fluxflow-cli 1.18.0 → 1.18.2

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/dist/fluxflow.js +23 -1339
  2. package/package.json +2 -2
package/dist/fluxflow.js CHANGED
@@ -1,42 +1,13 @@
1
1
  #!/usr/bin/env node
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
- }) : x)(function(x) {
11
- if (typeof require !== "undefined") return require.apply(this, arguments);
12
- throw Error('Dynamic require of "' + x + '" is not supported');
13
- });
14
4
  var __esm = (fn, res) => function __init() {
15
5
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
16
6
  };
17
- var __commonJS = (cb, mod) => function __require2() {
18
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
- };
20
7
  var __export = (target, all) => {
21
8
  for (var name in all)
22
9
  __defProp(target, name, { get: all[name], enumerable: true });
23
10
  };
24
- var __copyProps = (to, from, except, desc) => {
25
- if (from && typeof from === "object" || typeof from === "function") {
26
- for (let key of __getOwnPropNames(from))
27
- if (!__hasOwnProp.call(to, key) && key !== except)
28
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
29
- }
30
- return to;
31
- };
32
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
33
- // If the importer is in node compatibility mode or this is not an ESM
34
- // file that has been converted to a CommonJS file using a Babel-
35
- // compatible transform (i.e. "__esModule" has not been set), then set
36
- // "default" to the CommonJS "module.exports" for node compatibility.
37
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38
- mod
39
- ));
40
11
 
41
12
  // src/components/MultilineInput.jsx
42
13
  import React, { useState, useEffect, useMemo, useCallback, useRef } from "react";
@@ -469,11 +440,15 @@ var init_TerminalBox = __esm({
469
440
  "src/components/TerminalBox.jsx"() {
470
441
  init_text();
471
442
  TerminalBox = React2.memo(({ command, output, completed = false, isFocused = false, columns = 80, isPty = false }) => {
472
- const processOutput = (text) => {
443
+ const processPTY = (text) => {
473
444
  if (!text) return "";
474
- return text.split(/\r\n|\r|\n/).map((line) => line.trimEnd()).join("\n").replace(/^\n+|\n+$/g, "");
445
+ const noTrailingCr = text.replace(/\r+\n/g, "\n");
446
+ return noTrailingCr.split("\n").map((line) => {
447
+ const parts = line.split("\r");
448
+ return parts[parts.length - 1];
449
+ }).join("\n");
475
450
  };
476
- const cleanOutput = processOutput(output);
451
+ const cleanOutput = isPty ? processPTY(output) : (output || "").replace(/\r\n/g, "\n");
477
452
  const displayOutput = isPty ? cleanOutput : cleanOutput ? wrapText(cleanOutput, columns - 6) : "";
478
453
  return /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", borderStyle: isFocused ? "double" : "round", borderColor: completed ? "#334155" : isFocused ? "yellow" : "cyan", paddingX: 2, paddingY: completed ? 0 : 1, width: "100%" }, /* @__PURE__ */ React2.createElement(Box2, { marginBottom: 1, justifyContent: "space-between", width: "100%" }, /* @__PURE__ */ React2.createElement(Box2, { flexShrink: 1, paddingRight: 2 }, /* @__PURE__ */ React2.createElement(Text2, null, /* @__PURE__ */ React2.createElement(Text2, { color: completed ? "gray" : isFocused ? "yellow" : "cyan", bold: true }, completed ? "\u{1F3C1} FINISHED:" : "\u26A1 EXECUTING:", " "), /* @__PURE__ */ React2.createElement(Text2, { color: completed ? "gray" : "white" }, command))), isPty && /* @__PURE__ */ React2.createElement(Box2, { flexShrink: 0, paddingX: 1 }, /* @__PURE__ */ React2.createElement(Text2, { color: completed ? "gray" : "magenta", bold: true }, "ADVANCE"))), displayOutput ? /* @__PURE__ */ React2.createElement(Box2, { marginTop: completed ? 0 : 1, backgroundColor: isPty ? void 0 : "#0a0a0a", paddingX: 1 }, /* @__PURE__ */ React2.createElement(Text2, { color: completed ? "gray" : void 0 }, displayOutput)) : !completed && /* @__PURE__ */ React2.createElement(Box2, { marginTop: 1, backgroundColor: isPty ? void 0 : "#0a0a0a", paddingX: 1 }, /* @__PURE__ */ React2.createElement(Text2, { color: "gray", italic: true }, "Waiting for output...")), /* @__PURE__ */ React2.createElement(Box2, { justifyContent: "space-between", marginTop: 1 }, !completed ? /* @__PURE__ */ React2.createElement(Text2, { color: "gray", dimColor: true, italic: true }, "Double-press ESC to terminate if hanging.") : /* @__PURE__ */ React2.createElement(Box2, null), /* @__PURE__ */ React2.createElement(Text2, { color: completed ? "#475569" : isFocused ? "yellow" : "cyan", bold: true }, completed ? "\u25CF ARCHIVED" : isFocused ? "\u25B6 TERMINAL FOCUSED" : "\u25CF LIVE (Press TAB to focus)")));
479
454
  });
@@ -3444,1309 +3419,6 @@ ${errors.map((e) => ` \u2022 ${e.error}`).join("\n")}`;
3444
3419
  }
3445
3420
  });
3446
3421
 
3447
- // node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/utils.js
3448
- var require_utils = __commonJS({
3449
- "node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/utils.js"(exports) {
3450
- "use strict";
3451
- Object.defineProperty(exports, "__esModule", { value: true });
3452
- exports.loadNativeModule = exports.assign = void 0;
3453
- function assign(target) {
3454
- var sources = [];
3455
- for (var _i = 1; _i < arguments.length; _i++) {
3456
- sources[_i - 1] = arguments[_i];
3457
- }
3458
- sources.forEach(function(source) {
3459
- return Object.keys(source).forEach(function(key) {
3460
- return target[key] = source[key];
3461
- });
3462
- });
3463
- return target;
3464
- }
3465
- exports.assign = assign;
3466
- function loadNativeModule(name) {
3467
- var dirs = ["build/Release", "build/Debug", "prebuilds/" + process.platform + "-" + process.arch];
3468
- var relative = ["..", "."];
3469
- var lastError;
3470
- for (var _i = 0, dirs_1 = dirs; _i < dirs_1.length; _i++) {
3471
- var d = dirs_1[_i];
3472
- for (var _a = 0, relative_1 = relative; _a < relative_1.length; _a++) {
3473
- var r = relative_1[_a];
3474
- var dir = r + "/" + d + "/";
3475
- try {
3476
- return { dir, module: __require(dir + "/" + name + ".node") };
3477
- } catch (e) {
3478
- lastError = e;
3479
- }
3480
- }
3481
- }
3482
- throw new Error("Failed to load native module: " + name + ".node, checked: " + dirs.join(", ") + ": " + lastError);
3483
- }
3484
- exports.loadNativeModule = loadNativeModule;
3485
- }
3486
- });
3487
-
3488
- // node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/eventEmitter2.js
3489
- var require_eventEmitter2 = __commonJS({
3490
- "node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/eventEmitter2.js"(exports) {
3491
- "use strict";
3492
- Object.defineProperty(exports, "__esModule", { value: true });
3493
- exports.EventEmitter2 = void 0;
3494
- var EventEmitter2 = (
3495
- /** @class */
3496
- (function() {
3497
- function EventEmitter22() {
3498
- this._listeners = [];
3499
- }
3500
- Object.defineProperty(EventEmitter22.prototype, "event", {
3501
- get: function() {
3502
- var _this = this;
3503
- if (!this._event) {
3504
- this._event = function(listener) {
3505
- _this._listeners.push(listener);
3506
- var disposable = {
3507
- dispose: function() {
3508
- for (var i = 0; i < _this._listeners.length; i++) {
3509
- if (_this._listeners[i] === listener) {
3510
- _this._listeners.splice(i, 1);
3511
- return;
3512
- }
3513
- }
3514
- }
3515
- };
3516
- return disposable;
3517
- };
3518
- }
3519
- return this._event;
3520
- },
3521
- enumerable: false,
3522
- configurable: true
3523
- });
3524
- EventEmitter22.prototype.fire = function(data) {
3525
- var queue = [];
3526
- for (var i = 0; i < this._listeners.length; i++) {
3527
- queue.push(this._listeners[i]);
3528
- }
3529
- for (var i = 0; i < queue.length; i++) {
3530
- queue[i].call(void 0, data);
3531
- }
3532
- };
3533
- return EventEmitter22;
3534
- })()
3535
- );
3536
- exports.EventEmitter2 = EventEmitter2;
3537
- }
3538
- });
3539
-
3540
- // node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/terminal.js
3541
- var require_terminal = __commonJS({
3542
- "node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/terminal.js"(exports) {
3543
- "use strict";
3544
- Object.defineProperty(exports, "__esModule", { value: true });
3545
- exports.Terminal = exports.DEFAULT_ROWS = exports.DEFAULT_COLS = void 0;
3546
- var events_1 = __require("events");
3547
- var eventEmitter2_1 = require_eventEmitter2();
3548
- exports.DEFAULT_COLS = 80;
3549
- exports.DEFAULT_ROWS = 24;
3550
- var FLOW_CONTROL_PAUSE = "";
3551
- var FLOW_CONTROL_RESUME = "";
3552
- var Terminal = (
3553
- /** @class */
3554
- (function() {
3555
- function Terminal2(opt) {
3556
- this._pid = 0;
3557
- this._fd = 0;
3558
- this._cols = 0;
3559
- this._rows = 0;
3560
- this._readable = false;
3561
- this._writable = false;
3562
- this._onData = new eventEmitter2_1.EventEmitter2();
3563
- this._onExit = new eventEmitter2_1.EventEmitter2();
3564
- this._internalee = new events_1.EventEmitter();
3565
- this.handleFlowControl = !!(opt === null || opt === void 0 ? void 0 : opt.handleFlowControl);
3566
- this._flowControlPause = (opt === null || opt === void 0 ? void 0 : opt.flowControlPause) || FLOW_CONTROL_PAUSE;
3567
- this._flowControlResume = (opt === null || opt === void 0 ? void 0 : opt.flowControlResume) || FLOW_CONTROL_RESUME;
3568
- if (!opt) {
3569
- return;
3570
- }
3571
- this._checkType("name", opt.name ? opt.name : void 0, "string");
3572
- this._checkType("cols", opt.cols ? opt.cols : void 0, "number");
3573
- this._checkType("rows", opt.rows ? opt.rows : void 0, "number");
3574
- this._checkType("cwd", opt.cwd ? opt.cwd : void 0, "string");
3575
- this._checkType("env", opt.env ? opt.env : void 0, "object");
3576
- this._checkType("uid", opt.uid ? opt.uid : void 0, "number");
3577
- this._checkType("gid", opt.gid ? opt.gid : void 0, "number");
3578
- this._checkType("encoding", opt.encoding ? opt.encoding : void 0, "string");
3579
- }
3580
- Object.defineProperty(Terminal2.prototype, "onData", {
3581
- get: function() {
3582
- return this._onData.event;
3583
- },
3584
- enumerable: false,
3585
- configurable: true
3586
- });
3587
- Object.defineProperty(Terminal2.prototype, "onExit", {
3588
- get: function() {
3589
- return this._onExit.event;
3590
- },
3591
- enumerable: false,
3592
- configurable: true
3593
- });
3594
- Object.defineProperty(Terminal2.prototype, "pid", {
3595
- get: function() {
3596
- return this._pid;
3597
- },
3598
- enumerable: false,
3599
- configurable: true
3600
- });
3601
- Object.defineProperty(Terminal2.prototype, "cols", {
3602
- get: function() {
3603
- return this._cols;
3604
- },
3605
- enumerable: false,
3606
- configurable: true
3607
- });
3608
- Object.defineProperty(Terminal2.prototype, "rows", {
3609
- get: function() {
3610
- return this._rows;
3611
- },
3612
- enumerable: false,
3613
- configurable: true
3614
- });
3615
- Terminal2.prototype.write = function(data) {
3616
- if (this.handleFlowControl) {
3617
- if (data === this._flowControlPause) {
3618
- this.pause();
3619
- return;
3620
- }
3621
- if (data === this._flowControlResume) {
3622
- this.resume();
3623
- return;
3624
- }
3625
- }
3626
- this._write(data);
3627
- };
3628
- Terminal2.prototype._forwardEvents = function() {
3629
- var _this = this;
3630
- this.on("data", function(e) {
3631
- return _this._onData.fire(e);
3632
- });
3633
- this.on("exit", function(exitCode, signal) {
3634
- return _this._onExit.fire({ exitCode, signal });
3635
- });
3636
- };
3637
- Terminal2.prototype._checkType = function(name, value, type, allowArray) {
3638
- if (allowArray === void 0) {
3639
- allowArray = false;
3640
- }
3641
- if (value === void 0) {
3642
- return;
3643
- }
3644
- if (allowArray) {
3645
- if (Array.isArray(value)) {
3646
- value.forEach(function(v, i) {
3647
- if (typeof v !== type) {
3648
- throw new Error(name + "[" + i + "] must be a " + type + " (not a " + typeof v[i] + ")");
3649
- }
3650
- });
3651
- return;
3652
- }
3653
- }
3654
- if (typeof value !== type) {
3655
- throw new Error(name + " must be a " + type + " (not a " + typeof value + ")");
3656
- }
3657
- };
3658
- Terminal2.prototype.end = function(data) {
3659
- this._socket.end(data);
3660
- };
3661
- Terminal2.prototype.pipe = function(dest, options) {
3662
- return this._socket.pipe(dest, options);
3663
- };
3664
- Terminal2.prototype.pause = function() {
3665
- return this._socket.pause();
3666
- };
3667
- Terminal2.prototype.resume = function() {
3668
- return this._socket.resume();
3669
- };
3670
- Terminal2.prototype.setEncoding = function(encoding) {
3671
- if (this._socket._decoder) {
3672
- delete this._socket._decoder;
3673
- }
3674
- if (encoding) {
3675
- this._socket.setEncoding(encoding);
3676
- }
3677
- };
3678
- Terminal2.prototype.addListener = function(eventName, listener) {
3679
- this.on(eventName, listener);
3680
- };
3681
- Terminal2.prototype.on = function(eventName, listener) {
3682
- if (eventName === "close") {
3683
- this._internalee.on("close", listener);
3684
- return;
3685
- }
3686
- this._socket.on(eventName, listener);
3687
- };
3688
- Terminal2.prototype.emit = function(eventName) {
3689
- var args = [];
3690
- for (var _i = 1; _i < arguments.length; _i++) {
3691
- args[_i - 1] = arguments[_i];
3692
- }
3693
- if (eventName === "close") {
3694
- return this._internalee.emit.apply(this._internalee, arguments);
3695
- }
3696
- return this._socket.emit.apply(this._socket, arguments);
3697
- };
3698
- Terminal2.prototype.listeners = function(eventName) {
3699
- return this._socket.listeners(eventName);
3700
- };
3701
- Terminal2.prototype.removeListener = function(eventName, listener) {
3702
- this._socket.removeListener(eventName, listener);
3703
- };
3704
- Terminal2.prototype.removeAllListeners = function(eventName) {
3705
- this._socket.removeAllListeners(eventName);
3706
- };
3707
- Terminal2.prototype.once = function(eventName, listener) {
3708
- this._socket.once(eventName, listener);
3709
- };
3710
- Terminal2.prototype._close = function() {
3711
- this._socket.readable = false;
3712
- this.write = function() {
3713
- };
3714
- this.end = function() {
3715
- };
3716
- this._writable = false;
3717
- this._readable = false;
3718
- };
3719
- Terminal2.prototype._parseEnv = function(env) {
3720
- var keys = Object.keys(env || {});
3721
- var pairs = [];
3722
- for (var i = 0; i < keys.length; i++) {
3723
- if (keys[i] === void 0) {
3724
- continue;
3725
- }
3726
- pairs.push(keys[i] + "=" + env[keys[i]]);
3727
- }
3728
- return pairs;
3729
- };
3730
- return Terminal2;
3731
- })()
3732
- );
3733
- exports.Terminal = Terminal;
3734
- }
3735
- });
3736
-
3737
- // node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/shared/conout.js
3738
- var require_conout = __commonJS({
3739
- "node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/shared/conout.js"(exports) {
3740
- "use strict";
3741
- Object.defineProperty(exports, "__esModule", { value: true });
3742
- exports.getWorkerPipeName = void 0;
3743
- function getWorkerPipeName(conoutPipeName) {
3744
- return conoutPipeName + "-worker";
3745
- }
3746
- exports.getWorkerPipeName = getWorkerPipeName;
3747
- }
3748
- });
3749
-
3750
- // node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsConoutConnection.js
3751
- var require_windowsConoutConnection = __commonJS({
3752
- "node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsConoutConnection.js"(exports) {
3753
- "use strict";
3754
- var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
3755
- function adopt(value) {
3756
- return value instanceof P ? value : new P(function(resolve) {
3757
- resolve(value);
3758
- });
3759
- }
3760
- return new (P || (P = Promise))(function(resolve, reject) {
3761
- function fulfilled(value) {
3762
- try {
3763
- step(generator.next(value));
3764
- } catch (e) {
3765
- reject(e);
3766
- }
3767
- }
3768
- function rejected(value) {
3769
- try {
3770
- step(generator["throw"](value));
3771
- } catch (e) {
3772
- reject(e);
3773
- }
3774
- }
3775
- function step(result) {
3776
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
3777
- }
3778
- step((generator = generator.apply(thisArg, _arguments || [])).next());
3779
- });
3780
- };
3781
- var __generator = exports && exports.__generator || function(thisArg, body) {
3782
- var _ = { label: 0, sent: function() {
3783
- if (t[0] & 1) throw t[1];
3784
- return t[1];
3785
- }, trys: [], ops: [] }, f, y, t, g;
3786
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
3787
- return this;
3788
- }), g;
3789
- function verb(n) {
3790
- return function(v) {
3791
- return step([n, v]);
3792
- };
3793
- }
3794
- function step(op) {
3795
- if (f) throw new TypeError("Generator is already executing.");
3796
- while (_) try {
3797
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
3798
- if (y = 0, t) op = [op[0] & 2, t.value];
3799
- switch (op[0]) {
3800
- case 0:
3801
- case 1:
3802
- t = op;
3803
- break;
3804
- case 4:
3805
- _.label++;
3806
- return { value: op[1], done: false };
3807
- case 5:
3808
- _.label++;
3809
- y = op[1];
3810
- op = [0];
3811
- continue;
3812
- case 7:
3813
- op = _.ops.pop();
3814
- _.trys.pop();
3815
- continue;
3816
- default:
3817
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
3818
- _ = 0;
3819
- continue;
3820
- }
3821
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
3822
- _.label = op[1];
3823
- break;
3824
- }
3825
- if (op[0] === 6 && _.label < t[1]) {
3826
- _.label = t[1];
3827
- t = op;
3828
- break;
3829
- }
3830
- if (t && _.label < t[2]) {
3831
- _.label = t[2];
3832
- _.ops.push(op);
3833
- break;
3834
- }
3835
- if (t[2]) _.ops.pop();
3836
- _.trys.pop();
3837
- continue;
3838
- }
3839
- op = body.call(thisArg, _);
3840
- } catch (e) {
3841
- op = [6, e];
3842
- y = 0;
3843
- } finally {
3844
- f = t = 0;
3845
- }
3846
- if (op[0] & 5) throw op[1];
3847
- return { value: op[0] ? op[1] : void 0, done: true };
3848
- }
3849
- };
3850
- Object.defineProperty(exports, "__esModule", { value: true });
3851
- exports.ConoutConnection = void 0;
3852
- var worker_threads_1 = __require("worker_threads");
3853
- var conout_1 = require_conout();
3854
- var path_1 = __require("path");
3855
- var eventEmitter2_1 = require_eventEmitter2();
3856
- var FLUSH_DATA_INTERVAL = 1e3;
3857
- var ConoutConnection = (
3858
- /** @class */
3859
- (function() {
3860
- function ConoutConnection2(_conoutPipeName, _useConptyDll) {
3861
- var _this = this;
3862
- this._conoutPipeName = _conoutPipeName;
3863
- this._useConptyDll = _useConptyDll;
3864
- this._isDisposed = false;
3865
- this._onReady = new eventEmitter2_1.EventEmitter2();
3866
- var workerData = {
3867
- conoutPipeName: _conoutPipeName
3868
- };
3869
- var scriptPath = __dirname.replace("node_modules.asar", "node_modules.asar.unpacked");
3870
- this._worker = new worker_threads_1.Worker(path_1.join(scriptPath, "worker/conoutSocketWorker.js"), { workerData });
3871
- this._worker.on("message", function(message) {
3872
- switch (message) {
3873
- case 1:
3874
- _this._onReady.fire();
3875
- return;
3876
- default:
3877
- console.warn("Unexpected ConoutWorkerMessage", message);
3878
- }
3879
- });
3880
- }
3881
- Object.defineProperty(ConoutConnection2.prototype, "onReady", {
3882
- get: function() {
3883
- return this._onReady.event;
3884
- },
3885
- enumerable: false,
3886
- configurable: true
3887
- });
3888
- ConoutConnection2.prototype.dispose = function() {
3889
- if (!this._useConptyDll && this._isDisposed) {
3890
- return;
3891
- }
3892
- this._isDisposed = true;
3893
- this._drainDataAndClose();
3894
- };
3895
- ConoutConnection2.prototype.connectSocket = function(socket) {
3896
- socket.connect(conout_1.getWorkerPipeName(this._conoutPipeName));
3897
- };
3898
- ConoutConnection2.prototype._drainDataAndClose = function() {
3899
- var _this = this;
3900
- if (this._drainTimeout) {
3901
- clearTimeout(this._drainTimeout);
3902
- }
3903
- this._drainTimeout = setTimeout(function() {
3904
- return _this._destroySocket();
3905
- }, FLUSH_DATA_INTERVAL);
3906
- };
3907
- ConoutConnection2.prototype._destroySocket = function() {
3908
- return __awaiter(this, void 0, void 0, function() {
3909
- return __generator(this, function(_a) {
3910
- switch (_a.label) {
3911
- case 0:
3912
- return [4, this._worker.terminate()];
3913
- case 1:
3914
- _a.sent();
3915
- return [
3916
- 2
3917
- /*return*/
3918
- ];
3919
- }
3920
- });
3921
- });
3922
- };
3923
- return ConoutConnection2;
3924
- })()
3925
- );
3926
- exports.ConoutConnection = ConoutConnection;
3927
- }
3928
- });
3929
-
3930
- // node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsPtyAgent.js
3931
- var require_windowsPtyAgent = __commonJS({
3932
- "node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsPtyAgent.js"(exports) {
3933
- "use strict";
3934
- Object.defineProperty(exports, "__esModule", { value: true });
3935
- exports.argsToCommandLine = exports.WindowsPtyAgent = void 0;
3936
- var fs19 = __require("fs");
3937
- var os5 = __require("os");
3938
- var path17 = __require("path");
3939
- var child_process_1 = __require("child_process");
3940
- var net_1 = __require("net");
3941
- var windowsConoutConnection_1 = require_windowsConoutConnection();
3942
- var utils_1 = require_utils();
3943
- var conptyNative;
3944
- var winptyNative;
3945
- var FLUSH_DATA_INTERVAL = 1e3;
3946
- var WindowsPtyAgent = (
3947
- /** @class */
3948
- (function() {
3949
- function WindowsPtyAgent2(file, args, env, cwd, cols, rows, debug, _useConpty, _useConptyDll, conptyInheritCursor) {
3950
- var _this = this;
3951
- if (_useConptyDll === void 0) {
3952
- _useConptyDll = false;
3953
- }
3954
- if (conptyInheritCursor === void 0) {
3955
- conptyInheritCursor = false;
3956
- }
3957
- this._useConpty = _useConpty;
3958
- this._useConptyDll = _useConptyDll;
3959
- this._pid = 0;
3960
- this._innerPid = 0;
3961
- if (this._useConpty === void 0 || this._useConpty === true) {
3962
- this._useConpty = this._getWindowsBuildNumber() >= 18309;
3963
- }
3964
- if (this._useConpty) {
3965
- if (!conptyNative) {
3966
- conptyNative = utils_1.loadNativeModule("conpty").module;
3967
- }
3968
- } else {
3969
- if (!winptyNative) {
3970
- winptyNative = utils_1.loadNativeModule("pty").module;
3971
- }
3972
- }
3973
- this._ptyNative = this._useConpty ? conptyNative : winptyNative;
3974
- cwd = path17.resolve(cwd);
3975
- var commandLine = argsToCommandLine(file, args);
3976
- var term;
3977
- if (this._useConpty) {
3978
- term = this._ptyNative.startProcess(file, cols, rows, debug, this._generatePipeName(), conptyInheritCursor, this._useConptyDll);
3979
- } else {
3980
- term = this._ptyNative.startProcess(file, commandLine, env, cwd, cols, rows, debug);
3981
- this._pid = term.pid;
3982
- this._innerPid = term.innerPid;
3983
- }
3984
- this._fd = term.fd;
3985
- this._pty = term.pty;
3986
- this._outSocket = new net_1.Socket();
3987
- this._outSocket.setEncoding("utf8");
3988
- this._conoutSocketWorker = new windowsConoutConnection_1.ConoutConnection(term.conout, this._useConptyDll);
3989
- this._conoutSocketWorker.onReady(function() {
3990
- _this._conoutSocketWorker.connectSocket(_this._outSocket);
3991
- });
3992
- this._outSocket.on("connect", function() {
3993
- _this._outSocket.emit("ready_datapipe");
3994
- });
3995
- var inSocketFD = fs19.openSync(term.conin, "w");
3996
- this._inSocket = new net_1.Socket({
3997
- fd: inSocketFD,
3998
- readable: false,
3999
- writable: true
4000
- });
4001
- this._inSocket.setEncoding("utf8");
4002
- if (this._useConpty) {
4003
- var connect = this._ptyNative.connect(this._pty, commandLine, cwd, env, this._useConptyDll, function(c) {
4004
- return _this._$onProcessExit(c);
4005
- });
4006
- this._innerPid = connect.pid;
4007
- }
4008
- }
4009
- Object.defineProperty(WindowsPtyAgent2.prototype, "inSocket", {
4010
- get: function() {
4011
- return this._inSocket;
4012
- },
4013
- enumerable: false,
4014
- configurable: true
4015
- });
4016
- Object.defineProperty(WindowsPtyAgent2.prototype, "outSocket", {
4017
- get: function() {
4018
- return this._outSocket;
4019
- },
4020
- enumerable: false,
4021
- configurable: true
4022
- });
4023
- Object.defineProperty(WindowsPtyAgent2.prototype, "fd", {
4024
- get: function() {
4025
- return this._fd;
4026
- },
4027
- enumerable: false,
4028
- configurable: true
4029
- });
4030
- Object.defineProperty(WindowsPtyAgent2.prototype, "innerPid", {
4031
- get: function() {
4032
- return this._innerPid;
4033
- },
4034
- enumerable: false,
4035
- configurable: true
4036
- });
4037
- Object.defineProperty(WindowsPtyAgent2.prototype, "pty", {
4038
- get: function() {
4039
- return this._pty;
4040
- },
4041
- enumerable: false,
4042
- configurable: true
4043
- });
4044
- WindowsPtyAgent2.prototype.resize = function(cols, rows) {
4045
- if (this._useConpty) {
4046
- if (this._exitCode !== void 0) {
4047
- throw new Error("Cannot resize a pty that has already exited");
4048
- }
4049
- this._ptyNative.resize(this._pty, cols, rows, this._useConptyDll);
4050
- return;
4051
- }
4052
- this._ptyNative.resize(this._pid, cols, rows);
4053
- };
4054
- WindowsPtyAgent2.prototype.clear = function() {
4055
- if (this._useConpty) {
4056
- this._ptyNative.clear(this._pty, this._useConptyDll);
4057
- }
4058
- };
4059
- WindowsPtyAgent2.prototype.kill = function() {
4060
- var _this = this;
4061
- if (this._useConpty) {
4062
- if (!this._useConptyDll) {
4063
- this._inSocket.readable = false;
4064
- this._outSocket.readable = false;
4065
- this._getConsoleProcessList().then(function(consoleProcessList) {
4066
- consoleProcessList.forEach(function(pid) {
4067
- try {
4068
- process.kill(pid);
4069
- } catch (e) {
4070
- }
4071
- });
4072
- });
4073
- this._ptyNative.kill(this._pty, this._useConptyDll);
4074
- this._conoutSocketWorker.dispose();
4075
- } else {
4076
- this._inSocket.destroy();
4077
- this._ptyNative.kill(this._pty, this._useConptyDll);
4078
- this._outSocket.on("data", function() {
4079
- _this._conoutSocketWorker.dispose();
4080
- });
4081
- }
4082
- } else {
4083
- var processList = this._ptyNative.getProcessList(this._pid);
4084
- this._ptyNative.kill(this._pid, this._innerPid);
4085
- processList.forEach(function(pid) {
4086
- try {
4087
- process.kill(pid);
4088
- } catch (e) {
4089
- }
4090
- });
4091
- }
4092
- };
4093
- WindowsPtyAgent2.prototype._getConsoleProcessList = function() {
4094
- var _this = this;
4095
- return new Promise(function(resolve) {
4096
- var agent = child_process_1.fork(path17.join(__dirname, "conpty_console_list_agent"), [_this._innerPid.toString()]);
4097
- agent.on("message", function(message) {
4098
- clearTimeout(timeout);
4099
- resolve(message.consoleProcessList);
4100
- });
4101
- var timeout = setTimeout(function() {
4102
- agent.kill();
4103
- resolve([_this._innerPid]);
4104
- }, 5e3);
4105
- });
4106
- };
4107
- Object.defineProperty(WindowsPtyAgent2.prototype, "exitCode", {
4108
- get: function() {
4109
- if (this._useConpty) {
4110
- return this._exitCode;
4111
- }
4112
- var winptyExitCode = this._ptyNative.getExitCode(this._innerPid);
4113
- return winptyExitCode === -1 ? void 0 : winptyExitCode;
4114
- },
4115
- enumerable: false,
4116
- configurable: true
4117
- });
4118
- WindowsPtyAgent2.prototype._getWindowsBuildNumber = function() {
4119
- var osVersion = /(\d+)\.(\d+)\.(\d+)/g.exec(os5.release());
4120
- var buildNumber = 0;
4121
- if (osVersion && osVersion.length === 4) {
4122
- buildNumber = parseInt(osVersion[3]);
4123
- }
4124
- return buildNumber;
4125
- };
4126
- WindowsPtyAgent2.prototype._generatePipeName = function() {
4127
- return "conpty-" + Math.random() * 1e7;
4128
- };
4129
- WindowsPtyAgent2.prototype._$onProcessExit = function(exitCode) {
4130
- var _this = this;
4131
- this._exitCode = exitCode;
4132
- if (!this._useConptyDll) {
4133
- this._flushDataAndCleanUp();
4134
- this._outSocket.on("data", function() {
4135
- return _this._flushDataAndCleanUp();
4136
- });
4137
- }
4138
- };
4139
- WindowsPtyAgent2.prototype._flushDataAndCleanUp = function() {
4140
- var _this = this;
4141
- if (this._useConptyDll) {
4142
- return;
4143
- }
4144
- if (this._closeTimeout) {
4145
- clearTimeout(this._closeTimeout);
4146
- }
4147
- this._closeTimeout = setTimeout(function() {
4148
- return _this._cleanUpProcess();
4149
- }, FLUSH_DATA_INTERVAL);
4150
- };
4151
- WindowsPtyAgent2.prototype._cleanUpProcess = function() {
4152
- if (this._useConptyDll) {
4153
- return;
4154
- }
4155
- this._inSocket.readable = false;
4156
- this._outSocket.readable = false;
4157
- this._outSocket.destroy();
4158
- };
4159
- return WindowsPtyAgent2;
4160
- })()
4161
- );
4162
- exports.WindowsPtyAgent = WindowsPtyAgent;
4163
- function argsToCommandLine(file, args) {
4164
- if (isCommandLine(args)) {
4165
- if (args.length === 0) {
4166
- return file;
4167
- }
4168
- return argsToCommandLine(file, []) + " " + args;
4169
- }
4170
- var argv = [file];
4171
- Array.prototype.push.apply(argv, args);
4172
- var result = "";
4173
- for (var argIndex = 0; argIndex < argv.length; argIndex++) {
4174
- if (argIndex > 0) {
4175
- result += " ";
4176
- }
4177
- var arg = argv[argIndex];
4178
- var hasLopsidedEnclosingQuote = xOr(arg[0] !== '"', arg[arg.length - 1] !== '"');
4179
- var hasNoEnclosingQuotes = arg[0] !== '"' && arg[arg.length - 1] !== '"';
4180
- var quote = arg === "" || (arg.indexOf(" ") !== -1 || arg.indexOf(" ") !== -1) && (arg.length > 1 && (hasLopsidedEnclosingQuote || hasNoEnclosingQuotes));
4181
- if (quote) {
4182
- result += '"';
4183
- }
4184
- var bsCount = 0;
4185
- for (var i = 0; i < arg.length; i++) {
4186
- var p = arg[i];
4187
- if (p === "\\") {
4188
- bsCount++;
4189
- } else if (p === '"') {
4190
- result += repeatText("\\", bsCount * 2 + 1);
4191
- result += '"';
4192
- bsCount = 0;
4193
- } else {
4194
- result += repeatText("\\", bsCount);
4195
- bsCount = 0;
4196
- result += p;
4197
- }
4198
- }
4199
- if (quote) {
4200
- result += repeatText("\\", bsCount * 2);
4201
- result += '"';
4202
- } else {
4203
- result += repeatText("\\", bsCount);
4204
- }
4205
- }
4206
- return result;
4207
- }
4208
- exports.argsToCommandLine = argsToCommandLine;
4209
- function isCommandLine(args) {
4210
- return typeof args === "string";
4211
- }
4212
- function repeatText(text, count) {
4213
- var result = "";
4214
- for (var i = 0; i < count; i++) {
4215
- result += text;
4216
- }
4217
- return result;
4218
- }
4219
- function xOr(arg1, arg2) {
4220
- return arg1 && !arg2 || !arg1 && arg2;
4221
- }
4222
- }
4223
- });
4224
-
4225
- // node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsTerminal.js
4226
- var require_windowsTerminal = __commonJS({
4227
- "node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsTerminal.js"(exports) {
4228
- "use strict";
4229
- var __extends = exports && exports.__extends || /* @__PURE__ */ (function() {
4230
- var extendStatics = function(d, b) {
4231
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
4232
- d2.__proto__ = b2;
4233
- } || function(d2, b2) {
4234
- for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
4235
- };
4236
- return extendStatics(d, b);
4237
- };
4238
- return function(d, b) {
4239
- extendStatics(d, b);
4240
- function __() {
4241
- this.constructor = d;
4242
- }
4243
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4244
- };
4245
- })();
4246
- Object.defineProperty(exports, "__esModule", { value: true });
4247
- exports.WindowsTerminal = void 0;
4248
- var terminal_1 = require_terminal();
4249
- var windowsPtyAgent_1 = require_windowsPtyAgent();
4250
- var utils_1 = require_utils();
4251
- var DEFAULT_FILE = "cmd.exe";
4252
- var DEFAULT_NAME = "Windows Shell";
4253
- var WindowsTerminal = (
4254
- /** @class */
4255
- (function(_super) {
4256
- __extends(WindowsTerminal2, _super);
4257
- function WindowsTerminal2(file, args, opt) {
4258
- var _this = _super.call(this, opt) || this;
4259
- _this._checkType("args", args, "string", true);
4260
- args = args || [];
4261
- file = file || DEFAULT_FILE;
4262
- opt = opt || {};
4263
- opt.env = opt.env || process.env;
4264
- if (opt.encoding) {
4265
- console.warn("Setting encoding on Windows is not supported");
4266
- }
4267
- var env = utils_1.assign({}, opt.env);
4268
- _this._cols = opt.cols || terminal_1.DEFAULT_COLS;
4269
- _this._rows = opt.rows || terminal_1.DEFAULT_ROWS;
4270
- var cwd = opt.cwd || process.cwd();
4271
- var name = opt.name || env.TERM || DEFAULT_NAME;
4272
- var parsedEnv = _this._parseEnv(env);
4273
- _this._isReady = false;
4274
- _this._deferreds = [];
4275
- _this._agent = new windowsPtyAgent_1.WindowsPtyAgent(file, args, parsedEnv, cwd, _this._cols, _this._rows, false, opt.useConpty, opt.useConptyDll, opt.conptyInheritCursor);
4276
- _this._socket = _this._agent.outSocket;
4277
- _this._pid = _this._agent.innerPid;
4278
- _this._fd = _this._agent.fd;
4279
- _this._pty = _this._agent.pty;
4280
- _this._socket.on("ready_datapipe", function() {
4281
- _this._socket.once("data", function() {
4282
- if (!_this._isReady) {
4283
- _this._isReady = true;
4284
- _this._deferreds.forEach(function(fn) {
4285
- fn.run();
4286
- });
4287
- _this._deferreds = [];
4288
- }
4289
- });
4290
- _this._socket.on("error", function(err) {
4291
- _this._close();
4292
- if (err.code) {
4293
- if (~err.code.indexOf("errno 5") || ~err.code.indexOf("EIO"))
4294
- return;
4295
- }
4296
- if (_this.listeners("error").length < 2) {
4297
- throw err;
4298
- }
4299
- });
4300
- _this._socket.on("close", function() {
4301
- _this.emit("exit", _this._agent.exitCode);
4302
- _this._close();
4303
- });
4304
- });
4305
- _this._file = file;
4306
- _this._name = name;
4307
- _this._readable = true;
4308
- _this._writable = true;
4309
- _this._forwardEvents();
4310
- return _this;
4311
- }
4312
- WindowsTerminal2.prototype._write = function(data) {
4313
- this._defer(this._doWrite, data);
4314
- };
4315
- WindowsTerminal2.prototype._doWrite = function(data) {
4316
- this._agent.inSocket.write(data);
4317
- };
4318
- WindowsTerminal2.open = function(options) {
4319
- throw new Error("open() not supported on windows, use Fork() instead.");
4320
- };
4321
- WindowsTerminal2.prototype.resize = function(cols, rows) {
4322
- var _this = this;
4323
- if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) {
4324
- throw new Error("resizing must be done using positive cols and rows");
4325
- }
4326
- this._deferNoArgs(function() {
4327
- _this._agent.resize(cols, rows);
4328
- _this._cols = cols;
4329
- _this._rows = rows;
4330
- });
4331
- };
4332
- WindowsTerminal2.prototype.clear = function() {
4333
- var _this = this;
4334
- this._deferNoArgs(function() {
4335
- _this._agent.clear();
4336
- });
4337
- };
4338
- WindowsTerminal2.prototype.destroy = function() {
4339
- var _this = this;
4340
- this._deferNoArgs(function() {
4341
- _this.kill();
4342
- });
4343
- };
4344
- WindowsTerminal2.prototype.kill = function(signal) {
4345
- var _this = this;
4346
- this._deferNoArgs(function() {
4347
- if (signal) {
4348
- throw new Error("Signals not supported on windows.");
4349
- }
4350
- _this._close();
4351
- _this._agent.kill();
4352
- });
4353
- };
4354
- WindowsTerminal2.prototype._deferNoArgs = function(deferredFn) {
4355
- var _this = this;
4356
- if (this._isReady) {
4357
- deferredFn.call(this);
4358
- return;
4359
- }
4360
- this._deferreds.push({
4361
- run: function() {
4362
- return deferredFn.call(_this);
4363
- }
4364
- });
4365
- };
4366
- WindowsTerminal2.prototype._defer = function(deferredFn, arg) {
4367
- var _this = this;
4368
- if (this._isReady) {
4369
- deferredFn.call(this, arg);
4370
- return;
4371
- }
4372
- this._deferreds.push({
4373
- run: function() {
4374
- return deferredFn.call(_this, arg);
4375
- }
4376
- });
4377
- };
4378
- Object.defineProperty(WindowsTerminal2.prototype, "process", {
4379
- get: function() {
4380
- return this._name;
4381
- },
4382
- enumerable: false,
4383
- configurable: true
4384
- });
4385
- Object.defineProperty(WindowsTerminal2.prototype, "master", {
4386
- get: function() {
4387
- throw new Error("master is not supported on Windows");
4388
- },
4389
- enumerable: false,
4390
- configurable: true
4391
- });
4392
- Object.defineProperty(WindowsTerminal2.prototype, "slave", {
4393
- get: function() {
4394
- throw new Error("slave is not supported on Windows");
4395
- },
4396
- enumerable: false,
4397
- configurable: true
4398
- });
4399
- return WindowsTerminal2;
4400
- })(terminal_1.Terminal)
4401
- );
4402
- exports.WindowsTerminal = WindowsTerminal;
4403
- }
4404
- });
4405
-
4406
- // node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/unixTerminal.js
4407
- var require_unixTerminal = __commonJS({
4408
- "node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/unixTerminal.js"(exports) {
4409
- "use strict";
4410
- var __extends = exports && exports.__extends || /* @__PURE__ */ (function() {
4411
- var extendStatics = function(d, b) {
4412
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
4413
- d2.__proto__ = b2;
4414
- } || function(d2, b2) {
4415
- for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
4416
- };
4417
- return extendStatics(d, b);
4418
- };
4419
- return function(d, b) {
4420
- extendStatics(d, b);
4421
- function __() {
4422
- this.constructor = d;
4423
- }
4424
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4425
- };
4426
- })();
4427
- Object.defineProperty(exports, "__esModule", { value: true });
4428
- exports.UnixTerminal = void 0;
4429
- var fs19 = __require("fs");
4430
- var path17 = __require("path");
4431
- var tty = __require("tty");
4432
- var terminal_1 = require_terminal();
4433
- var utils_1 = require_utils();
4434
- var native = utils_1.loadNativeModule("pty");
4435
- var pty3 = native.module;
4436
- var helperPath = native.dir + "/spawn-helper";
4437
- helperPath = path17.resolve(__dirname, helperPath);
4438
- helperPath = helperPath.replace("app.asar", "app.asar.unpacked");
4439
- helperPath = helperPath.replace("node_modules.asar", "node_modules.asar.unpacked");
4440
- var DEFAULT_FILE = "sh";
4441
- var DEFAULT_NAME = "xterm";
4442
- var DESTROY_SOCKET_TIMEOUT_MS = 200;
4443
- var UnixTerminal = (
4444
- /** @class */
4445
- (function(_super) {
4446
- __extends(UnixTerminal2, _super);
4447
- function UnixTerminal2(file, args, opt) {
4448
- var _a, _b;
4449
- var _this = _super.call(this, opt) || this;
4450
- _this._boundClose = false;
4451
- _this._emittedClose = false;
4452
- if (typeof args === "string") {
4453
- throw new Error("args as a string is not supported on unix.");
4454
- }
4455
- args = args || [];
4456
- file = file || DEFAULT_FILE;
4457
- opt = opt || {};
4458
- opt.env = opt.env || process.env;
4459
- _this._cols = opt.cols || terminal_1.DEFAULT_COLS;
4460
- _this._rows = opt.rows || terminal_1.DEFAULT_ROWS;
4461
- var uid = (_a = opt.uid) !== null && _a !== void 0 ? _a : -1;
4462
- var gid = (_b = opt.gid) !== null && _b !== void 0 ? _b : -1;
4463
- var env = utils_1.assign({}, opt.env);
4464
- if (opt.env === process.env) {
4465
- _this._sanitizeEnv(env);
4466
- }
4467
- var cwd = opt.cwd || process.cwd();
4468
- env.PWD = cwd;
4469
- var name = opt.name || env.TERM || DEFAULT_NAME;
4470
- env.TERM = name;
4471
- var parsedEnv = _this._parseEnv(env);
4472
- var encoding = opt.encoding === void 0 ? "utf8" : opt.encoding;
4473
- var onexit = function(code, signal) {
4474
- if (!_this._emittedClose) {
4475
- if (_this._boundClose) {
4476
- return;
4477
- }
4478
- _this._boundClose = true;
4479
- var timeout_1 = setTimeout(function() {
4480
- timeout_1 = null;
4481
- _this._socket.destroy();
4482
- }, DESTROY_SOCKET_TIMEOUT_MS);
4483
- _this.once("close", function() {
4484
- if (timeout_1 !== null) {
4485
- clearTimeout(timeout_1);
4486
- }
4487
- _this.emit("exit", code, signal);
4488
- });
4489
- return;
4490
- }
4491
- _this.emit("exit", code, signal);
4492
- };
4493
- var term = pty3.fork(file, args, parsedEnv, cwd, _this._cols, _this._rows, uid, gid, encoding === "utf8", helperPath, onexit);
4494
- _this._socket = new tty.ReadStream(term.fd);
4495
- if (encoding !== null) {
4496
- _this._socket.setEncoding(encoding);
4497
- }
4498
- _this._writeStream = new CustomWriteStream(term.fd, encoding || void 0);
4499
- _this._socket.on("error", function(err) {
4500
- if (err.code) {
4501
- if (~err.code.indexOf("EAGAIN")) {
4502
- return;
4503
- }
4504
- }
4505
- _this._close();
4506
- if (!_this._emittedClose) {
4507
- _this._emittedClose = true;
4508
- _this.emit("close");
4509
- }
4510
- if (err.code) {
4511
- if (~err.code.indexOf("errno 5") || ~err.code.indexOf("EIO")) {
4512
- return;
4513
- }
4514
- }
4515
- if (_this.listeners("error").length < 2) {
4516
- throw err;
4517
- }
4518
- });
4519
- _this._pid = term.pid;
4520
- _this._fd = term.fd;
4521
- _this._pty = term.pty;
4522
- _this._file = file;
4523
- _this._name = name;
4524
- _this._readable = true;
4525
- _this._writable = true;
4526
- _this._socket.on("close", function() {
4527
- if (_this._emittedClose) {
4528
- return;
4529
- }
4530
- _this._emittedClose = true;
4531
- _this._close();
4532
- _this.emit("close");
4533
- });
4534
- _this._forwardEvents();
4535
- return _this;
4536
- }
4537
- Object.defineProperty(UnixTerminal2.prototype, "master", {
4538
- get: function() {
4539
- return this._master;
4540
- },
4541
- enumerable: false,
4542
- configurable: true
4543
- });
4544
- Object.defineProperty(UnixTerminal2.prototype, "slave", {
4545
- get: function() {
4546
- return this._slave;
4547
- },
4548
- enumerable: false,
4549
- configurable: true
4550
- });
4551
- UnixTerminal2.prototype._write = function(data) {
4552
- this._writeStream.write(data);
4553
- };
4554
- Object.defineProperty(UnixTerminal2.prototype, "fd", {
4555
- /* Accessors */
4556
- get: function() {
4557
- return this._fd;
4558
- },
4559
- enumerable: false,
4560
- configurable: true
4561
- });
4562
- Object.defineProperty(UnixTerminal2.prototype, "ptsName", {
4563
- get: function() {
4564
- return this._pty;
4565
- },
4566
- enumerable: false,
4567
- configurable: true
4568
- });
4569
- UnixTerminal2.open = function(opt) {
4570
- var self = Object.create(UnixTerminal2.prototype);
4571
- opt = opt || {};
4572
- if (arguments.length > 1) {
4573
- opt = {
4574
- cols: arguments[1],
4575
- rows: arguments[2]
4576
- };
4577
- }
4578
- var cols = opt.cols || terminal_1.DEFAULT_COLS;
4579
- var rows = opt.rows || terminal_1.DEFAULT_ROWS;
4580
- var encoding = opt.encoding === void 0 ? "utf8" : opt.encoding;
4581
- var term = pty3.open(cols, rows);
4582
- self._master = new tty.ReadStream(term.master);
4583
- if (encoding !== null) {
4584
- self._master.setEncoding(encoding);
4585
- }
4586
- self._master.resume();
4587
- self._slave = new tty.ReadStream(term.slave);
4588
- if (encoding !== null) {
4589
- self._slave.setEncoding(encoding);
4590
- }
4591
- self._slave.resume();
4592
- self._socket = self._master;
4593
- self._pid = -1;
4594
- self._fd = term.master;
4595
- self._pty = term.pty;
4596
- self._file = process.argv[0] || "node";
4597
- self._name = process.env.TERM || "";
4598
- self._readable = true;
4599
- self._writable = true;
4600
- self._socket.on("error", function(err) {
4601
- self._close();
4602
- if (self.listeners("error").length < 2) {
4603
- throw err;
4604
- }
4605
- });
4606
- self._socket.on("close", function() {
4607
- self._close();
4608
- });
4609
- return self;
4610
- };
4611
- UnixTerminal2.prototype.destroy = function() {
4612
- var _this = this;
4613
- this._close();
4614
- this._socket.once("close", function() {
4615
- _this.kill("SIGHUP");
4616
- });
4617
- this._socket.destroy();
4618
- this._writeStream.dispose();
4619
- };
4620
- UnixTerminal2.prototype.kill = function(signal) {
4621
- try {
4622
- process.kill(this.pid, signal || "SIGHUP");
4623
- } catch (e) {
4624
- }
4625
- };
4626
- Object.defineProperty(UnixTerminal2.prototype, "process", {
4627
- /**
4628
- * Gets the name of the process.
4629
- */
4630
- get: function() {
4631
- if (process.platform === "darwin") {
4632
- var title = pty3.process(this._fd);
4633
- return title !== "kernel_task" ? title : this._file;
4634
- }
4635
- return pty3.process(this._fd, this._pty) || this._file;
4636
- },
4637
- enumerable: false,
4638
- configurable: true
4639
- });
4640
- UnixTerminal2.prototype.resize = function(cols, rows) {
4641
- if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) {
4642
- throw new Error("resizing must be done using positive cols and rows");
4643
- }
4644
- pty3.resize(this._fd, cols, rows);
4645
- this._cols = cols;
4646
- this._rows = rows;
4647
- };
4648
- UnixTerminal2.prototype.clear = function() {
4649
- };
4650
- UnixTerminal2.prototype._sanitizeEnv = function(env) {
4651
- delete env["TMUX"];
4652
- delete env["TMUX_PANE"];
4653
- delete env["STY"];
4654
- delete env["WINDOW"];
4655
- delete env["WINDOWID"];
4656
- delete env["TERMCAP"];
4657
- delete env["COLUMNS"];
4658
- delete env["LINES"];
4659
- };
4660
- return UnixTerminal2;
4661
- })(terminal_1.Terminal)
4662
- );
4663
- exports.UnixTerminal = UnixTerminal;
4664
- var CustomWriteStream = (
4665
- /** @class */
4666
- (function() {
4667
- function CustomWriteStream2(_fd, _encoding) {
4668
- this._fd = _fd;
4669
- this._encoding = _encoding;
4670
- this._writeQueue = [];
4671
- }
4672
- CustomWriteStream2.prototype.dispose = function() {
4673
- clearImmediate(this._writeImmediate);
4674
- this._writeImmediate = void 0;
4675
- };
4676
- CustomWriteStream2.prototype.write = function(data) {
4677
- var buffer = typeof data === "string" ? Buffer.from(data, this._encoding) : Buffer.from(data);
4678
- if (buffer.byteLength !== 0) {
4679
- this._writeQueue.push({ buffer, offset: 0 });
4680
- if (this._writeQueue.length === 1) {
4681
- this._processWriteQueue();
4682
- }
4683
- }
4684
- };
4685
- CustomWriteStream2.prototype._processWriteQueue = function() {
4686
- var _this = this;
4687
- this._writeImmediate = void 0;
4688
- if (this._writeQueue.length === 0) {
4689
- return;
4690
- }
4691
- var task = this._writeQueue[0];
4692
- fs19.write(this._fd, task.buffer, task.offset, function(err, written) {
4693
- if (err) {
4694
- if ("code" in err && err.code === "EAGAIN") {
4695
- _this._writeImmediate = setImmediate(function() {
4696
- return _this._processWriteQueue();
4697
- });
4698
- } else {
4699
- _this._writeQueue.length = 0;
4700
- console.error("Unhandled pty write error", err);
4701
- }
4702
- return;
4703
- }
4704
- task.offset += written;
4705
- if (task.offset >= task.buffer.byteLength) {
4706
- _this._writeQueue.shift();
4707
- }
4708
- _this._processWriteQueue();
4709
- });
4710
- };
4711
- return CustomWriteStream2;
4712
- })()
4713
- );
4714
- }
4715
- });
4716
-
4717
- // node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/index.js
4718
- var require_lib = __commonJS({
4719
- "node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/index.js"(exports) {
4720
- "use strict";
4721
- Object.defineProperty(exports, "__esModule", { value: true });
4722
- exports.native = exports.open = exports.createTerminal = exports.fork = exports.spawn = void 0;
4723
- var utils_1 = require_utils();
4724
- var terminalCtor;
4725
- if (process.platform === "win32") {
4726
- terminalCtor = require_windowsTerminal().WindowsTerminal;
4727
- } else {
4728
- terminalCtor = require_unixTerminal().UnixTerminal;
4729
- }
4730
- function spawn4(file, args, opt) {
4731
- return new terminalCtor(file, args, opt);
4732
- }
4733
- exports.spawn = spawn4;
4734
- function fork(file, args, opt) {
4735
- return new terminalCtor(file, args, opt);
4736
- }
4737
- exports.fork = fork;
4738
- function createTerminal(file, args, opt) {
4739
- return new terminalCtor(file, args, opt);
4740
- }
4741
- exports.createTerminal = createTerminal;
4742
- function open(options) {
4743
- return terminalCtor.open(options);
4744
- }
4745
- exports.open = open;
4746
- exports.native = process.platform !== "win32" ? utils_1.loadNativeModule("pty").module : null;
4747
- }
4748
- });
4749
-
4750
3422
  // src/tools/exec_command.js
4751
3423
  import { spawn } from "child_process";
4752
3424
  var pty, activeChildProcess, isActiveCommandPty, writeToActiveCommand, terminateActiveCommand, adjustWindowsCommand, exec_command, runStandardSpawn;
@@ -4755,7 +3427,7 @@ var init_exec_command = __esm({
4755
3427
  init_arg_parser();
4756
3428
  pty = null;
4757
3429
  try {
4758
- const ptyModule = await Promise.resolve().then(() => __toESM(require_lib(), 1));
3430
+ const ptyModule = await import("node-pty");
4759
3431
  pty = ptyModule.default || ptyModule;
4760
3432
  } catch (err) {
4761
3433
  }
@@ -4958,7 +3630,8 @@ var init_exec_command = __esm({
4958
3630
  });
4959
3631
  ptyProcess.onExit(({ exitCode }) => {
4960
3632
  activeChildProcess = null;
4961
- const finalOutput = output || "Command executed with no output.";
3633
+ const normalizedOutput = (output || "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
3634
+ const finalOutput = normalizedOutput || "Command executed with no output.";
4962
3635
  if (exitCode !== 0) {
4963
3636
  resolve(`ERROR: Command [${rawCommand}] failed with exit code [${exitCode}].
4964
3637
 
@@ -7578,7 +6251,7 @@ var init_UpdateProcessor = __esm({
7578
6251
  async "src/components/UpdateProcessor.jsx"() {
7579
6252
  pty2 = null;
7580
6253
  try {
7581
- const ptyModule = await Promise.resolve().then(() => __toESM(require_lib(), 1));
6254
+ const ptyModule = await import("node-pty");
7582
6255
  pty2 = ptyModule.default || ptyModule;
7583
6256
  } catch (err) {
7584
6257
  }
@@ -9117,10 +7790,21 @@ ${timestamp}` };
9117
7790
  onExecEnd: () => {
9118
7791
  setMessages((prev) => {
9119
7792
  if (!activeCommandRef.current) return prev;
7793
+ const rawOutput = execOutputRef.current || "";
7794
+ let normalizedOutput = "";
7795
+ if (isActiveCommandPty) {
7796
+ const noTrailingCr = rawOutput.replace(/\r+\n/g, "\n");
7797
+ normalizedOutput = noTrailingCr.split("\n").map((line) => {
7798
+ const parts = line.split("\r");
7799
+ return parts[parts.length - 1];
7800
+ }).join("\n");
7801
+ } else {
7802
+ normalizedOutput = rawOutput.replace(/\r\n/g, "\n");
7803
+ }
9120
7804
  const finalStatus = `[TERMINAL_RECORD]
9121
7805
  COMMAND: ${activeCommandRef.current}
9122
7806
  PTY: ${isActiveCommandPty}
9123
- OUTPUT: ${execOutputRef.current}`;
7807
+ OUTPUT: ${normalizedOutput}`;
9124
7808
  return [...prev, { id: "term-" + Date.now(), role: "system", text: finalStatus, isTerminalRecord: true }];
9125
7809
  });
9126
7810
  setActiveCommand(null);