codeam-cli 2.4.27 → 2.4.28

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.
package/dist/index.js CHANGED
@@ -30,6 +30,1309 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  mod
31
31
  ));
32
32
 
33
+ // ../../node_modules/node-pty/lib/utils.js
34
+ var require_utils = __commonJS({
35
+ "../../node_modules/node-pty/lib/utils.js"(exports2) {
36
+ "use strict";
37
+ Object.defineProperty(exports2, "__esModule", { value: true });
38
+ exports2.loadNativeModule = exports2.assign = void 0;
39
+ function assign(target) {
40
+ var sources = [];
41
+ for (var _i = 1; _i < arguments.length; _i++) {
42
+ sources[_i - 1] = arguments[_i];
43
+ }
44
+ sources.forEach(function(source) {
45
+ return Object.keys(source).forEach(function(key) {
46
+ return target[key] = source[key];
47
+ });
48
+ });
49
+ return target;
50
+ }
51
+ exports2.assign = assign;
52
+ function loadNativeModule(name) {
53
+ var dirs = ["build/Release", "build/Debug", "prebuilds/" + process.platform + "-" + process.arch];
54
+ var relative3 = ["..", "."];
55
+ var lastError;
56
+ for (var _i = 0, dirs_1 = dirs; _i < dirs_1.length; _i++) {
57
+ var d3 = dirs_1[_i];
58
+ for (var _a = 0, relative_1 = relative3; _a < relative_1.length; _a++) {
59
+ var r = relative_1[_a];
60
+ var dir = r + "/" + d3 + "/";
61
+ try {
62
+ return { dir, module: require(dir + "/" + name + ".node") };
63
+ } catch (e) {
64
+ lastError = e;
65
+ }
66
+ }
67
+ }
68
+ throw new Error("Failed to load native module: " + name + ".node, checked: " + dirs.join(", ") + ": " + lastError);
69
+ }
70
+ exports2.loadNativeModule = loadNativeModule;
71
+ }
72
+ });
73
+
74
+ // ../../node_modules/node-pty/lib/eventEmitter2.js
75
+ var require_eventEmitter2 = __commonJS({
76
+ "../../node_modules/node-pty/lib/eventEmitter2.js"(exports2) {
77
+ "use strict";
78
+ Object.defineProperty(exports2, "__esModule", { value: true });
79
+ exports2.EventEmitter2 = void 0;
80
+ var EventEmitter2 = (
81
+ /** @class */
82
+ (function() {
83
+ function EventEmitter22() {
84
+ this._listeners = [];
85
+ }
86
+ Object.defineProperty(EventEmitter22.prototype, "event", {
87
+ get: function() {
88
+ var _this = this;
89
+ if (!this._event) {
90
+ this._event = function(listener) {
91
+ _this._listeners.push(listener);
92
+ var disposable = {
93
+ dispose: function() {
94
+ for (var i = 0; i < _this._listeners.length; i++) {
95
+ if (_this._listeners[i] === listener) {
96
+ _this._listeners.splice(i, 1);
97
+ return;
98
+ }
99
+ }
100
+ }
101
+ };
102
+ return disposable;
103
+ };
104
+ }
105
+ return this._event;
106
+ },
107
+ enumerable: false,
108
+ configurable: true
109
+ });
110
+ EventEmitter22.prototype.fire = function(data) {
111
+ var queue = [];
112
+ for (var i = 0; i < this._listeners.length; i++) {
113
+ queue.push(this._listeners[i]);
114
+ }
115
+ for (var i = 0; i < queue.length; i++) {
116
+ queue[i].call(void 0, data);
117
+ }
118
+ };
119
+ return EventEmitter22;
120
+ })()
121
+ );
122
+ exports2.EventEmitter2 = EventEmitter2;
123
+ }
124
+ });
125
+
126
+ // ../../node_modules/node-pty/lib/terminal.js
127
+ var require_terminal = __commonJS({
128
+ "../../node_modules/node-pty/lib/terminal.js"(exports2) {
129
+ "use strict";
130
+ Object.defineProperty(exports2, "__esModule", { value: true });
131
+ exports2.Terminal = exports2.DEFAULT_ROWS = exports2.DEFAULT_COLS = void 0;
132
+ var events_1 = require("events");
133
+ var eventEmitter2_1 = require_eventEmitter2();
134
+ exports2.DEFAULT_COLS = 80;
135
+ exports2.DEFAULT_ROWS = 24;
136
+ var FLOW_CONTROL_PAUSE = "";
137
+ var FLOW_CONTROL_RESUME = "";
138
+ var Terminal = (
139
+ /** @class */
140
+ (function() {
141
+ function Terminal2(opt) {
142
+ this._pid = 0;
143
+ this._fd = 0;
144
+ this._cols = 0;
145
+ this._rows = 0;
146
+ this._readable = false;
147
+ this._writable = false;
148
+ this._onData = new eventEmitter2_1.EventEmitter2();
149
+ this._onExit = new eventEmitter2_1.EventEmitter2();
150
+ this._internalee = new events_1.EventEmitter();
151
+ this.handleFlowControl = !!(opt === null || opt === void 0 ? void 0 : opt.handleFlowControl);
152
+ this._flowControlPause = (opt === null || opt === void 0 ? void 0 : opt.flowControlPause) || FLOW_CONTROL_PAUSE;
153
+ this._flowControlResume = (opt === null || opt === void 0 ? void 0 : opt.flowControlResume) || FLOW_CONTROL_RESUME;
154
+ if (!opt) {
155
+ return;
156
+ }
157
+ this._checkType("name", opt.name ? opt.name : void 0, "string");
158
+ this._checkType("cols", opt.cols ? opt.cols : void 0, "number");
159
+ this._checkType("rows", opt.rows ? opt.rows : void 0, "number");
160
+ this._checkType("cwd", opt.cwd ? opt.cwd : void 0, "string");
161
+ this._checkType("env", opt.env ? opt.env : void 0, "object");
162
+ this._checkType("uid", opt.uid ? opt.uid : void 0, "number");
163
+ this._checkType("gid", opt.gid ? opt.gid : void 0, "number");
164
+ this._checkType("encoding", opt.encoding ? opt.encoding : void 0, "string");
165
+ }
166
+ Object.defineProperty(Terminal2.prototype, "onData", {
167
+ get: function() {
168
+ return this._onData.event;
169
+ },
170
+ enumerable: false,
171
+ configurable: true
172
+ });
173
+ Object.defineProperty(Terminal2.prototype, "onExit", {
174
+ get: function() {
175
+ return this._onExit.event;
176
+ },
177
+ enumerable: false,
178
+ configurable: true
179
+ });
180
+ Object.defineProperty(Terminal2.prototype, "pid", {
181
+ get: function() {
182
+ return this._pid;
183
+ },
184
+ enumerable: false,
185
+ configurable: true
186
+ });
187
+ Object.defineProperty(Terminal2.prototype, "cols", {
188
+ get: function() {
189
+ return this._cols;
190
+ },
191
+ enumerable: false,
192
+ configurable: true
193
+ });
194
+ Object.defineProperty(Terminal2.prototype, "rows", {
195
+ get: function() {
196
+ return this._rows;
197
+ },
198
+ enumerable: false,
199
+ configurable: true
200
+ });
201
+ Terminal2.prototype.write = function(data) {
202
+ if (this.handleFlowControl) {
203
+ if (data === this._flowControlPause) {
204
+ this.pause();
205
+ return;
206
+ }
207
+ if (data === this._flowControlResume) {
208
+ this.resume();
209
+ return;
210
+ }
211
+ }
212
+ this._write(data);
213
+ };
214
+ Terminal2.prototype._forwardEvents = function() {
215
+ var _this = this;
216
+ this.on("data", function(e) {
217
+ return _this._onData.fire(e);
218
+ });
219
+ this.on("exit", function(exitCode, signal) {
220
+ return _this._onExit.fire({ exitCode, signal });
221
+ });
222
+ };
223
+ Terminal2.prototype._checkType = function(name, value, type, allowArray) {
224
+ if (allowArray === void 0) {
225
+ allowArray = false;
226
+ }
227
+ if (value === void 0) {
228
+ return;
229
+ }
230
+ if (allowArray) {
231
+ if (Array.isArray(value)) {
232
+ value.forEach(function(v, i) {
233
+ if (typeof v !== type) {
234
+ throw new Error(name + "[" + i + "] must be a " + type + " (not a " + typeof v[i] + ")");
235
+ }
236
+ });
237
+ return;
238
+ }
239
+ }
240
+ if (typeof value !== type) {
241
+ throw new Error(name + " must be a " + type + " (not a " + typeof value + ")");
242
+ }
243
+ };
244
+ Terminal2.prototype.end = function(data) {
245
+ this._socket.end(data);
246
+ };
247
+ Terminal2.prototype.pipe = function(dest, options) {
248
+ return this._socket.pipe(dest, options);
249
+ };
250
+ Terminal2.prototype.pause = function() {
251
+ return this._socket.pause();
252
+ };
253
+ Terminal2.prototype.resume = function() {
254
+ return this._socket.resume();
255
+ };
256
+ Terminal2.prototype.setEncoding = function(encoding) {
257
+ if (this._socket._decoder) {
258
+ delete this._socket._decoder;
259
+ }
260
+ if (encoding) {
261
+ this._socket.setEncoding(encoding);
262
+ }
263
+ };
264
+ Terminal2.prototype.addListener = function(eventName, listener) {
265
+ this.on(eventName, listener);
266
+ };
267
+ Terminal2.prototype.on = function(eventName, listener) {
268
+ if (eventName === "close") {
269
+ this._internalee.on("close", listener);
270
+ return;
271
+ }
272
+ this._socket.on(eventName, listener);
273
+ };
274
+ Terminal2.prototype.emit = function(eventName) {
275
+ var args2 = [];
276
+ for (var _i = 1; _i < arguments.length; _i++) {
277
+ args2[_i - 1] = arguments[_i];
278
+ }
279
+ if (eventName === "close") {
280
+ return this._internalee.emit.apply(this._internalee, arguments);
281
+ }
282
+ return this._socket.emit.apply(this._socket, arguments);
283
+ };
284
+ Terminal2.prototype.listeners = function(eventName) {
285
+ return this._socket.listeners(eventName);
286
+ };
287
+ Terminal2.prototype.removeListener = function(eventName, listener) {
288
+ this._socket.removeListener(eventName, listener);
289
+ };
290
+ Terminal2.prototype.removeAllListeners = function(eventName) {
291
+ this._socket.removeAllListeners(eventName);
292
+ };
293
+ Terminal2.prototype.once = function(eventName, listener) {
294
+ this._socket.once(eventName, listener);
295
+ };
296
+ Terminal2.prototype._close = function() {
297
+ this._socket.readable = false;
298
+ this.write = function() {
299
+ };
300
+ this.end = function() {
301
+ };
302
+ this._writable = false;
303
+ this._readable = false;
304
+ };
305
+ Terminal2.prototype._parseEnv = function(env) {
306
+ var keys = Object.keys(env || {});
307
+ var pairs = [];
308
+ for (var i = 0; i < keys.length; i++) {
309
+ if (keys[i] === void 0) {
310
+ continue;
311
+ }
312
+ pairs.push(keys[i] + "=" + env[keys[i]]);
313
+ }
314
+ return pairs;
315
+ };
316
+ return Terminal2;
317
+ })()
318
+ );
319
+ exports2.Terminal = Terminal;
320
+ }
321
+ });
322
+
323
+ // ../../node_modules/node-pty/lib/shared/conout.js
324
+ var require_conout = __commonJS({
325
+ "../../node_modules/node-pty/lib/shared/conout.js"(exports2) {
326
+ "use strict";
327
+ Object.defineProperty(exports2, "__esModule", { value: true });
328
+ exports2.getWorkerPipeName = void 0;
329
+ function getWorkerPipeName(conoutPipeName) {
330
+ return conoutPipeName + "-worker";
331
+ }
332
+ exports2.getWorkerPipeName = getWorkerPipeName;
333
+ }
334
+ });
335
+
336
+ // ../../node_modules/node-pty/lib/windowsConoutConnection.js
337
+ var require_windowsConoutConnection = __commonJS({
338
+ "../../node_modules/node-pty/lib/windowsConoutConnection.js"(exports2) {
339
+ "use strict";
340
+ var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P3, generator) {
341
+ function adopt(value) {
342
+ return value instanceof P3 ? value : new P3(function(resolve2) {
343
+ resolve2(value);
344
+ });
345
+ }
346
+ return new (P3 || (P3 = Promise))(function(resolve2, reject) {
347
+ function fulfilled(value) {
348
+ try {
349
+ step(generator.next(value));
350
+ } catch (e) {
351
+ reject(e);
352
+ }
353
+ }
354
+ function rejected(value) {
355
+ try {
356
+ step(generator["throw"](value));
357
+ } catch (e) {
358
+ reject(e);
359
+ }
360
+ }
361
+ function step(result) {
362
+ result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
363
+ }
364
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
365
+ });
366
+ };
367
+ var __generator = exports2 && exports2.__generator || function(thisArg, body) {
368
+ var _2 = { label: 0, sent: function() {
369
+ if (t2[0] & 1) throw t2[1];
370
+ return t2[1];
371
+ }, trys: [], ops: [] }, f, y2, t2, g;
372
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
373
+ return this;
374
+ }), g;
375
+ function verb(n) {
376
+ return function(v) {
377
+ return step([n, v]);
378
+ };
379
+ }
380
+ function step(op) {
381
+ if (f) throw new TypeError("Generator is already executing.");
382
+ while (_2) try {
383
+ if (f = 1, y2 && (t2 = op[0] & 2 ? y2["return"] : op[0] ? y2["throw"] || ((t2 = y2["return"]) && t2.call(y2), 0) : y2.next) && !(t2 = t2.call(y2, op[1])).done) return t2;
384
+ if (y2 = 0, t2) op = [op[0] & 2, t2.value];
385
+ switch (op[0]) {
386
+ case 0:
387
+ case 1:
388
+ t2 = op;
389
+ break;
390
+ case 4:
391
+ _2.label++;
392
+ return { value: op[1], done: false };
393
+ case 5:
394
+ _2.label++;
395
+ y2 = op[1];
396
+ op = [0];
397
+ continue;
398
+ case 7:
399
+ op = _2.ops.pop();
400
+ _2.trys.pop();
401
+ continue;
402
+ default:
403
+ if (!(t2 = _2.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) {
404
+ _2 = 0;
405
+ continue;
406
+ }
407
+ if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) {
408
+ _2.label = op[1];
409
+ break;
410
+ }
411
+ if (op[0] === 6 && _2.label < t2[1]) {
412
+ _2.label = t2[1];
413
+ t2 = op;
414
+ break;
415
+ }
416
+ if (t2 && _2.label < t2[2]) {
417
+ _2.label = t2[2];
418
+ _2.ops.push(op);
419
+ break;
420
+ }
421
+ if (t2[2]) _2.ops.pop();
422
+ _2.trys.pop();
423
+ continue;
424
+ }
425
+ op = body.call(thisArg, _2);
426
+ } catch (e) {
427
+ op = [6, e];
428
+ y2 = 0;
429
+ } finally {
430
+ f = t2 = 0;
431
+ }
432
+ if (op[0] & 5) throw op[1];
433
+ return { value: op[0] ? op[1] : void 0, done: true };
434
+ }
435
+ };
436
+ Object.defineProperty(exports2, "__esModule", { value: true });
437
+ exports2.ConoutConnection = void 0;
438
+ var worker_threads_1 = require("worker_threads");
439
+ var conout_1 = require_conout();
440
+ var path_1 = require("path");
441
+ var eventEmitter2_1 = require_eventEmitter2();
442
+ var FLUSH_DATA_INTERVAL = 1e3;
443
+ var ConoutConnection = (
444
+ /** @class */
445
+ (function() {
446
+ function ConoutConnection2(_conoutPipeName, _useConptyDll) {
447
+ var _this = this;
448
+ this._conoutPipeName = _conoutPipeName;
449
+ this._useConptyDll = _useConptyDll;
450
+ this._isDisposed = false;
451
+ this._onReady = new eventEmitter2_1.EventEmitter2();
452
+ var workerData = {
453
+ conoutPipeName: _conoutPipeName
454
+ };
455
+ var scriptPath = __dirname.replace("node_modules.asar", "node_modules.asar.unpacked");
456
+ this._worker = new worker_threads_1.Worker(path_1.join(scriptPath, "worker/conoutSocketWorker.js"), { workerData });
457
+ this._worker.on("message", function(message) {
458
+ switch (message) {
459
+ case 1:
460
+ _this._onReady.fire();
461
+ return;
462
+ default:
463
+ console.warn("Unexpected ConoutWorkerMessage", message);
464
+ }
465
+ });
466
+ }
467
+ Object.defineProperty(ConoutConnection2.prototype, "onReady", {
468
+ get: function() {
469
+ return this._onReady.event;
470
+ },
471
+ enumerable: false,
472
+ configurable: true
473
+ });
474
+ ConoutConnection2.prototype.dispose = function() {
475
+ if (!this._useConptyDll && this._isDisposed) {
476
+ return;
477
+ }
478
+ this._isDisposed = true;
479
+ this._drainDataAndClose();
480
+ };
481
+ ConoutConnection2.prototype.connectSocket = function(socket) {
482
+ socket.connect(conout_1.getWorkerPipeName(this._conoutPipeName));
483
+ };
484
+ ConoutConnection2.prototype._drainDataAndClose = function() {
485
+ var _this = this;
486
+ if (this._drainTimeout) {
487
+ clearTimeout(this._drainTimeout);
488
+ }
489
+ this._drainTimeout = setTimeout(function() {
490
+ return _this._destroySocket();
491
+ }, FLUSH_DATA_INTERVAL);
492
+ };
493
+ ConoutConnection2.prototype._destroySocket = function() {
494
+ return __awaiter(this, void 0, void 0, function() {
495
+ return __generator(this, function(_a) {
496
+ switch (_a.label) {
497
+ case 0:
498
+ return [4, this._worker.terminate()];
499
+ case 1:
500
+ _a.sent();
501
+ return [
502
+ 2
503
+ /*return*/
504
+ ];
505
+ }
506
+ });
507
+ });
508
+ };
509
+ return ConoutConnection2;
510
+ })()
511
+ );
512
+ exports2.ConoutConnection = ConoutConnection;
513
+ }
514
+ });
515
+
516
+ // ../../node_modules/node-pty/lib/windowsPtyAgent.js
517
+ var require_windowsPtyAgent = __commonJS({
518
+ "../../node_modules/node-pty/lib/windowsPtyAgent.js"(exports2) {
519
+ "use strict";
520
+ Object.defineProperty(exports2, "__esModule", { value: true });
521
+ exports2.argsToCommandLine = exports2.WindowsPtyAgent = void 0;
522
+ var fs9 = require("fs");
523
+ var os7 = require("os");
524
+ var path13 = require("path");
525
+ var child_process_1 = require("child_process");
526
+ var net_1 = require("net");
527
+ var windowsConoutConnection_1 = require_windowsConoutConnection();
528
+ var utils_1 = require_utils();
529
+ var conptyNative;
530
+ var winptyNative;
531
+ var FLUSH_DATA_INTERVAL = 1e3;
532
+ var WindowsPtyAgent = (
533
+ /** @class */
534
+ (function() {
535
+ function WindowsPtyAgent2(file, args2, env, cwd, cols, rows, debug, _useConpty, _useConptyDll, conptyInheritCursor) {
536
+ var _this = this;
537
+ if (_useConptyDll === void 0) {
538
+ _useConptyDll = false;
539
+ }
540
+ if (conptyInheritCursor === void 0) {
541
+ conptyInheritCursor = false;
542
+ }
543
+ this._useConpty = _useConpty;
544
+ this._useConptyDll = _useConptyDll;
545
+ this._pid = 0;
546
+ this._innerPid = 0;
547
+ if (this._useConpty === void 0 || this._useConpty === true) {
548
+ this._useConpty = this._getWindowsBuildNumber() >= 18309;
549
+ }
550
+ if (this._useConpty) {
551
+ if (!conptyNative) {
552
+ conptyNative = utils_1.loadNativeModule("conpty").module;
553
+ }
554
+ } else {
555
+ if (!winptyNative) {
556
+ winptyNative = utils_1.loadNativeModule("pty").module;
557
+ }
558
+ }
559
+ this._ptyNative = this._useConpty ? conptyNative : winptyNative;
560
+ cwd = path13.resolve(cwd);
561
+ var commandLine = argsToCommandLine(file, args2);
562
+ var term;
563
+ if (this._useConpty) {
564
+ term = this._ptyNative.startProcess(file, cols, rows, debug, this._generatePipeName(), conptyInheritCursor, this._useConptyDll);
565
+ } else {
566
+ term = this._ptyNative.startProcess(file, commandLine, env, cwd, cols, rows, debug);
567
+ this._pid = term.pid;
568
+ this._innerPid = term.innerPid;
569
+ }
570
+ this._fd = term.fd;
571
+ this._pty = term.pty;
572
+ this._outSocket = new net_1.Socket();
573
+ this._outSocket.setEncoding("utf8");
574
+ this._conoutSocketWorker = new windowsConoutConnection_1.ConoutConnection(term.conout, this._useConptyDll);
575
+ this._conoutSocketWorker.onReady(function() {
576
+ _this._conoutSocketWorker.connectSocket(_this._outSocket);
577
+ });
578
+ this._outSocket.on("connect", function() {
579
+ _this._outSocket.emit("ready_datapipe");
580
+ });
581
+ var inSocketFD = fs9.openSync(term.conin, "w");
582
+ this._inSocket = new net_1.Socket({
583
+ fd: inSocketFD,
584
+ readable: false,
585
+ writable: true
586
+ });
587
+ this._inSocket.setEncoding("utf8");
588
+ if (this._useConpty) {
589
+ var connect = this._ptyNative.connect(this._pty, commandLine, cwd, env, this._useConptyDll, function(c2) {
590
+ return _this._$onProcessExit(c2);
591
+ });
592
+ this._innerPid = connect.pid;
593
+ }
594
+ }
595
+ Object.defineProperty(WindowsPtyAgent2.prototype, "inSocket", {
596
+ get: function() {
597
+ return this._inSocket;
598
+ },
599
+ enumerable: false,
600
+ configurable: true
601
+ });
602
+ Object.defineProperty(WindowsPtyAgent2.prototype, "outSocket", {
603
+ get: function() {
604
+ return this._outSocket;
605
+ },
606
+ enumerable: false,
607
+ configurable: true
608
+ });
609
+ Object.defineProperty(WindowsPtyAgent2.prototype, "fd", {
610
+ get: function() {
611
+ return this._fd;
612
+ },
613
+ enumerable: false,
614
+ configurable: true
615
+ });
616
+ Object.defineProperty(WindowsPtyAgent2.prototype, "innerPid", {
617
+ get: function() {
618
+ return this._innerPid;
619
+ },
620
+ enumerable: false,
621
+ configurable: true
622
+ });
623
+ Object.defineProperty(WindowsPtyAgent2.prototype, "pty", {
624
+ get: function() {
625
+ return this._pty;
626
+ },
627
+ enumerable: false,
628
+ configurable: true
629
+ });
630
+ WindowsPtyAgent2.prototype.resize = function(cols, rows) {
631
+ if (this._useConpty) {
632
+ if (this._exitCode !== void 0) {
633
+ throw new Error("Cannot resize a pty that has already exited");
634
+ }
635
+ this._ptyNative.resize(this._pty, cols, rows, this._useConptyDll);
636
+ return;
637
+ }
638
+ this._ptyNative.resize(this._pid, cols, rows);
639
+ };
640
+ WindowsPtyAgent2.prototype.clear = function() {
641
+ if (this._useConpty) {
642
+ this._ptyNative.clear(this._pty, this._useConptyDll);
643
+ }
644
+ };
645
+ WindowsPtyAgent2.prototype.kill = function() {
646
+ var _this = this;
647
+ if (this._useConpty) {
648
+ if (!this._useConptyDll) {
649
+ this._inSocket.readable = false;
650
+ this._outSocket.readable = false;
651
+ this._getConsoleProcessList().then(function(consoleProcessList) {
652
+ consoleProcessList.forEach(function(pid) {
653
+ try {
654
+ process.kill(pid);
655
+ } catch (e) {
656
+ }
657
+ });
658
+ });
659
+ this._ptyNative.kill(this._pty, this._useConptyDll);
660
+ this._conoutSocketWorker.dispose();
661
+ } else {
662
+ this._inSocket.destroy();
663
+ this._ptyNative.kill(this._pty, this._useConptyDll);
664
+ this._outSocket.on("data", function() {
665
+ _this._conoutSocketWorker.dispose();
666
+ });
667
+ }
668
+ } else {
669
+ var processList = this._ptyNative.getProcessList(this._pid);
670
+ this._ptyNative.kill(this._pid, this._innerPid);
671
+ processList.forEach(function(pid) {
672
+ try {
673
+ process.kill(pid);
674
+ } catch (e) {
675
+ }
676
+ });
677
+ }
678
+ };
679
+ WindowsPtyAgent2.prototype._getConsoleProcessList = function() {
680
+ var _this = this;
681
+ return new Promise(function(resolve2) {
682
+ var agent = child_process_1.fork(path13.join(__dirname, "conpty_console_list_agent"), [_this._innerPid.toString()]);
683
+ agent.on("message", function(message) {
684
+ clearTimeout(timeout);
685
+ resolve2(message.consoleProcessList);
686
+ });
687
+ var timeout = setTimeout(function() {
688
+ agent.kill();
689
+ resolve2([_this._innerPid]);
690
+ }, 5e3);
691
+ });
692
+ };
693
+ Object.defineProperty(WindowsPtyAgent2.prototype, "exitCode", {
694
+ get: function() {
695
+ if (this._useConpty) {
696
+ return this._exitCode;
697
+ }
698
+ var winptyExitCode = this._ptyNative.getExitCode(this._innerPid);
699
+ return winptyExitCode === -1 ? void 0 : winptyExitCode;
700
+ },
701
+ enumerable: false,
702
+ configurable: true
703
+ });
704
+ WindowsPtyAgent2.prototype._getWindowsBuildNumber = function() {
705
+ var osVersion = /(\d+)\.(\d+)\.(\d+)/g.exec(os7.release());
706
+ var buildNumber = 0;
707
+ if (osVersion && osVersion.length === 4) {
708
+ buildNumber = parseInt(osVersion[3]);
709
+ }
710
+ return buildNumber;
711
+ };
712
+ WindowsPtyAgent2.prototype._generatePipeName = function() {
713
+ return "conpty-" + Math.random() * 1e7;
714
+ };
715
+ WindowsPtyAgent2.prototype._$onProcessExit = function(exitCode) {
716
+ var _this = this;
717
+ this._exitCode = exitCode;
718
+ if (!this._useConptyDll) {
719
+ this._flushDataAndCleanUp();
720
+ this._outSocket.on("data", function() {
721
+ return _this._flushDataAndCleanUp();
722
+ });
723
+ }
724
+ };
725
+ WindowsPtyAgent2.prototype._flushDataAndCleanUp = function() {
726
+ var _this = this;
727
+ if (this._useConptyDll) {
728
+ return;
729
+ }
730
+ if (this._closeTimeout) {
731
+ clearTimeout(this._closeTimeout);
732
+ }
733
+ this._closeTimeout = setTimeout(function() {
734
+ return _this._cleanUpProcess();
735
+ }, FLUSH_DATA_INTERVAL);
736
+ };
737
+ WindowsPtyAgent2.prototype._cleanUpProcess = function() {
738
+ if (this._useConptyDll) {
739
+ return;
740
+ }
741
+ this._inSocket.readable = false;
742
+ this._outSocket.readable = false;
743
+ this._outSocket.destroy();
744
+ };
745
+ return WindowsPtyAgent2;
746
+ })()
747
+ );
748
+ exports2.WindowsPtyAgent = WindowsPtyAgent;
749
+ function argsToCommandLine(file, args2) {
750
+ if (isCommandLine(args2)) {
751
+ if (args2.length === 0) {
752
+ return file;
753
+ }
754
+ return argsToCommandLine(file, []) + " " + args2;
755
+ }
756
+ var argv = [file];
757
+ Array.prototype.push.apply(argv, args2);
758
+ var result = "";
759
+ for (var argIndex = 0; argIndex < argv.length; argIndex++) {
760
+ if (argIndex > 0) {
761
+ result += " ";
762
+ }
763
+ var arg = argv[argIndex];
764
+ var hasLopsidedEnclosingQuote = xOr(arg[0] !== '"', arg[arg.length - 1] !== '"');
765
+ var hasNoEnclosingQuotes = arg[0] !== '"' && arg[arg.length - 1] !== '"';
766
+ var quote = arg === "" || (arg.indexOf(" ") !== -1 || arg.indexOf(" ") !== -1) && (arg.length > 1 && (hasLopsidedEnclosingQuote || hasNoEnclosingQuotes));
767
+ if (quote) {
768
+ result += '"';
769
+ }
770
+ var bsCount = 0;
771
+ for (var i = 0; i < arg.length; i++) {
772
+ var p2 = arg[i];
773
+ if (p2 === "\\") {
774
+ bsCount++;
775
+ } else if (p2 === '"') {
776
+ result += repeatText("\\", bsCount * 2 + 1);
777
+ result += '"';
778
+ bsCount = 0;
779
+ } else {
780
+ result += repeatText("\\", bsCount);
781
+ bsCount = 0;
782
+ result += p2;
783
+ }
784
+ }
785
+ if (quote) {
786
+ result += repeatText("\\", bsCount * 2);
787
+ result += '"';
788
+ } else {
789
+ result += repeatText("\\", bsCount);
790
+ }
791
+ }
792
+ return result;
793
+ }
794
+ exports2.argsToCommandLine = argsToCommandLine;
795
+ function isCommandLine(args2) {
796
+ return typeof args2 === "string";
797
+ }
798
+ function repeatText(text, count) {
799
+ var result = "";
800
+ for (var i = 0; i < count; i++) {
801
+ result += text;
802
+ }
803
+ return result;
804
+ }
805
+ function xOr(arg1, arg2) {
806
+ return arg1 && !arg2 || !arg1 && arg2;
807
+ }
808
+ }
809
+ });
810
+
811
+ // ../../node_modules/node-pty/lib/windowsTerminal.js
812
+ var require_windowsTerminal = __commonJS({
813
+ "../../node_modules/node-pty/lib/windowsTerminal.js"(exports2) {
814
+ "use strict";
815
+ var __extends = exports2 && exports2.__extends || /* @__PURE__ */ (function() {
816
+ var extendStatics = function(d3, b) {
817
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d4, b2) {
818
+ d4.__proto__ = b2;
819
+ } || function(d4, b2) {
820
+ for (var p2 in b2) if (b2.hasOwnProperty(p2)) d4[p2] = b2[p2];
821
+ };
822
+ return extendStatics(d3, b);
823
+ };
824
+ return function(d3, b) {
825
+ extendStatics(d3, b);
826
+ function __() {
827
+ this.constructor = d3;
828
+ }
829
+ d3.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
830
+ };
831
+ })();
832
+ Object.defineProperty(exports2, "__esModule", { value: true });
833
+ exports2.WindowsTerminal = void 0;
834
+ var terminal_1 = require_terminal();
835
+ var windowsPtyAgent_1 = require_windowsPtyAgent();
836
+ var utils_1 = require_utils();
837
+ var DEFAULT_FILE = "cmd.exe";
838
+ var DEFAULT_NAME = "Windows Shell";
839
+ var WindowsTerminal = (
840
+ /** @class */
841
+ (function(_super) {
842
+ __extends(WindowsTerminal2, _super);
843
+ function WindowsTerminal2(file, args2, opt) {
844
+ var _this = _super.call(this, opt) || this;
845
+ _this._checkType("args", args2, "string", true);
846
+ args2 = args2 || [];
847
+ file = file || DEFAULT_FILE;
848
+ opt = opt || {};
849
+ opt.env = opt.env || process.env;
850
+ if (opt.encoding) {
851
+ console.warn("Setting encoding on Windows is not supported");
852
+ }
853
+ var env = utils_1.assign({}, opt.env);
854
+ _this._cols = opt.cols || terminal_1.DEFAULT_COLS;
855
+ _this._rows = opt.rows || terminal_1.DEFAULT_ROWS;
856
+ var cwd = opt.cwd || process.cwd();
857
+ var name = opt.name || env.TERM || DEFAULT_NAME;
858
+ var parsedEnv = _this._parseEnv(env);
859
+ _this._isReady = false;
860
+ _this._deferreds = [];
861
+ _this._agent = new windowsPtyAgent_1.WindowsPtyAgent(file, args2, parsedEnv, cwd, _this._cols, _this._rows, false, opt.useConpty, opt.useConptyDll, opt.conptyInheritCursor);
862
+ _this._socket = _this._agent.outSocket;
863
+ _this._pid = _this._agent.innerPid;
864
+ _this._fd = _this._agent.fd;
865
+ _this._pty = _this._agent.pty;
866
+ _this._socket.on("ready_datapipe", function() {
867
+ _this._socket.once("data", function() {
868
+ if (!_this._isReady) {
869
+ _this._isReady = true;
870
+ _this._deferreds.forEach(function(fn) {
871
+ fn.run();
872
+ });
873
+ _this._deferreds = [];
874
+ }
875
+ });
876
+ _this._socket.on("error", function(err) {
877
+ _this._close();
878
+ if (err.code) {
879
+ if (~err.code.indexOf("errno 5") || ~err.code.indexOf("EIO"))
880
+ return;
881
+ }
882
+ if (_this.listeners("error").length < 2) {
883
+ throw err;
884
+ }
885
+ });
886
+ _this._socket.on("close", function() {
887
+ _this.emit("exit", _this._agent.exitCode);
888
+ _this._close();
889
+ });
890
+ });
891
+ _this._file = file;
892
+ _this._name = name;
893
+ _this._readable = true;
894
+ _this._writable = true;
895
+ _this._forwardEvents();
896
+ return _this;
897
+ }
898
+ WindowsTerminal2.prototype._write = function(data) {
899
+ this._defer(this._doWrite, data);
900
+ };
901
+ WindowsTerminal2.prototype._doWrite = function(data) {
902
+ this._agent.inSocket.write(data);
903
+ };
904
+ WindowsTerminal2.open = function(options) {
905
+ throw new Error("open() not supported on windows, use Fork() instead.");
906
+ };
907
+ WindowsTerminal2.prototype.resize = function(cols, rows) {
908
+ var _this = this;
909
+ if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) {
910
+ throw new Error("resizing must be done using positive cols and rows");
911
+ }
912
+ this._deferNoArgs(function() {
913
+ _this._agent.resize(cols, rows);
914
+ _this._cols = cols;
915
+ _this._rows = rows;
916
+ });
917
+ };
918
+ WindowsTerminal2.prototype.clear = function() {
919
+ var _this = this;
920
+ this._deferNoArgs(function() {
921
+ _this._agent.clear();
922
+ });
923
+ };
924
+ WindowsTerminal2.prototype.destroy = function() {
925
+ var _this = this;
926
+ this._deferNoArgs(function() {
927
+ _this.kill();
928
+ });
929
+ };
930
+ WindowsTerminal2.prototype.kill = function(signal) {
931
+ var _this = this;
932
+ this._deferNoArgs(function() {
933
+ if (signal) {
934
+ throw new Error("Signals not supported on windows.");
935
+ }
936
+ _this._close();
937
+ _this._agent.kill();
938
+ });
939
+ };
940
+ WindowsTerminal2.prototype._deferNoArgs = function(deferredFn) {
941
+ var _this = this;
942
+ if (this._isReady) {
943
+ deferredFn.call(this);
944
+ return;
945
+ }
946
+ this._deferreds.push({
947
+ run: function() {
948
+ return deferredFn.call(_this);
949
+ }
950
+ });
951
+ };
952
+ WindowsTerminal2.prototype._defer = function(deferredFn, arg) {
953
+ var _this = this;
954
+ if (this._isReady) {
955
+ deferredFn.call(this, arg);
956
+ return;
957
+ }
958
+ this._deferreds.push({
959
+ run: function() {
960
+ return deferredFn.call(_this, arg);
961
+ }
962
+ });
963
+ };
964
+ Object.defineProperty(WindowsTerminal2.prototype, "process", {
965
+ get: function() {
966
+ return this._name;
967
+ },
968
+ enumerable: false,
969
+ configurable: true
970
+ });
971
+ Object.defineProperty(WindowsTerminal2.prototype, "master", {
972
+ get: function() {
973
+ throw new Error("master is not supported on Windows");
974
+ },
975
+ enumerable: false,
976
+ configurable: true
977
+ });
978
+ Object.defineProperty(WindowsTerminal2.prototype, "slave", {
979
+ get: function() {
980
+ throw new Error("slave is not supported on Windows");
981
+ },
982
+ enumerable: false,
983
+ configurable: true
984
+ });
985
+ return WindowsTerminal2;
986
+ })(terminal_1.Terminal)
987
+ );
988
+ exports2.WindowsTerminal = WindowsTerminal;
989
+ }
990
+ });
991
+
992
+ // ../../node_modules/node-pty/lib/unixTerminal.js
993
+ var require_unixTerminal = __commonJS({
994
+ "../../node_modules/node-pty/lib/unixTerminal.js"(exports2) {
995
+ "use strict";
996
+ var __extends = exports2 && exports2.__extends || /* @__PURE__ */ (function() {
997
+ var extendStatics = function(d3, b) {
998
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d4, b2) {
999
+ d4.__proto__ = b2;
1000
+ } || function(d4, b2) {
1001
+ for (var p2 in b2) if (b2.hasOwnProperty(p2)) d4[p2] = b2[p2];
1002
+ };
1003
+ return extendStatics(d3, b);
1004
+ };
1005
+ return function(d3, b) {
1006
+ extendStatics(d3, b);
1007
+ function __() {
1008
+ this.constructor = d3;
1009
+ }
1010
+ d3.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1011
+ };
1012
+ })();
1013
+ Object.defineProperty(exports2, "__esModule", { value: true });
1014
+ exports2.UnixTerminal = void 0;
1015
+ var fs9 = require("fs");
1016
+ var path13 = require("path");
1017
+ var tty = require("tty");
1018
+ var terminal_1 = require_terminal();
1019
+ var utils_1 = require_utils();
1020
+ var native = utils_1.loadNativeModule("pty");
1021
+ var pty = native.module;
1022
+ var helperPath = native.dir + "/spawn-helper";
1023
+ helperPath = path13.resolve(__dirname, helperPath);
1024
+ helperPath = helperPath.replace("app.asar", "app.asar.unpacked");
1025
+ helperPath = helperPath.replace("node_modules.asar", "node_modules.asar.unpacked");
1026
+ var DEFAULT_FILE = "sh";
1027
+ var DEFAULT_NAME = "xterm";
1028
+ var DESTROY_SOCKET_TIMEOUT_MS = 200;
1029
+ var UnixTerminal = (
1030
+ /** @class */
1031
+ (function(_super) {
1032
+ __extends(UnixTerminal2, _super);
1033
+ function UnixTerminal2(file, args2, opt) {
1034
+ var _a, _b;
1035
+ var _this = _super.call(this, opt) || this;
1036
+ _this._boundClose = false;
1037
+ _this._emittedClose = false;
1038
+ if (typeof args2 === "string") {
1039
+ throw new Error("args as a string is not supported on unix.");
1040
+ }
1041
+ args2 = args2 || [];
1042
+ file = file || DEFAULT_FILE;
1043
+ opt = opt || {};
1044
+ opt.env = opt.env || process.env;
1045
+ _this._cols = opt.cols || terminal_1.DEFAULT_COLS;
1046
+ _this._rows = opt.rows || terminal_1.DEFAULT_ROWS;
1047
+ var uid = (_a = opt.uid) !== null && _a !== void 0 ? _a : -1;
1048
+ var gid = (_b = opt.gid) !== null && _b !== void 0 ? _b : -1;
1049
+ var env = utils_1.assign({}, opt.env);
1050
+ if (opt.env === process.env) {
1051
+ _this._sanitizeEnv(env);
1052
+ }
1053
+ var cwd = opt.cwd || process.cwd();
1054
+ env.PWD = cwd;
1055
+ var name = opt.name || env.TERM || DEFAULT_NAME;
1056
+ env.TERM = name;
1057
+ var parsedEnv = _this._parseEnv(env);
1058
+ var encoding = opt.encoding === void 0 ? "utf8" : opt.encoding;
1059
+ var onexit = function(code, signal) {
1060
+ if (!_this._emittedClose) {
1061
+ if (_this._boundClose) {
1062
+ return;
1063
+ }
1064
+ _this._boundClose = true;
1065
+ var timeout_1 = setTimeout(function() {
1066
+ timeout_1 = null;
1067
+ _this._socket.destroy();
1068
+ }, DESTROY_SOCKET_TIMEOUT_MS);
1069
+ _this.once("close", function() {
1070
+ if (timeout_1 !== null) {
1071
+ clearTimeout(timeout_1);
1072
+ }
1073
+ _this.emit("exit", code, signal);
1074
+ });
1075
+ return;
1076
+ }
1077
+ _this.emit("exit", code, signal);
1078
+ };
1079
+ var term = pty.fork(file, args2, parsedEnv, cwd, _this._cols, _this._rows, uid, gid, encoding === "utf8", helperPath, onexit);
1080
+ _this._socket = new tty.ReadStream(term.fd);
1081
+ if (encoding !== null) {
1082
+ _this._socket.setEncoding(encoding);
1083
+ }
1084
+ _this._writeStream = new CustomWriteStream(term.fd, encoding || void 0);
1085
+ _this._socket.on("error", function(err) {
1086
+ if (err.code) {
1087
+ if (~err.code.indexOf("EAGAIN")) {
1088
+ return;
1089
+ }
1090
+ }
1091
+ _this._close();
1092
+ if (!_this._emittedClose) {
1093
+ _this._emittedClose = true;
1094
+ _this.emit("close");
1095
+ }
1096
+ if (err.code) {
1097
+ if (~err.code.indexOf("errno 5") || ~err.code.indexOf("EIO")) {
1098
+ return;
1099
+ }
1100
+ }
1101
+ if (_this.listeners("error").length < 2) {
1102
+ throw err;
1103
+ }
1104
+ });
1105
+ _this._pid = term.pid;
1106
+ _this._fd = term.fd;
1107
+ _this._pty = term.pty;
1108
+ _this._file = file;
1109
+ _this._name = name;
1110
+ _this._readable = true;
1111
+ _this._writable = true;
1112
+ _this._socket.on("close", function() {
1113
+ if (_this._emittedClose) {
1114
+ return;
1115
+ }
1116
+ _this._emittedClose = true;
1117
+ _this._close();
1118
+ _this.emit("close");
1119
+ });
1120
+ _this._forwardEvents();
1121
+ return _this;
1122
+ }
1123
+ Object.defineProperty(UnixTerminal2.prototype, "master", {
1124
+ get: function() {
1125
+ return this._master;
1126
+ },
1127
+ enumerable: false,
1128
+ configurable: true
1129
+ });
1130
+ Object.defineProperty(UnixTerminal2.prototype, "slave", {
1131
+ get: function() {
1132
+ return this._slave;
1133
+ },
1134
+ enumerable: false,
1135
+ configurable: true
1136
+ });
1137
+ UnixTerminal2.prototype._write = function(data) {
1138
+ this._writeStream.write(data);
1139
+ };
1140
+ Object.defineProperty(UnixTerminal2.prototype, "fd", {
1141
+ /* Accessors */
1142
+ get: function() {
1143
+ return this._fd;
1144
+ },
1145
+ enumerable: false,
1146
+ configurable: true
1147
+ });
1148
+ Object.defineProperty(UnixTerminal2.prototype, "ptsName", {
1149
+ get: function() {
1150
+ return this._pty;
1151
+ },
1152
+ enumerable: false,
1153
+ configurable: true
1154
+ });
1155
+ UnixTerminal2.open = function(opt) {
1156
+ var self = Object.create(UnixTerminal2.prototype);
1157
+ opt = opt || {};
1158
+ if (arguments.length > 1) {
1159
+ opt = {
1160
+ cols: arguments[1],
1161
+ rows: arguments[2]
1162
+ };
1163
+ }
1164
+ var cols = opt.cols || terminal_1.DEFAULT_COLS;
1165
+ var rows = opt.rows || terminal_1.DEFAULT_ROWS;
1166
+ var encoding = opt.encoding === void 0 ? "utf8" : opt.encoding;
1167
+ var term = pty.open(cols, rows);
1168
+ self._master = new tty.ReadStream(term.master);
1169
+ if (encoding !== null) {
1170
+ self._master.setEncoding(encoding);
1171
+ }
1172
+ self._master.resume();
1173
+ self._slave = new tty.ReadStream(term.slave);
1174
+ if (encoding !== null) {
1175
+ self._slave.setEncoding(encoding);
1176
+ }
1177
+ self._slave.resume();
1178
+ self._socket = self._master;
1179
+ self._pid = -1;
1180
+ self._fd = term.master;
1181
+ self._pty = term.pty;
1182
+ self._file = process.argv[0] || "node";
1183
+ self._name = process.env.TERM || "";
1184
+ self._readable = true;
1185
+ self._writable = true;
1186
+ self._socket.on("error", function(err) {
1187
+ self._close();
1188
+ if (self.listeners("error").length < 2) {
1189
+ throw err;
1190
+ }
1191
+ });
1192
+ self._socket.on("close", function() {
1193
+ self._close();
1194
+ });
1195
+ return self;
1196
+ };
1197
+ UnixTerminal2.prototype.destroy = function() {
1198
+ var _this = this;
1199
+ this._close();
1200
+ this._socket.once("close", function() {
1201
+ _this.kill("SIGHUP");
1202
+ });
1203
+ this._socket.destroy();
1204
+ this._writeStream.dispose();
1205
+ };
1206
+ UnixTerminal2.prototype.kill = function(signal) {
1207
+ try {
1208
+ process.kill(this.pid, signal || "SIGHUP");
1209
+ } catch (e) {
1210
+ }
1211
+ };
1212
+ Object.defineProperty(UnixTerminal2.prototype, "process", {
1213
+ /**
1214
+ * Gets the name of the process.
1215
+ */
1216
+ get: function() {
1217
+ if (process.platform === "darwin") {
1218
+ var title = pty.process(this._fd);
1219
+ return title !== "kernel_task" ? title : this._file;
1220
+ }
1221
+ return pty.process(this._fd, this._pty) || this._file;
1222
+ },
1223
+ enumerable: false,
1224
+ configurable: true
1225
+ });
1226
+ UnixTerminal2.prototype.resize = function(cols, rows) {
1227
+ if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) {
1228
+ throw new Error("resizing must be done using positive cols and rows");
1229
+ }
1230
+ pty.resize(this._fd, cols, rows);
1231
+ this._cols = cols;
1232
+ this._rows = rows;
1233
+ };
1234
+ UnixTerminal2.prototype.clear = function() {
1235
+ };
1236
+ UnixTerminal2.prototype._sanitizeEnv = function(env) {
1237
+ delete env["TMUX"];
1238
+ delete env["TMUX_PANE"];
1239
+ delete env["STY"];
1240
+ delete env["WINDOW"];
1241
+ delete env["WINDOWID"];
1242
+ delete env["TERMCAP"];
1243
+ delete env["COLUMNS"];
1244
+ delete env["LINES"];
1245
+ };
1246
+ return UnixTerminal2;
1247
+ })(terminal_1.Terminal)
1248
+ );
1249
+ exports2.UnixTerminal = UnixTerminal;
1250
+ var CustomWriteStream = (
1251
+ /** @class */
1252
+ (function() {
1253
+ function CustomWriteStream2(_fd, _encoding) {
1254
+ this._fd = _fd;
1255
+ this._encoding = _encoding;
1256
+ this._writeQueue = [];
1257
+ }
1258
+ CustomWriteStream2.prototype.dispose = function() {
1259
+ clearImmediate(this._writeImmediate);
1260
+ this._writeImmediate = void 0;
1261
+ };
1262
+ CustomWriteStream2.prototype.write = function(data) {
1263
+ var buffer = typeof data === "string" ? Buffer.from(data, this._encoding) : Buffer.from(data);
1264
+ if (buffer.byteLength !== 0) {
1265
+ this._writeQueue.push({ buffer, offset: 0 });
1266
+ if (this._writeQueue.length === 1) {
1267
+ this._processWriteQueue();
1268
+ }
1269
+ }
1270
+ };
1271
+ CustomWriteStream2.prototype._processWriteQueue = function() {
1272
+ var _this = this;
1273
+ this._writeImmediate = void 0;
1274
+ if (this._writeQueue.length === 0) {
1275
+ return;
1276
+ }
1277
+ var task = this._writeQueue[0];
1278
+ fs9.write(this._fd, task.buffer, task.offset, function(err, written) {
1279
+ if (err) {
1280
+ if ("code" in err && err.code === "EAGAIN") {
1281
+ _this._writeImmediate = setImmediate(function() {
1282
+ return _this._processWriteQueue();
1283
+ });
1284
+ } else {
1285
+ _this._writeQueue.length = 0;
1286
+ console.error("Unhandled pty write error", err);
1287
+ }
1288
+ return;
1289
+ }
1290
+ task.offset += written;
1291
+ if (task.offset >= task.buffer.byteLength) {
1292
+ _this._writeQueue.shift();
1293
+ }
1294
+ _this._processWriteQueue();
1295
+ });
1296
+ };
1297
+ return CustomWriteStream2;
1298
+ })()
1299
+ );
1300
+ }
1301
+ });
1302
+
1303
+ // ../../node_modules/node-pty/lib/index.js
1304
+ var require_lib = __commonJS({
1305
+ "../../node_modules/node-pty/lib/index.js"(exports2) {
1306
+ "use strict";
1307
+ Object.defineProperty(exports2, "__esModule", { value: true });
1308
+ exports2.native = exports2.open = exports2.createTerminal = exports2.fork = exports2.spawn = void 0;
1309
+ var utils_1 = require_utils();
1310
+ var terminalCtor;
1311
+ if (process.platform === "win32") {
1312
+ terminalCtor = require_windowsTerminal().WindowsTerminal;
1313
+ } else {
1314
+ terminalCtor = require_unixTerminal().UnixTerminal;
1315
+ }
1316
+ function spawn8(file, args2, opt) {
1317
+ return new terminalCtor(file, args2, opt);
1318
+ }
1319
+ exports2.spawn = spawn8;
1320
+ function fork(file, args2, opt) {
1321
+ return new terminalCtor(file, args2, opt);
1322
+ }
1323
+ exports2.fork = fork;
1324
+ function createTerminal(file, args2, opt) {
1325
+ return new terminalCtor(file, args2, opt);
1326
+ }
1327
+ exports2.createTerminal = createTerminal;
1328
+ function open(options) {
1329
+ return terminalCtor.open(options);
1330
+ }
1331
+ exports2.open = open;
1332
+ exports2.native = process.platform !== "win32" ? utils_1.loadNativeModule("pty").module : null;
1333
+ }
1334
+ });
1335
+
33
1336
  // ../../node_modules/sisteransi/src/index.js
34
1337
  var require_src = __commonJS({
35
1338
  "../../node_modules/sisteransi/src/index.js"(exports2, module2) {
@@ -179,7 +1482,7 @@ var import_qrcode_terminal = __toESM(require("qrcode-terminal"));
179
1482
  // package.json
180
1483
  var package_default = {
181
1484
  name: "codeam-cli",
182
- version: "2.4.27",
1485
+ version: "2.4.28",
183
1486
  description: "Remote control Claude Code (and other AI coding agents) from your mobile phone. Pair your device, send prompts, stream responses in real-time, and approve commands \u2014 from anywhere.",
184
1487
  main: "dist/index.js",
185
1488
  bin: {
@@ -253,6 +1556,9 @@ var package_default = {
253
1556
  ws: "^8.18.0",
254
1557
  zod: "^4.3.6"
255
1558
  },
1559
+ optionalDependencies: {
1560
+ "node-pty": "^1.0.0"
1561
+ },
256
1562
  devDependencies: {
257
1563
  "@codeagent/shared": "*",
258
1564
  "@types/node": "^22.0.0",
@@ -955,6 +2261,110 @@ var WindowsPtyStrategy = class {
955
2261
  };
956
2262
  };
957
2263
 
2264
+ // src/services/pty/windows-conpty.strategy.ts
2265
+ function loadNodePty() {
2266
+ try {
2267
+ return require_lib();
2268
+ } catch {
2269
+ return null;
2270
+ }
2271
+ }
2272
+ var WindowsConPtyStrategy = class _WindowsConPtyStrategy {
2273
+ constructor(opts, lib) {
2274
+ this.opts = opts;
2275
+ this.lib = lib;
2276
+ }
2277
+ opts;
2278
+ lib;
2279
+ pty = null;
2280
+ dataSub = null;
2281
+ exitSub = null;
2282
+ rawModeSet = false;
2283
+ /**
2284
+ * Factory that returns a working ConPTY strategy or `null` if
2285
+ * node-pty can't load. The caller (claude.service.ts) decides
2286
+ * whether to fall back to the legacy pipe strategy.
2287
+ */
2288
+ static tryCreate(opts) {
2289
+ const lib = loadNodePty();
2290
+ if (!lib) return null;
2291
+ return new _WindowsConPtyStrategy(opts, lib);
2292
+ }
2293
+ spawn(cmd, cwd, args2 = []) {
2294
+ try {
2295
+ this.pty = this.lib.spawn(cmd, args2, {
2296
+ name: "xterm-256color",
2297
+ cols: 220,
2298
+ rows: 50,
2299
+ cwd,
2300
+ env: {
2301
+ ...process.env,
2302
+ TERM: "xterm-256color",
2303
+ FORCE_COLOR: "1"
2304
+ },
2305
+ useConpty: true,
2306
+ conptyInheritCursor: false
2307
+ });
2308
+ } catch (err) {
2309
+ const msg = err instanceof Error ? err.message : String(err);
2310
+ console.error(
2311
+ `
2312
+ \u2717 Failed to launch Claude Code via ConPTY: ${msg}
2313
+ Make sure claude is installed: npm install -g @anthropic-ai/claude-code
2314
+ `
2315
+ );
2316
+ this.opts.onExit(1);
2317
+ return;
2318
+ }
2319
+ this.dataSub = this.pty.onData((data) => {
2320
+ process.stdout.write(data);
2321
+ this.opts.onData(data);
2322
+ });
2323
+ this.exitSub = this.pty.onExit(({ exitCode }) => {
2324
+ this.dispose();
2325
+ this.opts.onExit(exitCode ?? 0);
2326
+ });
2327
+ if (process.stdin.isTTY) {
2328
+ try {
2329
+ process.stdin.setRawMode(true);
2330
+ this.rawModeSet = true;
2331
+ } catch {
2332
+ }
2333
+ }
2334
+ process.stdin.resume();
2335
+ process.stdin.on("data", this.stdinHandler);
2336
+ }
2337
+ write(data) {
2338
+ if (!this.pty) return;
2339
+ this.pty.write(typeof data === "string" ? data : data.toString("utf8"));
2340
+ }
2341
+ kill() {
2342
+ try {
2343
+ this.pty?.kill();
2344
+ } catch {
2345
+ }
2346
+ this.dispose();
2347
+ }
2348
+ dispose() {
2349
+ this.dataSub?.dispose();
2350
+ this.exitSub?.dispose();
2351
+ this.dataSub = null;
2352
+ this.exitSub = null;
2353
+ process.stdin.removeListener("data", this.stdinHandler);
2354
+ if (this.rawModeSet && process.stdin.isTTY) {
2355
+ try {
2356
+ process.stdin.setRawMode(false);
2357
+ } catch {
2358
+ }
2359
+ this.rawModeSet = false;
2360
+ }
2361
+ this.pty = null;
2362
+ }
2363
+ stdinHandler = (chunk) => {
2364
+ this.pty?.write(chunk.toString("utf8"));
2365
+ };
2366
+ };
2367
+
958
2368
  // src/services/claude.service.ts
959
2369
  var ClaudeService = class {
960
2370
  constructor(opts) {
@@ -964,7 +2374,19 @@ var ClaudeService = class {
964
2374
  }),
965
2375
  onExit: opts.onExit
966
2376
  };
967
- this.strategy = process.platform === "win32" ? new WindowsPtyStrategy(strategyOpts) : new UnixPtyStrategy(strategyOpts);
2377
+ if (process.platform === "win32") {
2378
+ const conpty = WindowsConPtyStrategy.tryCreate(strategyOpts);
2379
+ if (conpty) {
2380
+ this.strategy = conpty;
2381
+ } else {
2382
+ console.error(
2383
+ '\n \u26A0 Windows: node-pty unavailable, falling back to pipe mode.\n Claude Code may exit immediately with "no stdin data" / "--print" errors.\n Install build tools or run codeam-cli inside WSL for the best experience.\n'
2384
+ );
2385
+ this.strategy = new WindowsPtyStrategy(strategyOpts);
2386
+ }
2387
+ } else {
2388
+ this.strategy = new UnixPtyStrategy(strategyOpts);
2389
+ }
968
2390
  }
969
2391
  opts;
970
2392
  strategy;