@botiverse/kimi-code-sdk 0.16.0 → 0.17.0
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/NOTICE.md +1 -1
- package/README.md +1 -1
- package/dist/index.d.mts +59 -0
- package/dist/index.mjs +13164 -1681
- package/dist/lib-uthR5TlF.mjs +1238 -0
- package/package.json +3 -3
|
@@ -0,0 +1,1238 @@
|
|
|
1
|
+
import { fileURLToPath as __cjsShimFileURLToPath } from 'node:url';
|
|
2
|
+
import { dirname as __cjsShimDirname } from 'node:path';
|
|
3
|
+
const __filename = __cjsShimFileURLToPath(import.meta.url);
|
|
4
|
+
const __dirname = __cjsShimDirname(__filename);
|
|
5
|
+
import { r as __require, t as __commonJSMin } from "./index.mjs";
|
|
6
|
+
//#region ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/utils.js
|
|
7
|
+
var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
8
|
+
/**
|
|
9
|
+
* Copyright (c) 2017, Daniel Imms (MIT License).
|
|
10
|
+
* Copyright (c) 2018, Microsoft Corporation (MIT License).
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.loadNativeModule = exports.assign = void 0;
|
|
14
|
+
function assign(target) {
|
|
15
|
+
var sources = [];
|
|
16
|
+
for (var _i = 1; _i < arguments.length; _i++) sources[_i - 1] = arguments[_i];
|
|
17
|
+
sources.forEach(function(source) {
|
|
18
|
+
return Object.keys(source).forEach(function(key) {
|
|
19
|
+
return target[key] = source[key];
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
return target;
|
|
23
|
+
}
|
|
24
|
+
exports.assign = assign;
|
|
25
|
+
function loadNativeModule(name) {
|
|
26
|
+
var dirs = [
|
|
27
|
+
"build/Release",
|
|
28
|
+
"build/Debug",
|
|
29
|
+
"prebuilds/" + process.platform + "-" + process.arch
|
|
30
|
+
];
|
|
31
|
+
var relative = ["..", "."];
|
|
32
|
+
var lastError;
|
|
33
|
+
for (var _i = 0, dirs_1 = dirs; _i < dirs_1.length; _i++) {
|
|
34
|
+
var d = dirs_1[_i];
|
|
35
|
+
for (var _a = 0, relative_1 = relative; _a < relative_1.length; _a++) {
|
|
36
|
+
var dir = relative_1[_a] + "/" + d + "/";
|
|
37
|
+
try {
|
|
38
|
+
return {
|
|
39
|
+
dir,
|
|
40
|
+
module: __require(dir + "/" + name + ".node")
|
|
41
|
+
};
|
|
42
|
+
} catch (e) {
|
|
43
|
+
lastError = e;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
throw new Error("Failed to load native module: " + name + ".node, checked: " + dirs.join(", ") + ": " + lastError);
|
|
48
|
+
}
|
|
49
|
+
exports.loadNativeModule = loadNativeModule;
|
|
50
|
+
}));
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/eventEmitter2.js
|
|
53
|
+
var require_eventEmitter2 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
54
|
+
/**
|
|
55
|
+
* Copyright (c) 2019, Microsoft Corporation (MIT License).
|
|
56
|
+
*/
|
|
57
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
|
+
exports.EventEmitter2 = void 0;
|
|
59
|
+
exports.EventEmitter2 = function() {
|
|
60
|
+
function EventEmitter2() {
|
|
61
|
+
this._listeners = [];
|
|
62
|
+
}
|
|
63
|
+
Object.defineProperty(EventEmitter2.prototype, "event", {
|
|
64
|
+
get: function() {
|
|
65
|
+
var _this = this;
|
|
66
|
+
if (!this._event) this._event = function(listener) {
|
|
67
|
+
_this._listeners.push(listener);
|
|
68
|
+
return { dispose: function() {
|
|
69
|
+
for (var i = 0; i < _this._listeners.length; i++) if (_this._listeners[i] === listener) {
|
|
70
|
+
_this._listeners.splice(i, 1);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
} };
|
|
74
|
+
};
|
|
75
|
+
return this._event;
|
|
76
|
+
},
|
|
77
|
+
enumerable: false,
|
|
78
|
+
configurable: true
|
|
79
|
+
});
|
|
80
|
+
EventEmitter2.prototype.fire = function(data) {
|
|
81
|
+
var queue = [];
|
|
82
|
+
for (var i = 0; i < this._listeners.length; i++) queue.push(this._listeners[i]);
|
|
83
|
+
for (var i = 0; i < queue.length; i++) queue[i].call(void 0, data);
|
|
84
|
+
};
|
|
85
|
+
return EventEmitter2;
|
|
86
|
+
}();
|
|
87
|
+
}));
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/terminal.js
|
|
90
|
+
var require_terminal = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
91
|
+
/**
|
|
92
|
+
* Copyright (c) 2012-2015, Christopher Jeffrey (MIT License)
|
|
93
|
+
* Copyright (c) 2016, Daniel Imms (MIT License).
|
|
94
|
+
* Copyright (c) 2018, Microsoft Corporation (MIT License).
|
|
95
|
+
*/
|
|
96
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
97
|
+
exports.Terminal = exports.DEFAULT_ROWS = exports.DEFAULT_COLS = void 0;
|
|
98
|
+
var events_1 = __require("events");
|
|
99
|
+
var eventEmitter2_1 = require_eventEmitter2();
|
|
100
|
+
exports.DEFAULT_COLS = 80;
|
|
101
|
+
exports.DEFAULT_ROWS = 24;
|
|
102
|
+
/**
|
|
103
|
+
* Default messages to indicate PAUSE/RESUME for automatic flow control.
|
|
104
|
+
* To avoid conflicts with rebound XON/XOFF control codes (such as on-my-zsh),
|
|
105
|
+
* the sequences can be customized in `IPtyForkOptions`.
|
|
106
|
+
*/
|
|
107
|
+
var FLOW_CONTROL_PAUSE = "";
|
|
108
|
+
var FLOW_CONTROL_RESUME = "";
|
|
109
|
+
exports.Terminal = function() {
|
|
110
|
+
function Terminal(opt) {
|
|
111
|
+
this._pid = 0;
|
|
112
|
+
this._fd = 0;
|
|
113
|
+
this._cols = 0;
|
|
114
|
+
this._rows = 0;
|
|
115
|
+
this._readable = false;
|
|
116
|
+
this._writable = false;
|
|
117
|
+
this._onData = new eventEmitter2_1.EventEmitter2();
|
|
118
|
+
this._onExit = new eventEmitter2_1.EventEmitter2();
|
|
119
|
+
this._internalee = new events_1.EventEmitter();
|
|
120
|
+
this.handleFlowControl = !!(opt === null || opt === void 0 ? void 0 : opt.handleFlowControl);
|
|
121
|
+
this._flowControlPause = (opt === null || opt === void 0 ? void 0 : opt.flowControlPause) || FLOW_CONTROL_PAUSE;
|
|
122
|
+
this._flowControlResume = (opt === null || opt === void 0 ? void 0 : opt.flowControlResume) || FLOW_CONTROL_RESUME;
|
|
123
|
+
if (!opt) return;
|
|
124
|
+
this._checkType("name", opt.name ? opt.name : void 0, "string");
|
|
125
|
+
this._checkType("cols", opt.cols ? opt.cols : void 0, "number");
|
|
126
|
+
this._checkType("rows", opt.rows ? opt.rows : void 0, "number");
|
|
127
|
+
this._checkType("cwd", opt.cwd ? opt.cwd : void 0, "string");
|
|
128
|
+
this._checkType("env", opt.env ? opt.env : void 0, "object");
|
|
129
|
+
this._checkType("uid", opt.uid ? opt.uid : void 0, "number");
|
|
130
|
+
this._checkType("gid", opt.gid ? opt.gid : void 0, "number");
|
|
131
|
+
this._checkType("encoding", opt.encoding ? opt.encoding : void 0, "string");
|
|
132
|
+
}
|
|
133
|
+
Object.defineProperty(Terminal.prototype, "onData", {
|
|
134
|
+
get: function() {
|
|
135
|
+
return this._onData.event;
|
|
136
|
+
},
|
|
137
|
+
enumerable: false,
|
|
138
|
+
configurable: true
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(Terminal.prototype, "onExit", {
|
|
141
|
+
get: function() {
|
|
142
|
+
return this._onExit.event;
|
|
143
|
+
},
|
|
144
|
+
enumerable: false,
|
|
145
|
+
configurable: true
|
|
146
|
+
});
|
|
147
|
+
Object.defineProperty(Terminal.prototype, "pid", {
|
|
148
|
+
get: function() {
|
|
149
|
+
return this._pid;
|
|
150
|
+
},
|
|
151
|
+
enumerable: false,
|
|
152
|
+
configurable: true
|
|
153
|
+
});
|
|
154
|
+
Object.defineProperty(Terminal.prototype, "cols", {
|
|
155
|
+
get: function() {
|
|
156
|
+
return this._cols;
|
|
157
|
+
},
|
|
158
|
+
enumerable: false,
|
|
159
|
+
configurable: true
|
|
160
|
+
});
|
|
161
|
+
Object.defineProperty(Terminal.prototype, "rows", {
|
|
162
|
+
get: function() {
|
|
163
|
+
return this._rows;
|
|
164
|
+
},
|
|
165
|
+
enumerable: false,
|
|
166
|
+
configurable: true
|
|
167
|
+
});
|
|
168
|
+
Terminal.prototype.write = function(data) {
|
|
169
|
+
if (this.handleFlowControl) {
|
|
170
|
+
if (data === this._flowControlPause) {
|
|
171
|
+
this.pause();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (data === this._flowControlResume) {
|
|
175
|
+
this.resume();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
this._write(data);
|
|
180
|
+
};
|
|
181
|
+
Terminal.prototype._forwardEvents = function() {
|
|
182
|
+
var _this = this;
|
|
183
|
+
this.on("data", function(e) {
|
|
184
|
+
return _this._onData.fire(e);
|
|
185
|
+
});
|
|
186
|
+
this.on("exit", function(exitCode, signal) {
|
|
187
|
+
return _this._onExit.fire({
|
|
188
|
+
exitCode,
|
|
189
|
+
signal
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
Terminal.prototype._checkType = function(name, value, type, allowArray) {
|
|
194
|
+
if (allowArray === void 0) allowArray = false;
|
|
195
|
+
if (value === void 0) return;
|
|
196
|
+
if (allowArray) {
|
|
197
|
+
if (Array.isArray(value)) {
|
|
198
|
+
value.forEach(function(v, i) {
|
|
199
|
+
if (typeof v !== type) throw new Error(name + "[" + i + "] must be a " + type + " (not a " + typeof v[i] + ")");
|
|
200
|
+
});
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (typeof value !== type) throw new Error(name + " must be a " + type + " (not a " + typeof value + ")");
|
|
205
|
+
};
|
|
206
|
+
/** See net.Socket.end */
|
|
207
|
+
Terminal.prototype.end = function(data) {
|
|
208
|
+
this._socket.end(data);
|
|
209
|
+
};
|
|
210
|
+
/** See stream.Readable.pipe */
|
|
211
|
+
Terminal.prototype.pipe = function(dest, options) {
|
|
212
|
+
return this._socket.pipe(dest, options);
|
|
213
|
+
};
|
|
214
|
+
/** See net.Socket.pause */
|
|
215
|
+
Terminal.prototype.pause = function() {
|
|
216
|
+
return this._socket.pause();
|
|
217
|
+
};
|
|
218
|
+
/** See net.Socket.resume */
|
|
219
|
+
Terminal.prototype.resume = function() {
|
|
220
|
+
return this._socket.resume();
|
|
221
|
+
};
|
|
222
|
+
/** See net.Socket.setEncoding */
|
|
223
|
+
Terminal.prototype.setEncoding = function(encoding) {
|
|
224
|
+
if (this._socket._decoder) delete this._socket._decoder;
|
|
225
|
+
if (encoding) this._socket.setEncoding(encoding);
|
|
226
|
+
};
|
|
227
|
+
Terminal.prototype.addListener = function(eventName, listener) {
|
|
228
|
+
this.on(eventName, listener);
|
|
229
|
+
};
|
|
230
|
+
Terminal.prototype.on = function(eventName, listener) {
|
|
231
|
+
if (eventName === "close") {
|
|
232
|
+
this._internalee.on("close", listener);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
this._socket.on(eventName, listener);
|
|
236
|
+
};
|
|
237
|
+
Terminal.prototype.emit = function(eventName) {
|
|
238
|
+
var args = [];
|
|
239
|
+
for (var _i = 1; _i < arguments.length; _i++) args[_i - 1] = arguments[_i];
|
|
240
|
+
if (eventName === "close") return this._internalee.emit.apply(this._internalee, arguments);
|
|
241
|
+
return this._socket.emit.apply(this._socket, arguments);
|
|
242
|
+
};
|
|
243
|
+
Terminal.prototype.listeners = function(eventName) {
|
|
244
|
+
return this._socket.listeners(eventName);
|
|
245
|
+
};
|
|
246
|
+
Terminal.prototype.removeListener = function(eventName, listener) {
|
|
247
|
+
this._socket.removeListener(eventName, listener);
|
|
248
|
+
};
|
|
249
|
+
Terminal.prototype.removeAllListeners = function(eventName) {
|
|
250
|
+
this._socket.removeAllListeners(eventName);
|
|
251
|
+
};
|
|
252
|
+
Terminal.prototype.once = function(eventName, listener) {
|
|
253
|
+
this._socket.once(eventName, listener);
|
|
254
|
+
};
|
|
255
|
+
Terminal.prototype._close = function() {
|
|
256
|
+
this._socket.readable = false;
|
|
257
|
+
this.write = function() {};
|
|
258
|
+
this.end = function() {};
|
|
259
|
+
this._writable = false;
|
|
260
|
+
this._readable = false;
|
|
261
|
+
};
|
|
262
|
+
Terminal.prototype._parseEnv = function(env) {
|
|
263
|
+
var keys = Object.keys(env || {});
|
|
264
|
+
var pairs = [];
|
|
265
|
+
for (var i = 0; i < keys.length; i++) {
|
|
266
|
+
if (keys[i] === void 0) continue;
|
|
267
|
+
pairs.push(keys[i] + "=" + env[keys[i]]);
|
|
268
|
+
}
|
|
269
|
+
return pairs;
|
|
270
|
+
};
|
|
271
|
+
return Terminal;
|
|
272
|
+
}();
|
|
273
|
+
}));
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/shared/conout.js
|
|
276
|
+
var require_conout = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
277
|
+
/**
|
|
278
|
+
* Copyright (c) 2020, Microsoft Corporation (MIT License).
|
|
279
|
+
*/
|
|
280
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
281
|
+
exports.getWorkerPipeName = void 0;
|
|
282
|
+
function getWorkerPipeName(conoutPipeName) {
|
|
283
|
+
return conoutPipeName + "-worker";
|
|
284
|
+
}
|
|
285
|
+
exports.getWorkerPipeName = getWorkerPipeName;
|
|
286
|
+
}));
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsConoutConnection.js
|
|
289
|
+
var require_windowsConoutConnection = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
290
|
+
/**
|
|
291
|
+
* Copyright (c) 2020, Microsoft Corporation (MIT License).
|
|
292
|
+
*/
|
|
293
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
294
|
+
function adopt(value) {
|
|
295
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
296
|
+
resolve(value);
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
300
|
+
function fulfilled(value) {
|
|
301
|
+
try {
|
|
302
|
+
step(generator.next(value));
|
|
303
|
+
} catch (e) {
|
|
304
|
+
reject(e);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function rejected(value) {
|
|
308
|
+
try {
|
|
309
|
+
step(generator["throw"](value));
|
|
310
|
+
} catch (e) {
|
|
311
|
+
reject(e);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function step(result) {
|
|
315
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
316
|
+
}
|
|
317
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
var __generator = exports && exports.__generator || function(thisArg, body) {
|
|
321
|
+
var _ = {
|
|
322
|
+
label: 0,
|
|
323
|
+
sent: function() {
|
|
324
|
+
if (t[0] & 1) throw t[1];
|
|
325
|
+
return t[1];
|
|
326
|
+
},
|
|
327
|
+
trys: [],
|
|
328
|
+
ops: []
|
|
329
|
+
}, f, y, t, g;
|
|
330
|
+
return g = {
|
|
331
|
+
next: verb(0),
|
|
332
|
+
"throw": verb(1),
|
|
333
|
+
"return": verb(2)
|
|
334
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
335
|
+
return this;
|
|
336
|
+
}), g;
|
|
337
|
+
function verb(n) {
|
|
338
|
+
return function(v) {
|
|
339
|
+
return step([n, v]);
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function step(op) {
|
|
343
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
344
|
+
while (_) try {
|
|
345
|
+
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;
|
|
346
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
347
|
+
switch (op[0]) {
|
|
348
|
+
case 0:
|
|
349
|
+
case 1:
|
|
350
|
+
t = op;
|
|
351
|
+
break;
|
|
352
|
+
case 4:
|
|
353
|
+
_.label++;
|
|
354
|
+
return {
|
|
355
|
+
value: op[1],
|
|
356
|
+
done: false
|
|
357
|
+
};
|
|
358
|
+
case 5:
|
|
359
|
+
_.label++;
|
|
360
|
+
y = op[1];
|
|
361
|
+
op = [0];
|
|
362
|
+
continue;
|
|
363
|
+
case 7:
|
|
364
|
+
op = _.ops.pop();
|
|
365
|
+
_.trys.pop();
|
|
366
|
+
continue;
|
|
367
|
+
default:
|
|
368
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
369
|
+
_ = 0;
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
373
|
+
_.label = op[1];
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
376
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
377
|
+
_.label = t[1];
|
|
378
|
+
t = op;
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
if (t && _.label < t[2]) {
|
|
382
|
+
_.label = t[2];
|
|
383
|
+
_.ops.push(op);
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
if (t[2]) _.ops.pop();
|
|
387
|
+
_.trys.pop();
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
op = body.call(thisArg, _);
|
|
391
|
+
} catch (e) {
|
|
392
|
+
op = [6, e];
|
|
393
|
+
y = 0;
|
|
394
|
+
} finally {
|
|
395
|
+
f = t = 0;
|
|
396
|
+
}
|
|
397
|
+
if (op[0] & 5) throw op[1];
|
|
398
|
+
return {
|
|
399
|
+
value: op[0] ? op[1] : void 0,
|
|
400
|
+
done: true
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
405
|
+
exports.ConoutConnection = void 0;
|
|
406
|
+
var worker_threads_1 = __require("worker_threads");
|
|
407
|
+
var conout_1 = require_conout();
|
|
408
|
+
var path_1 = __require("path");
|
|
409
|
+
var eventEmitter2_1 = require_eventEmitter2();
|
|
410
|
+
/**
|
|
411
|
+
* The amount of time to wait for additional data after the conpty shell process has exited before
|
|
412
|
+
* shutting down the worker and sockets. The timer will be reset if a new data event comes in after
|
|
413
|
+
* the timer has started.
|
|
414
|
+
*/
|
|
415
|
+
var FLUSH_DATA_INTERVAL = 1e3;
|
|
416
|
+
exports.ConoutConnection = function() {
|
|
417
|
+
function ConoutConnection(_conoutPipeName, _useConptyDll) {
|
|
418
|
+
var _this = this;
|
|
419
|
+
this._conoutPipeName = _conoutPipeName;
|
|
420
|
+
this._useConptyDll = _useConptyDll;
|
|
421
|
+
this._isDisposed = false;
|
|
422
|
+
this._onReady = new eventEmitter2_1.EventEmitter2();
|
|
423
|
+
var workerData = { conoutPipeName: _conoutPipeName };
|
|
424
|
+
var scriptPath = __dirname.replace("node_modules.asar", "node_modules.asar.unpacked");
|
|
425
|
+
this._worker = new worker_threads_1.Worker(path_1.join(scriptPath, "worker/conoutSocketWorker.js"), { workerData });
|
|
426
|
+
this._worker.on("message", function(message) {
|
|
427
|
+
switch (message) {
|
|
428
|
+
case 1:
|
|
429
|
+
_this._onReady.fire();
|
|
430
|
+
return;
|
|
431
|
+
default: console.warn("Unexpected ConoutWorkerMessage", message);
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
Object.defineProperty(ConoutConnection.prototype, "onReady", {
|
|
436
|
+
get: function() {
|
|
437
|
+
return this._onReady.event;
|
|
438
|
+
},
|
|
439
|
+
enumerable: false,
|
|
440
|
+
configurable: true
|
|
441
|
+
});
|
|
442
|
+
ConoutConnection.prototype.dispose = function() {
|
|
443
|
+
if (!this._useConptyDll && this._isDisposed) return;
|
|
444
|
+
this._isDisposed = true;
|
|
445
|
+
this._drainDataAndClose();
|
|
446
|
+
};
|
|
447
|
+
ConoutConnection.prototype.connectSocket = function(socket) {
|
|
448
|
+
socket.connect(conout_1.getWorkerPipeName(this._conoutPipeName));
|
|
449
|
+
};
|
|
450
|
+
ConoutConnection.prototype._drainDataAndClose = function() {
|
|
451
|
+
var _this = this;
|
|
452
|
+
if (this._drainTimeout) clearTimeout(this._drainTimeout);
|
|
453
|
+
this._drainTimeout = setTimeout(function() {
|
|
454
|
+
return _this._destroySocket();
|
|
455
|
+
}, FLUSH_DATA_INTERVAL);
|
|
456
|
+
};
|
|
457
|
+
ConoutConnection.prototype._destroySocket = function() {
|
|
458
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
459
|
+
return __generator(this, function(_a) {
|
|
460
|
+
switch (_a.label) {
|
|
461
|
+
case 0: return [4, this._worker.terminate()];
|
|
462
|
+
case 1:
|
|
463
|
+
_a.sent();
|
|
464
|
+
return [2];
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
};
|
|
469
|
+
return ConoutConnection;
|
|
470
|
+
}();
|
|
471
|
+
}));
|
|
472
|
+
//#endregion
|
|
473
|
+
//#region ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsPtyAgent.js
|
|
474
|
+
var require_windowsPtyAgent = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
475
|
+
/**
|
|
476
|
+
* Copyright (c) 2012-2015, Christopher Jeffrey, Peter Sunde (MIT License)
|
|
477
|
+
* Copyright (c) 2016, Daniel Imms (MIT License).
|
|
478
|
+
* Copyright (c) 2018, Microsoft Corporation (MIT License).
|
|
479
|
+
*/
|
|
480
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
481
|
+
exports.argsToCommandLine = exports.WindowsPtyAgent = void 0;
|
|
482
|
+
var fs$1 = __require("fs");
|
|
483
|
+
var os = __require("os");
|
|
484
|
+
var path$1 = __require("path");
|
|
485
|
+
var child_process_1 = __require("child_process");
|
|
486
|
+
var net_1 = __require("net");
|
|
487
|
+
var windowsConoutConnection_1 = require_windowsConoutConnection();
|
|
488
|
+
var utils_1 = require_utils();
|
|
489
|
+
var conptyNative;
|
|
490
|
+
var winptyNative;
|
|
491
|
+
/**
|
|
492
|
+
* The amount of time to wait for additional data after the conpty shell process has exited before
|
|
493
|
+
* shutting down the socket. The timer will be reset if a new data event comes in after the timer
|
|
494
|
+
* has started.
|
|
495
|
+
*/
|
|
496
|
+
var FLUSH_DATA_INTERVAL = 1e3;
|
|
497
|
+
exports.WindowsPtyAgent = function() {
|
|
498
|
+
function WindowsPtyAgent(file, args, env, cwd, cols, rows, debug, _useConpty, _useConptyDll, conptyInheritCursor) {
|
|
499
|
+
var _this = this;
|
|
500
|
+
if (_useConptyDll === void 0) _useConptyDll = false;
|
|
501
|
+
if (conptyInheritCursor === void 0) conptyInheritCursor = false;
|
|
502
|
+
this._useConpty = _useConpty;
|
|
503
|
+
this._useConptyDll = _useConptyDll;
|
|
504
|
+
this._pid = 0;
|
|
505
|
+
this._innerPid = 0;
|
|
506
|
+
if (this._useConpty === void 0 || this._useConpty === true) this._useConpty = this._getWindowsBuildNumber() >= 18309;
|
|
507
|
+
if (this._useConpty) {
|
|
508
|
+
if (!conptyNative) conptyNative = utils_1.loadNativeModule("conpty").module;
|
|
509
|
+
} else if (!winptyNative) winptyNative = utils_1.loadNativeModule("pty").module;
|
|
510
|
+
this._ptyNative = this._useConpty ? conptyNative : winptyNative;
|
|
511
|
+
cwd = path$1.resolve(cwd);
|
|
512
|
+
var commandLine = argsToCommandLine(file, args);
|
|
513
|
+
var term;
|
|
514
|
+
if (this._useConpty) term = this._ptyNative.startProcess(file, cols, rows, debug, this._generatePipeName(), conptyInheritCursor, this._useConptyDll);
|
|
515
|
+
else {
|
|
516
|
+
term = this._ptyNative.startProcess(file, commandLine, env, cwd, cols, rows, debug);
|
|
517
|
+
this._pid = term.pid;
|
|
518
|
+
this._innerPid = term.innerPid;
|
|
519
|
+
}
|
|
520
|
+
this._fd = term.fd;
|
|
521
|
+
this._pty = term.pty;
|
|
522
|
+
this._outSocket = new net_1.Socket();
|
|
523
|
+
this._outSocket.setEncoding("utf8");
|
|
524
|
+
this._conoutSocketWorker = new windowsConoutConnection_1.ConoutConnection(term.conout, this._useConptyDll);
|
|
525
|
+
this._conoutSocketWorker.onReady(function() {
|
|
526
|
+
_this._conoutSocketWorker.connectSocket(_this._outSocket);
|
|
527
|
+
});
|
|
528
|
+
this._outSocket.on("connect", function() {
|
|
529
|
+
_this._outSocket.emit("ready_datapipe");
|
|
530
|
+
});
|
|
531
|
+
var inSocketFD = fs$1.openSync(term.conin, "w");
|
|
532
|
+
this._inSocket = new net_1.Socket({
|
|
533
|
+
fd: inSocketFD,
|
|
534
|
+
readable: false,
|
|
535
|
+
writable: true
|
|
536
|
+
});
|
|
537
|
+
this._inSocket.setEncoding("utf8");
|
|
538
|
+
if (this._useConpty) {
|
|
539
|
+
var connect = this._ptyNative.connect(this._pty, commandLine, cwd, env, this._useConptyDll, function(c) {
|
|
540
|
+
return _this._$onProcessExit(c);
|
|
541
|
+
});
|
|
542
|
+
this._innerPid = connect.pid;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
Object.defineProperty(WindowsPtyAgent.prototype, "inSocket", {
|
|
546
|
+
get: function() {
|
|
547
|
+
return this._inSocket;
|
|
548
|
+
},
|
|
549
|
+
enumerable: false,
|
|
550
|
+
configurable: true
|
|
551
|
+
});
|
|
552
|
+
Object.defineProperty(WindowsPtyAgent.prototype, "outSocket", {
|
|
553
|
+
get: function() {
|
|
554
|
+
return this._outSocket;
|
|
555
|
+
},
|
|
556
|
+
enumerable: false,
|
|
557
|
+
configurable: true
|
|
558
|
+
});
|
|
559
|
+
Object.defineProperty(WindowsPtyAgent.prototype, "fd", {
|
|
560
|
+
get: function() {
|
|
561
|
+
return this._fd;
|
|
562
|
+
},
|
|
563
|
+
enumerable: false,
|
|
564
|
+
configurable: true
|
|
565
|
+
});
|
|
566
|
+
Object.defineProperty(WindowsPtyAgent.prototype, "innerPid", {
|
|
567
|
+
get: function() {
|
|
568
|
+
return this._innerPid;
|
|
569
|
+
},
|
|
570
|
+
enumerable: false,
|
|
571
|
+
configurable: true
|
|
572
|
+
});
|
|
573
|
+
Object.defineProperty(WindowsPtyAgent.prototype, "pty", {
|
|
574
|
+
get: function() {
|
|
575
|
+
return this._pty;
|
|
576
|
+
},
|
|
577
|
+
enumerable: false,
|
|
578
|
+
configurable: true
|
|
579
|
+
});
|
|
580
|
+
WindowsPtyAgent.prototype.resize = function(cols, rows) {
|
|
581
|
+
if (this._useConpty) {
|
|
582
|
+
if (this._exitCode !== void 0) throw new Error("Cannot resize a pty that has already exited");
|
|
583
|
+
this._ptyNative.resize(this._pty, cols, rows, this._useConptyDll);
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
this._ptyNative.resize(this._pid, cols, rows);
|
|
587
|
+
};
|
|
588
|
+
WindowsPtyAgent.prototype.clear = function() {
|
|
589
|
+
if (this._useConpty) this._ptyNative.clear(this._pty, this._useConptyDll);
|
|
590
|
+
};
|
|
591
|
+
WindowsPtyAgent.prototype.kill = function() {
|
|
592
|
+
var _this = this;
|
|
593
|
+
if (this._useConpty) if (!this._useConptyDll) {
|
|
594
|
+
this._inSocket.readable = false;
|
|
595
|
+
this._outSocket.readable = false;
|
|
596
|
+
this._getConsoleProcessList().then(function(consoleProcessList) {
|
|
597
|
+
consoleProcessList.forEach(function(pid) {
|
|
598
|
+
try {
|
|
599
|
+
process.kill(pid);
|
|
600
|
+
} catch (e) {}
|
|
601
|
+
});
|
|
602
|
+
});
|
|
603
|
+
this._ptyNative.kill(this._pty, this._useConptyDll);
|
|
604
|
+
this._conoutSocketWorker.dispose();
|
|
605
|
+
} else {
|
|
606
|
+
this._inSocket.destroy();
|
|
607
|
+
this._ptyNative.kill(this._pty, this._useConptyDll);
|
|
608
|
+
this._outSocket.on("data", function() {
|
|
609
|
+
_this._conoutSocketWorker.dispose();
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
var processList = this._ptyNative.getProcessList(this._pid);
|
|
614
|
+
this._ptyNative.kill(this._pid, this._innerPid);
|
|
615
|
+
processList.forEach(function(pid) {
|
|
616
|
+
try {
|
|
617
|
+
process.kill(pid);
|
|
618
|
+
} catch (e) {}
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
WindowsPtyAgent.prototype._getConsoleProcessList = function() {
|
|
623
|
+
var _this = this;
|
|
624
|
+
return new Promise(function(resolve) {
|
|
625
|
+
var agent = child_process_1.fork(path$1.join(__dirname, "conpty_console_list_agent"), [_this._innerPid.toString()]);
|
|
626
|
+
agent.on("message", function(message) {
|
|
627
|
+
clearTimeout(timeout);
|
|
628
|
+
resolve(message.consoleProcessList);
|
|
629
|
+
});
|
|
630
|
+
var timeout = setTimeout(function() {
|
|
631
|
+
agent.kill();
|
|
632
|
+
resolve([_this._innerPid]);
|
|
633
|
+
}, 5e3);
|
|
634
|
+
});
|
|
635
|
+
};
|
|
636
|
+
Object.defineProperty(WindowsPtyAgent.prototype, "exitCode", {
|
|
637
|
+
get: function() {
|
|
638
|
+
if (this._useConpty) return this._exitCode;
|
|
639
|
+
var winptyExitCode = this._ptyNative.getExitCode(this._innerPid);
|
|
640
|
+
return winptyExitCode === -1 ? void 0 : winptyExitCode;
|
|
641
|
+
},
|
|
642
|
+
enumerable: false,
|
|
643
|
+
configurable: true
|
|
644
|
+
});
|
|
645
|
+
WindowsPtyAgent.prototype._getWindowsBuildNumber = function() {
|
|
646
|
+
var osVersion = /(\d+)\.(\d+)\.(\d+)/g.exec(os.release());
|
|
647
|
+
var buildNumber = 0;
|
|
648
|
+
if (osVersion && osVersion.length === 4) buildNumber = parseInt(osVersion[3]);
|
|
649
|
+
return buildNumber;
|
|
650
|
+
};
|
|
651
|
+
WindowsPtyAgent.prototype._generatePipeName = function() {
|
|
652
|
+
return "conpty-" + Math.random() * 1e7;
|
|
653
|
+
};
|
|
654
|
+
/**
|
|
655
|
+
* Triggered from the native side when a contpy process exits.
|
|
656
|
+
*/
|
|
657
|
+
WindowsPtyAgent.prototype._$onProcessExit = function(exitCode) {
|
|
658
|
+
var _this = this;
|
|
659
|
+
this._exitCode = exitCode;
|
|
660
|
+
if (!this._useConptyDll) {
|
|
661
|
+
this._flushDataAndCleanUp();
|
|
662
|
+
this._outSocket.on("data", function() {
|
|
663
|
+
return _this._flushDataAndCleanUp();
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
WindowsPtyAgent.prototype._flushDataAndCleanUp = function() {
|
|
668
|
+
var _this = this;
|
|
669
|
+
if (this._useConptyDll) return;
|
|
670
|
+
if (this._closeTimeout) clearTimeout(this._closeTimeout);
|
|
671
|
+
this._closeTimeout = setTimeout(function() {
|
|
672
|
+
return _this._cleanUpProcess();
|
|
673
|
+
}, FLUSH_DATA_INTERVAL);
|
|
674
|
+
};
|
|
675
|
+
WindowsPtyAgent.prototype._cleanUpProcess = function() {
|
|
676
|
+
if (this._useConptyDll) return;
|
|
677
|
+
this._inSocket.readable = false;
|
|
678
|
+
this._outSocket.readable = false;
|
|
679
|
+
this._outSocket.destroy();
|
|
680
|
+
};
|
|
681
|
+
return WindowsPtyAgent;
|
|
682
|
+
}();
|
|
683
|
+
function argsToCommandLine(file, args) {
|
|
684
|
+
if (isCommandLine(args)) {
|
|
685
|
+
if (args.length === 0) return file;
|
|
686
|
+
return argsToCommandLine(file, []) + " " + args;
|
|
687
|
+
}
|
|
688
|
+
var argv = [file];
|
|
689
|
+
Array.prototype.push.apply(argv, args);
|
|
690
|
+
var result = "";
|
|
691
|
+
for (var argIndex = 0; argIndex < argv.length; argIndex++) {
|
|
692
|
+
if (argIndex > 0) result += " ";
|
|
693
|
+
var arg = argv[argIndex];
|
|
694
|
+
var hasLopsidedEnclosingQuote = xOr(arg[0] !== "\"", arg[arg.length - 1] !== "\"");
|
|
695
|
+
var hasNoEnclosingQuotes = arg[0] !== "\"" && arg[arg.length - 1] !== "\"";
|
|
696
|
+
var quote = arg === "" || (arg.indexOf(" ") !== -1 || arg.indexOf(" ") !== -1) && arg.length > 1 && (hasLopsidedEnclosingQuote || hasNoEnclosingQuotes);
|
|
697
|
+
if (quote) result += "\"";
|
|
698
|
+
var bsCount = 0;
|
|
699
|
+
for (var i = 0; i < arg.length; i++) {
|
|
700
|
+
var p = arg[i];
|
|
701
|
+
if (p === "\\") bsCount++;
|
|
702
|
+
else if (p === "\"") {
|
|
703
|
+
result += repeatText("\\", bsCount * 2 + 1);
|
|
704
|
+
result += "\"";
|
|
705
|
+
bsCount = 0;
|
|
706
|
+
} else {
|
|
707
|
+
result += repeatText("\\", bsCount);
|
|
708
|
+
bsCount = 0;
|
|
709
|
+
result += p;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
if (quote) {
|
|
713
|
+
result += repeatText("\\", bsCount * 2);
|
|
714
|
+
result += "\"";
|
|
715
|
+
} else result += repeatText("\\", bsCount);
|
|
716
|
+
}
|
|
717
|
+
return result;
|
|
718
|
+
}
|
|
719
|
+
exports.argsToCommandLine = argsToCommandLine;
|
|
720
|
+
function isCommandLine(args) {
|
|
721
|
+
return typeof args === "string";
|
|
722
|
+
}
|
|
723
|
+
function repeatText(text, count) {
|
|
724
|
+
var result = "";
|
|
725
|
+
for (var i = 0; i < count; i++) result += text;
|
|
726
|
+
return result;
|
|
727
|
+
}
|
|
728
|
+
function xOr(arg1, arg2) {
|
|
729
|
+
return arg1 && !arg2 || !arg1 && arg2;
|
|
730
|
+
}
|
|
731
|
+
}));
|
|
732
|
+
//#endregion
|
|
733
|
+
//#region ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsTerminal.js
|
|
734
|
+
var require_windowsTerminal = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
735
|
+
/**
|
|
736
|
+
* Copyright (c) 2012-2015, Christopher Jeffrey, Peter Sunde (MIT License)
|
|
737
|
+
* Copyright (c) 2016, Daniel Imms (MIT License).
|
|
738
|
+
* Copyright (c) 2018, Microsoft Corporation (MIT License).
|
|
739
|
+
*/
|
|
740
|
+
var __extends = exports && exports.__extends || (function() {
|
|
741
|
+
var extendStatics = function(d, b) {
|
|
742
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
743
|
+
d.__proto__ = b;
|
|
744
|
+
} || function(d, b) {
|
|
745
|
+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
746
|
+
};
|
|
747
|
+
return extendStatics(d, b);
|
|
748
|
+
};
|
|
749
|
+
return function(d, b) {
|
|
750
|
+
extendStatics(d, b);
|
|
751
|
+
function __() {
|
|
752
|
+
this.constructor = d;
|
|
753
|
+
}
|
|
754
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
755
|
+
};
|
|
756
|
+
})();
|
|
757
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
758
|
+
exports.WindowsTerminal = void 0;
|
|
759
|
+
var terminal_1 = require_terminal();
|
|
760
|
+
var windowsPtyAgent_1 = require_windowsPtyAgent();
|
|
761
|
+
var utils_1 = require_utils();
|
|
762
|
+
var DEFAULT_FILE = "cmd.exe";
|
|
763
|
+
var DEFAULT_NAME = "Windows Shell";
|
|
764
|
+
exports.WindowsTerminal = function(_super) {
|
|
765
|
+
__extends(WindowsTerminal, _super);
|
|
766
|
+
function WindowsTerminal(file, args, opt) {
|
|
767
|
+
var _this = _super.call(this, opt) || this;
|
|
768
|
+
_this._checkType("args", args, "string", true);
|
|
769
|
+
args = args || [];
|
|
770
|
+
file = file || DEFAULT_FILE;
|
|
771
|
+
opt = opt || {};
|
|
772
|
+
opt.env = opt.env || process.env;
|
|
773
|
+
if (opt.encoding) console.warn("Setting encoding on Windows is not supported");
|
|
774
|
+
var env = utils_1.assign({}, opt.env);
|
|
775
|
+
_this._cols = opt.cols || terminal_1.DEFAULT_COLS;
|
|
776
|
+
_this._rows = opt.rows || terminal_1.DEFAULT_ROWS;
|
|
777
|
+
var cwd = opt.cwd || process.cwd();
|
|
778
|
+
var name = opt.name || env.TERM || DEFAULT_NAME;
|
|
779
|
+
var parsedEnv = _this._parseEnv(env);
|
|
780
|
+
_this._isReady = false;
|
|
781
|
+
_this._deferreds = [];
|
|
782
|
+
_this._agent = new windowsPtyAgent_1.WindowsPtyAgent(file, args, parsedEnv, cwd, _this._cols, _this._rows, false, opt.useConpty, opt.useConptyDll, opt.conptyInheritCursor);
|
|
783
|
+
_this._socket = _this._agent.outSocket;
|
|
784
|
+
_this._pid = _this._agent.innerPid;
|
|
785
|
+
_this._fd = _this._agent.fd;
|
|
786
|
+
_this._pty = _this._agent.pty;
|
|
787
|
+
_this._socket.on("ready_datapipe", function() {
|
|
788
|
+
_this._socket.once("data", function() {
|
|
789
|
+
if (!_this._isReady) {
|
|
790
|
+
_this._isReady = true;
|
|
791
|
+
_this._deferreds.forEach(function(fn) {
|
|
792
|
+
fn.run();
|
|
793
|
+
});
|
|
794
|
+
_this._deferreds = [];
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
_this._socket.on("error", function(err) {
|
|
798
|
+
_this._close();
|
|
799
|
+
if (err.code) {
|
|
800
|
+
if (~err.code.indexOf("errno 5") || ~err.code.indexOf("EIO")) return;
|
|
801
|
+
}
|
|
802
|
+
if (_this.listeners("error").length < 2) throw err;
|
|
803
|
+
});
|
|
804
|
+
_this._socket.on("close", function() {
|
|
805
|
+
_this.emit("exit", _this._agent.exitCode);
|
|
806
|
+
_this._close();
|
|
807
|
+
});
|
|
808
|
+
});
|
|
809
|
+
_this._file = file;
|
|
810
|
+
_this._name = name;
|
|
811
|
+
_this._readable = true;
|
|
812
|
+
_this._writable = true;
|
|
813
|
+
_this._forwardEvents();
|
|
814
|
+
return _this;
|
|
815
|
+
}
|
|
816
|
+
WindowsTerminal.prototype._write = function(data) {
|
|
817
|
+
this._defer(this._doWrite, data);
|
|
818
|
+
};
|
|
819
|
+
WindowsTerminal.prototype._doWrite = function(data) {
|
|
820
|
+
this._agent.inSocket.write(data);
|
|
821
|
+
};
|
|
822
|
+
/**
|
|
823
|
+
* openpty
|
|
824
|
+
*/
|
|
825
|
+
WindowsTerminal.open = function(options) {
|
|
826
|
+
throw new Error("open() not supported on windows, use Fork() instead.");
|
|
827
|
+
};
|
|
828
|
+
/**
|
|
829
|
+
* TTY
|
|
830
|
+
*/
|
|
831
|
+
WindowsTerminal.prototype.resize = function(cols, rows) {
|
|
832
|
+
var _this = this;
|
|
833
|
+
if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) throw new Error("resizing must be done using positive cols and rows");
|
|
834
|
+
this._deferNoArgs(function() {
|
|
835
|
+
_this._agent.resize(cols, rows);
|
|
836
|
+
_this._cols = cols;
|
|
837
|
+
_this._rows = rows;
|
|
838
|
+
});
|
|
839
|
+
};
|
|
840
|
+
WindowsTerminal.prototype.clear = function() {
|
|
841
|
+
var _this = this;
|
|
842
|
+
this._deferNoArgs(function() {
|
|
843
|
+
_this._agent.clear();
|
|
844
|
+
});
|
|
845
|
+
};
|
|
846
|
+
WindowsTerminal.prototype.destroy = function() {
|
|
847
|
+
var _this = this;
|
|
848
|
+
this._deferNoArgs(function() {
|
|
849
|
+
_this.kill();
|
|
850
|
+
});
|
|
851
|
+
};
|
|
852
|
+
WindowsTerminal.prototype.kill = function(signal) {
|
|
853
|
+
var _this = this;
|
|
854
|
+
this._deferNoArgs(function() {
|
|
855
|
+
if (signal) throw new Error("Signals not supported on windows.");
|
|
856
|
+
_this._close();
|
|
857
|
+
_this._agent.kill();
|
|
858
|
+
});
|
|
859
|
+
};
|
|
860
|
+
WindowsTerminal.prototype._deferNoArgs = function(deferredFn) {
|
|
861
|
+
var _this = this;
|
|
862
|
+
if (this._isReady) {
|
|
863
|
+
deferredFn.call(this);
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
this._deferreds.push({ run: function() {
|
|
867
|
+
return deferredFn.call(_this);
|
|
868
|
+
} });
|
|
869
|
+
};
|
|
870
|
+
WindowsTerminal.prototype._defer = function(deferredFn, arg) {
|
|
871
|
+
var _this = this;
|
|
872
|
+
if (this._isReady) {
|
|
873
|
+
deferredFn.call(this, arg);
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
this._deferreds.push({ run: function() {
|
|
877
|
+
return deferredFn.call(_this, arg);
|
|
878
|
+
} });
|
|
879
|
+
};
|
|
880
|
+
Object.defineProperty(WindowsTerminal.prototype, "process", {
|
|
881
|
+
get: function() {
|
|
882
|
+
return this._name;
|
|
883
|
+
},
|
|
884
|
+
enumerable: false,
|
|
885
|
+
configurable: true
|
|
886
|
+
});
|
|
887
|
+
Object.defineProperty(WindowsTerminal.prototype, "master", {
|
|
888
|
+
get: function() {
|
|
889
|
+
throw new Error("master is not supported on Windows");
|
|
890
|
+
},
|
|
891
|
+
enumerable: false,
|
|
892
|
+
configurable: true
|
|
893
|
+
});
|
|
894
|
+
Object.defineProperty(WindowsTerminal.prototype, "slave", {
|
|
895
|
+
get: function() {
|
|
896
|
+
throw new Error("slave is not supported on Windows");
|
|
897
|
+
},
|
|
898
|
+
enumerable: false,
|
|
899
|
+
configurable: true
|
|
900
|
+
});
|
|
901
|
+
return WindowsTerminal;
|
|
902
|
+
}(terminal_1.Terminal);
|
|
903
|
+
}));
|
|
904
|
+
//#endregion
|
|
905
|
+
//#region ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/unixTerminal.js
|
|
906
|
+
var require_unixTerminal = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
907
|
+
var __extends = exports && exports.__extends || (function() {
|
|
908
|
+
var extendStatics = function(d, b) {
|
|
909
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
910
|
+
d.__proto__ = b;
|
|
911
|
+
} || function(d, b) {
|
|
912
|
+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
913
|
+
};
|
|
914
|
+
return extendStatics(d, b);
|
|
915
|
+
};
|
|
916
|
+
return function(d, b) {
|
|
917
|
+
extendStatics(d, b);
|
|
918
|
+
function __() {
|
|
919
|
+
this.constructor = d;
|
|
920
|
+
}
|
|
921
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
922
|
+
};
|
|
923
|
+
})();
|
|
924
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
925
|
+
exports.UnixTerminal = void 0;
|
|
926
|
+
/**
|
|
927
|
+
* Copyright (c) 2012-2015, Christopher Jeffrey (MIT License)
|
|
928
|
+
* Copyright (c) 2016, Daniel Imms (MIT License).
|
|
929
|
+
* Copyright (c) 2018, Microsoft Corporation (MIT License).
|
|
930
|
+
*/
|
|
931
|
+
var fs = __require("fs");
|
|
932
|
+
var path = __require("path");
|
|
933
|
+
var tty = __require("tty");
|
|
934
|
+
var terminal_1 = require_terminal();
|
|
935
|
+
var utils_1 = require_utils();
|
|
936
|
+
var native = utils_1.loadNativeModule("pty");
|
|
937
|
+
var pty = native.module;
|
|
938
|
+
var helperPath = native.dir + "/spawn-helper";
|
|
939
|
+
helperPath = path.resolve(__dirname, helperPath);
|
|
940
|
+
helperPath = helperPath.replace("app.asar", "app.asar.unpacked");
|
|
941
|
+
helperPath = helperPath.replace("node_modules.asar", "node_modules.asar.unpacked");
|
|
942
|
+
var DEFAULT_FILE = "sh";
|
|
943
|
+
var DEFAULT_NAME = "xterm";
|
|
944
|
+
var DESTROY_SOCKET_TIMEOUT_MS = 200;
|
|
945
|
+
exports.UnixTerminal = function(_super) {
|
|
946
|
+
__extends(UnixTerminal, _super);
|
|
947
|
+
function UnixTerminal(file, args, opt) {
|
|
948
|
+
var _a, _b;
|
|
949
|
+
var _this = _super.call(this, opt) || this;
|
|
950
|
+
_this._boundClose = false;
|
|
951
|
+
_this._emittedClose = false;
|
|
952
|
+
if (typeof args === "string") throw new Error("args as a string is not supported on unix.");
|
|
953
|
+
args = args || [];
|
|
954
|
+
file = file || DEFAULT_FILE;
|
|
955
|
+
opt = opt || {};
|
|
956
|
+
opt.env = opt.env || process.env;
|
|
957
|
+
_this._cols = opt.cols || terminal_1.DEFAULT_COLS;
|
|
958
|
+
_this._rows = opt.rows || terminal_1.DEFAULT_ROWS;
|
|
959
|
+
var uid = (_a = opt.uid) !== null && _a !== void 0 ? _a : -1;
|
|
960
|
+
var gid = (_b = opt.gid) !== null && _b !== void 0 ? _b : -1;
|
|
961
|
+
var env = utils_1.assign({}, opt.env);
|
|
962
|
+
if (opt.env === process.env) _this._sanitizeEnv(env);
|
|
963
|
+
var cwd = opt.cwd || process.cwd();
|
|
964
|
+
env.PWD = cwd;
|
|
965
|
+
var name = opt.name || env.TERM || DEFAULT_NAME;
|
|
966
|
+
env.TERM = name;
|
|
967
|
+
var parsedEnv = _this._parseEnv(env);
|
|
968
|
+
var encoding = opt.encoding === void 0 ? "utf8" : opt.encoding;
|
|
969
|
+
var onexit = function(code, signal) {
|
|
970
|
+
if (!_this._emittedClose) {
|
|
971
|
+
if (_this._boundClose) return;
|
|
972
|
+
_this._boundClose = true;
|
|
973
|
+
var timeout_1 = setTimeout(function() {
|
|
974
|
+
timeout_1 = null;
|
|
975
|
+
_this._socket.destroy();
|
|
976
|
+
}, DESTROY_SOCKET_TIMEOUT_MS);
|
|
977
|
+
_this.once("close", function() {
|
|
978
|
+
if (timeout_1 !== null) clearTimeout(timeout_1);
|
|
979
|
+
_this.emit("exit", code, signal);
|
|
980
|
+
});
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
_this.emit("exit", code, signal);
|
|
984
|
+
};
|
|
985
|
+
var term = pty.fork(file, args, parsedEnv, cwd, _this._cols, _this._rows, uid, gid, encoding === "utf8", helperPath, onexit);
|
|
986
|
+
_this._socket = new tty.ReadStream(term.fd);
|
|
987
|
+
if (encoding !== null) _this._socket.setEncoding(encoding);
|
|
988
|
+
_this._writeStream = new CustomWriteStream(term.fd, encoding || void 0);
|
|
989
|
+
_this._socket.on("error", function(err) {
|
|
990
|
+
if (err.code) {
|
|
991
|
+
if (~err.code.indexOf("EAGAIN")) return;
|
|
992
|
+
}
|
|
993
|
+
_this._close();
|
|
994
|
+
if (!_this._emittedClose) {
|
|
995
|
+
_this._emittedClose = true;
|
|
996
|
+
_this.emit("close");
|
|
997
|
+
}
|
|
998
|
+
if (err.code) {
|
|
999
|
+
if (~err.code.indexOf("errno 5") || ~err.code.indexOf("EIO")) return;
|
|
1000
|
+
}
|
|
1001
|
+
if (_this.listeners("error").length < 2) throw err;
|
|
1002
|
+
});
|
|
1003
|
+
_this._pid = term.pid;
|
|
1004
|
+
_this._fd = term.fd;
|
|
1005
|
+
_this._pty = term.pty;
|
|
1006
|
+
_this._file = file;
|
|
1007
|
+
_this._name = name;
|
|
1008
|
+
_this._readable = true;
|
|
1009
|
+
_this._writable = true;
|
|
1010
|
+
_this._socket.on("close", function() {
|
|
1011
|
+
if (_this._emittedClose) return;
|
|
1012
|
+
_this._emittedClose = true;
|
|
1013
|
+
_this._close();
|
|
1014
|
+
_this.emit("close");
|
|
1015
|
+
});
|
|
1016
|
+
_this._forwardEvents();
|
|
1017
|
+
return _this;
|
|
1018
|
+
}
|
|
1019
|
+
Object.defineProperty(UnixTerminal.prototype, "master", {
|
|
1020
|
+
get: function() {
|
|
1021
|
+
return this._master;
|
|
1022
|
+
},
|
|
1023
|
+
enumerable: false,
|
|
1024
|
+
configurable: true
|
|
1025
|
+
});
|
|
1026
|
+
Object.defineProperty(UnixTerminal.prototype, "slave", {
|
|
1027
|
+
get: function() {
|
|
1028
|
+
return this._slave;
|
|
1029
|
+
},
|
|
1030
|
+
enumerable: false,
|
|
1031
|
+
configurable: true
|
|
1032
|
+
});
|
|
1033
|
+
UnixTerminal.prototype._write = function(data) {
|
|
1034
|
+
this._writeStream.write(data);
|
|
1035
|
+
};
|
|
1036
|
+
Object.defineProperty(UnixTerminal.prototype, "fd", {
|
|
1037
|
+
get: function() {
|
|
1038
|
+
return this._fd;
|
|
1039
|
+
},
|
|
1040
|
+
enumerable: false,
|
|
1041
|
+
configurable: true
|
|
1042
|
+
});
|
|
1043
|
+
Object.defineProperty(UnixTerminal.prototype, "ptsName", {
|
|
1044
|
+
get: function() {
|
|
1045
|
+
return this._pty;
|
|
1046
|
+
},
|
|
1047
|
+
enumerable: false,
|
|
1048
|
+
configurable: true
|
|
1049
|
+
});
|
|
1050
|
+
/**
|
|
1051
|
+
* openpty
|
|
1052
|
+
*/
|
|
1053
|
+
UnixTerminal.open = function(opt) {
|
|
1054
|
+
var self = Object.create(UnixTerminal.prototype);
|
|
1055
|
+
opt = opt || {};
|
|
1056
|
+
if (arguments.length > 1) opt = {
|
|
1057
|
+
cols: arguments[1],
|
|
1058
|
+
rows: arguments[2]
|
|
1059
|
+
};
|
|
1060
|
+
var cols = opt.cols || terminal_1.DEFAULT_COLS;
|
|
1061
|
+
var rows = opt.rows || terminal_1.DEFAULT_ROWS;
|
|
1062
|
+
var encoding = opt.encoding === void 0 ? "utf8" : opt.encoding;
|
|
1063
|
+
var term = pty.open(cols, rows);
|
|
1064
|
+
self._master = new tty.ReadStream(term.master);
|
|
1065
|
+
if (encoding !== null) self._master.setEncoding(encoding);
|
|
1066
|
+
self._master.resume();
|
|
1067
|
+
self._slave = new tty.ReadStream(term.slave);
|
|
1068
|
+
if (encoding !== null) self._slave.setEncoding(encoding);
|
|
1069
|
+
self._slave.resume();
|
|
1070
|
+
self._socket = self._master;
|
|
1071
|
+
self._pid = -1;
|
|
1072
|
+
self._fd = term.master;
|
|
1073
|
+
self._pty = term.pty;
|
|
1074
|
+
self._file = process.argv[0] || "node";
|
|
1075
|
+
self._name = process.env.TERM || "";
|
|
1076
|
+
self._readable = true;
|
|
1077
|
+
self._writable = true;
|
|
1078
|
+
self._socket.on("error", function(err) {
|
|
1079
|
+
self._close();
|
|
1080
|
+
if (self.listeners("error").length < 2) throw err;
|
|
1081
|
+
});
|
|
1082
|
+
self._socket.on("close", function() {
|
|
1083
|
+
self._close();
|
|
1084
|
+
});
|
|
1085
|
+
return self;
|
|
1086
|
+
};
|
|
1087
|
+
UnixTerminal.prototype.destroy = function() {
|
|
1088
|
+
var _this = this;
|
|
1089
|
+
this._close();
|
|
1090
|
+
this._socket.once("close", function() {
|
|
1091
|
+
_this.kill("SIGHUP");
|
|
1092
|
+
});
|
|
1093
|
+
this._socket.destroy();
|
|
1094
|
+
this._writeStream.dispose();
|
|
1095
|
+
};
|
|
1096
|
+
UnixTerminal.prototype.kill = function(signal) {
|
|
1097
|
+
try {
|
|
1098
|
+
process.kill(this.pid, signal || "SIGHUP");
|
|
1099
|
+
} catch (e) {}
|
|
1100
|
+
};
|
|
1101
|
+
Object.defineProperty(UnixTerminal.prototype, "process", {
|
|
1102
|
+
/**
|
|
1103
|
+
* Gets the name of the process.
|
|
1104
|
+
*/
|
|
1105
|
+
get: function() {
|
|
1106
|
+
if (process.platform === "darwin") {
|
|
1107
|
+
var title = pty.process(this._fd);
|
|
1108
|
+
return title !== "kernel_task" ? title : this._file;
|
|
1109
|
+
}
|
|
1110
|
+
return pty.process(this._fd, this._pty) || this._file;
|
|
1111
|
+
},
|
|
1112
|
+
enumerable: false,
|
|
1113
|
+
configurable: true
|
|
1114
|
+
});
|
|
1115
|
+
/**
|
|
1116
|
+
* TTY
|
|
1117
|
+
*/
|
|
1118
|
+
UnixTerminal.prototype.resize = function(cols, rows) {
|
|
1119
|
+
if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) throw new Error("resizing must be done using positive cols and rows");
|
|
1120
|
+
pty.resize(this._fd, cols, rows);
|
|
1121
|
+
this._cols = cols;
|
|
1122
|
+
this._rows = rows;
|
|
1123
|
+
};
|
|
1124
|
+
UnixTerminal.prototype.clear = function() {};
|
|
1125
|
+
UnixTerminal.prototype._sanitizeEnv = function(env) {
|
|
1126
|
+
delete env["TMUX"];
|
|
1127
|
+
delete env["TMUX_PANE"];
|
|
1128
|
+
delete env["STY"];
|
|
1129
|
+
delete env["WINDOW"];
|
|
1130
|
+
delete env["WINDOWID"];
|
|
1131
|
+
delete env["TERMCAP"];
|
|
1132
|
+
delete env["COLUMNS"];
|
|
1133
|
+
delete env["LINES"];
|
|
1134
|
+
};
|
|
1135
|
+
return UnixTerminal;
|
|
1136
|
+
}(terminal_1.Terminal);
|
|
1137
|
+
/**
|
|
1138
|
+
* A custom write stream that writes directly to a file descriptor with proper
|
|
1139
|
+
* handling of backpressure and errors. This avoids some event loop exhaustion
|
|
1140
|
+
* issues that can occur when using the standard APIs in Node.
|
|
1141
|
+
*/
|
|
1142
|
+
var CustomWriteStream = function() {
|
|
1143
|
+
function CustomWriteStream(_fd, _encoding) {
|
|
1144
|
+
this._fd = _fd;
|
|
1145
|
+
this._encoding = _encoding;
|
|
1146
|
+
this._writeQueue = [];
|
|
1147
|
+
}
|
|
1148
|
+
CustomWriteStream.prototype.dispose = function() {
|
|
1149
|
+
clearImmediate(this._writeImmediate);
|
|
1150
|
+
this._writeImmediate = void 0;
|
|
1151
|
+
};
|
|
1152
|
+
CustomWriteStream.prototype.write = function(data) {
|
|
1153
|
+
var buffer = typeof data === "string" ? Buffer.from(data, this._encoding) : Buffer.from(data);
|
|
1154
|
+
if (buffer.byteLength !== 0) {
|
|
1155
|
+
this._writeQueue.push({
|
|
1156
|
+
buffer,
|
|
1157
|
+
offset: 0
|
|
1158
|
+
});
|
|
1159
|
+
if (this._writeQueue.length === 1) this._processWriteQueue();
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
CustomWriteStream.prototype._processWriteQueue = function() {
|
|
1163
|
+
var _this = this;
|
|
1164
|
+
this._writeImmediate = void 0;
|
|
1165
|
+
if (this._writeQueue.length === 0) return;
|
|
1166
|
+
var task = this._writeQueue[0];
|
|
1167
|
+
fs.write(this._fd, task.buffer, task.offset, function(err, written) {
|
|
1168
|
+
if (err) {
|
|
1169
|
+
if ("code" in err && err.code === "EAGAIN") _this._writeImmediate = setImmediate(function() {
|
|
1170
|
+
return _this._processWriteQueue();
|
|
1171
|
+
});
|
|
1172
|
+
else {
|
|
1173
|
+
_this._writeQueue.length = 0;
|
|
1174
|
+
console.error("Unhandled pty write error", err);
|
|
1175
|
+
}
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1178
|
+
task.offset += written;
|
|
1179
|
+
if (task.offset >= task.buffer.byteLength) _this._writeQueue.shift();
|
|
1180
|
+
_this._processWriteQueue();
|
|
1181
|
+
});
|
|
1182
|
+
};
|
|
1183
|
+
return CustomWriteStream;
|
|
1184
|
+
}();
|
|
1185
|
+
}));
|
|
1186
|
+
//#endregion
|
|
1187
|
+
//#region ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/index.js
|
|
1188
|
+
var require_lib = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1189
|
+
/**
|
|
1190
|
+
* Copyright (c) 2012-2015, Christopher Jeffrey, Peter Sunde (MIT License)
|
|
1191
|
+
* Copyright (c) 2016, Daniel Imms (MIT License).
|
|
1192
|
+
* Copyright (c) 2018, Microsoft Corporation (MIT License).
|
|
1193
|
+
*/
|
|
1194
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1195
|
+
exports.native = exports.open = exports.createTerminal = exports.fork = exports.spawn = void 0;
|
|
1196
|
+
var utils_1 = require_utils();
|
|
1197
|
+
var terminalCtor;
|
|
1198
|
+
if (process.platform === "win32") terminalCtor = require_windowsTerminal().WindowsTerminal;
|
|
1199
|
+
else terminalCtor = require_unixTerminal().UnixTerminal;
|
|
1200
|
+
/**
|
|
1201
|
+
* Forks a process as a pseudoterminal.
|
|
1202
|
+
* @param file The file to launch.
|
|
1203
|
+
* @param args The file's arguments as argv (string[]) or in a pre-escaped
|
|
1204
|
+
* CommandLine format (string). Note that the CommandLine option is only
|
|
1205
|
+
* available on Windows and is expected to be escaped properly.
|
|
1206
|
+
* @param options The options of the terminal.
|
|
1207
|
+
* @throws When the file passed to spawn with does not exists.
|
|
1208
|
+
* @see CommandLineToArgvW https://msdn.microsoft.com/en-us/library/windows/desktop/bb776391(v=vs.85).aspx
|
|
1209
|
+
* @see Parsing C++ Comamnd-Line Arguments https://msdn.microsoft.com/en-us/library/17w5ykft.aspx
|
|
1210
|
+
* @see GetCommandLine https://msdn.microsoft.com/en-us/library/windows/desktop/ms683156.aspx
|
|
1211
|
+
*/
|
|
1212
|
+
function spawn(file, args, opt) {
|
|
1213
|
+
return new terminalCtor(file, args, opt);
|
|
1214
|
+
}
|
|
1215
|
+
exports.spawn = spawn;
|
|
1216
|
+
/** @deprecated */
|
|
1217
|
+
function fork(file, args, opt) {
|
|
1218
|
+
return new terminalCtor(file, args, opt);
|
|
1219
|
+
}
|
|
1220
|
+
exports.fork = fork;
|
|
1221
|
+
/** @deprecated */
|
|
1222
|
+
function createTerminal(file, args, opt) {
|
|
1223
|
+
return new terminalCtor(file, args, opt);
|
|
1224
|
+
}
|
|
1225
|
+
exports.createTerminal = createTerminal;
|
|
1226
|
+
function open(options) {
|
|
1227
|
+
return terminalCtor.open(options);
|
|
1228
|
+
}
|
|
1229
|
+
exports.open = open;
|
|
1230
|
+
/**
|
|
1231
|
+
* Expose the native API when not Windows, note that this is not public API and
|
|
1232
|
+
* could be removed at any time.
|
|
1233
|
+
*/
|
|
1234
|
+
exports.native = process.platform !== "win32" ? utils_1.loadNativeModule("pty").module : null;
|
|
1235
|
+
}));
|
|
1236
|
+
//#endregion
|
|
1237
|
+
export default require_lib();
|
|
1238
|
+
export {};
|