@platless/axom-cli 0.3.13 → 0.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/axom-patch/cli/README.md +30 -8
- package/dist/axom-patch/cli/account-limits/README.md +27 -0
- package/dist/axom-patch/cli/account-limits/antigravity-proxy.mjs +47 -0
- package/dist/axom-patch/cli/account-limits/antigravity-read.mjs +90 -0
- package/dist/axom-patch/cli/account-limits/antigravity.mjs +46 -0
- package/dist/axom-patch/cli/account-limits/generate.py +120 -0
- package/dist/axom-patch/cli/account-limits/kimi-proxy.mjs +64 -0
- package/dist/axom-patch/cli/account-limits/normalize.mjs +151 -0
- package/dist/axom-patch/cli/claude-account-limits.json +37 -0
- package/dist/axom-patch/cli/codex-account-limits.json +37 -0
- package/dist/axom-patch/cli/commandcode-account-limits.json +30 -0
- package/dist/axom-patch/cli/nightly-task.md +152 -0
- package/dist/axom-patch/cli/pi-subagent-subwork.json +23 -0
- package/dist/axom-patch/cli/probes/claude-late-async-terminal.mjs +5 -1
- package/dist/axom-patch/cli/probes/pi-subagent-subwork.mjs +211 -0
- package/dist/axom-patch/cli/probes/qoder-steering.mjs +1 -1
- package/dist/axom-patch/cli/probes/qoder-subagent-origin.mjs +20 -8
- package/dist/axom-patch/cli/probes/zcode-subagent-subwork.mjs +257 -0
- package/dist/axom-patch/cli/qoder-background-terminal.md +2 -1
- package/dist/axom-patch/cli/qoder-foreground-output.md +4 -3
- package/dist/axom-patch/cli/qoder-steering.json +15 -15
- package/dist/axom-patch/cli/qoder-subagent-origin.json +21 -21
- package/dist/axom-patch/cli/runtime.json +34 -8
- package/dist/axom-patch/cli/zcode-account-limits.json +31 -0
- package/dist/axom-patch/cli/zcode-models.json +38 -0
- package/dist/axom-patch/cli/zcode-subagent-subwork.json +73 -0
- package/dist/cli.js +33 -6
- package/dist/keepers/acp/keeper.mjs +3083 -0
- package/dist/keepers/acp/manifest.json +9 -0
- package/dist/keepers/terminal/keeper.mjs +8469 -0
- package/dist/keepers/terminal/manifest.json +9 -0
- package/dist/keepers/terminal/node_modules/node-pty/lib/conpty_console_list_agent.js +25 -0
- package/dist/keepers/terminal/node_modules/node-pty/lib/eventEmitter2.js +47 -0
- package/dist/keepers/terminal/node_modules/node-pty/lib/index.js +52 -0
- package/dist/keepers/terminal/node_modules/node-pty/lib/interfaces.js +7 -0
- package/dist/keepers/terminal/node_modules/node-pty/lib/shared/conout.js +10 -0
- package/dist/keepers/terminal/node_modules/node-pty/lib/terminal.js +190 -0
- package/dist/keepers/terminal/node_modules/node-pty/lib/types.js +7 -0
- package/dist/keepers/terminal/node_modules/node-pty/lib/unixTerminal.js +351 -0
- package/dist/keepers/terminal/node_modules/node-pty/lib/utils.js +38 -0
- package/dist/keepers/terminal/node_modules/node-pty/lib/windowsConoutConnection.js +131 -0
- package/dist/keepers/terminal/node_modules/node-pty/lib/windowsPtyAgent.js +344 -0
- package/dist/keepers/terminal/node_modules/node-pty/lib/windowsTerminal.js +209 -0
- package/dist/keepers/terminal/node_modules/node-pty/lib/worker/conoutSocketWorker.js +22 -0
- package/dist/keepers/terminal/node_modules/node-pty/package.json +66 -0
- package/dist/keepers/terminal/node_modules/node-pty/prebuilds/darwin-arm64/pty.node +0 -0
- package/dist/keepers/terminal/node_modules/node-pty/prebuilds/darwin-arm64/spawn-helper +0 -0
- package/dist/keepers/terminal/node_modules/node-pty/prebuilds/darwin-x64/pty.node +0 -0
- package/dist/keepers/terminal/node_modules/node-pty/prebuilds/darwin-x64/spawn-helper +0 -0
- package/dist/keepers/terminal/node_modules/node-pty/prebuilds/linux-arm64/pty.node +0 -0
- package/dist/keepers/terminal/node_modules/node-pty/prebuilds/linux-x64/pty.node +0 -0
- package/dist/runtime-deps/qoder-sdk/package-lock.json +1189 -0
- package/dist/runtime-deps/qoder-sdk/package.json +8 -0
- package/dist/test/keeperKit.js +67 -0
- package/dist/workstation/acp/acpAgents.js +2163 -611
- package/dist/workstation/acp/acpClient.js +60 -497
- package/dist/workstation/acp/adoption.js +10 -396
- package/dist/workstation/acp/binaryInstall.js +100 -27
- package/dist/workstation/acp/builds/gc.js +245 -0
- package/dist/workstation/acp/builds/install/binary.js +28 -0
- package/dist/workstation/acp/builds/install/npm.js +235 -0
- package/dist/workstation/acp/builds/install/uv.js +254 -0
- package/dist/workstation/acp/builds/migrate.js +195 -0
- package/dist/workstation/acp/builds/model.js +128 -0
- package/dist/workstation/acp/builds/nodeGate.js +100 -0
- package/dist/workstation/acp/builds/store.js +352 -0
- package/dist/workstation/acp/commandTableProbe.js +68 -0
- package/dist/workstation/acp/configOptions.js +103 -1
- package/dist/workstation/acp/envSecrets.js +27 -0
- package/dist/workstation/acp/initializeResponse.js +285 -0
- package/dist/workstation/acp/installErrors.js +12 -2
- package/dist/workstation/acp/installProbe.js +1 -1
- package/dist/workstation/acp/managedPatches.js +76 -160
- package/dist/workstation/acp/outbox.js +330 -0
- package/dist/workstation/acp/patchAssets.js +20 -3
- package/dist/workstation/acp/permission.js +42 -10
- package/dist/workstation/acp/processor/checkpoint.js +87 -0
- package/dist/workstation/acp/processor/commands.js +35 -0
- package/dist/workstation/acp/processor/control.js +355 -0
- package/dist/workstation/acp/processor/emit.js +26 -0
- package/dist/workstation/acp/processor/jsonrpc.js +172 -0
- package/dist/workstation/acp/processor/memoryLog.js +49 -0
- package/dist/workstation/acp/processor/origins.js +48 -0
- package/dist/workstation/acp/processor/output.js +67 -0
- package/dist/workstation/acp/processor/projection.js +42 -0
- package/dist/workstation/acp/processor/record.js +128 -0
- package/dist/workstation/acp/processor/runtime.js +181 -0
- package/dist/workstation/acp/processor/sdkSchemas.js +61 -0
- package/dist/workstation/acp/processor/session.js +525 -0
- package/dist/workstation/acp/processor/sideChannel.js +80 -0
- package/dist/workstation/acp/processor/state.js +74 -0
- package/dist/workstation/acp/processor/step.js +459 -0
- package/dist/workstation/acp/processor/test/fixtureLog.js +65 -0
- package/dist/workstation/acp/processor/test/harness.js +120 -0
- package/dist/workstation/acp/processor/test/largeIdEcho.js +50 -0
- package/dist/workstation/acp/processor/test/rawAgent.js +70 -0
- package/dist/workstation/acp/processor/transport/generations.js +76 -0
- package/dist/workstation/acp/processor/transport/keeper.js +130 -0
- package/dist/workstation/acp/processor/transport/local.js +269 -0
- package/dist/workstation/acp/processor/transport/types.js +78 -0
- package/dist/workstation/acp/processor/updates.js +364 -0
- package/dist/workstation/acp/processorSession.js +1512 -0
- package/dist/workstation/acp/qoderStartup.js +1 -1
- package/dist/workstation/acp/registry/catalog.js +154 -32
- package/dist/workstation/acp/registry/launch.js +61 -119
- package/dist/workstation/acp/sessionUpdateMapper.js +18 -7
- package/dist/workstation/acp/steering.js +58 -0
- package/dist/workstation/acp/switching.js +114 -0
- package/dist/workstation/acp/terminalLogin.js +16 -42
- package/dist/workstation/acp/terminalLoginSpec.js +41 -0
- package/dist/workstation/acp/test/adapterFixtures.js +256 -0
- package/dist/workstation/acp/test/daemonLife.js +106 -0
- package/dist/workstation/acp/test/keeperWorld.js +267 -0
- package/dist/workstation/acp/test/memoryOutbox.js +55 -0
- package/dist/workstation/acp/test/raw/fixtures.js +196 -0
- package/dist/workstation/acp/test/raw/qoderCaptures.js +125 -0
- package/dist/workstation/acp/test/raw/sanitize.js +344 -0
- package/dist/workstation/acp/test/raw/sources.js +249 -0
- package/dist/workstation/acp/test/realAdapter.js +377 -0
- package/dist/workstation/acp/test/scriptAgent.js +206 -0
- package/dist/workstation/acp/test/sessionFrames.js +42 -0
- package/dist/workstation/acp/timedCommand.js +4 -2
- package/dist/workstation/acp/uvxInstall.js +72 -122
- package/dist/workstation/agentFlow.js +103 -0
- package/dist/workstation/agentSessions.js +1324 -474
- package/dist/workstation/channels/agent.js +7 -5
- package/dist/workstation/channels/computer.js +69 -21
- package/dist/workstation/channels/computerExecs.js +200 -0
- package/dist/workstation/channels/management.js +84 -4
- package/dist/workstation/daemon.js +288 -7
- package/dist/workstation/daemonctl.js +28 -2
- package/dist/workstation/exec/attach.js +126 -0
- package/dist/workstation/exec/command.js +40 -0
- package/dist/workstation/exec/durable.js +517 -0
- package/dist/workstation/exec/fallback.js +106 -0
- package/dist/workstation/exec/policy.js +837 -0
- package/dist/workstation/exec/shaping.js +211 -0
- package/dist/workstation/exec.js +3 -112
- package/dist/workstation/files/adapters/computerFileFrames.js +51 -0
- package/dist/workstation/files/adapters/toolRequests.js +121 -0
- package/dist/workstation/files/client.js +455 -0
- package/dist/workstation/files/errors.js +28 -0
- package/dist/workstation/files/fence.js +350 -0
- package/dist/workstation/files/find/fileIndex.js +153 -0
- package/dist/workstation/files/find/fuzzy.js +155 -0
- package/dist/workstation/files/host.js +122 -0
- package/dist/workstation/files/hostProtocol.js +2 -0
- package/dist/workstation/files/media/cache.js +620 -0
- package/dist/workstation/files/media/encoding.js +308 -0
- package/dist/workstation/files/media/estimator.js +100 -0
- package/dist/workstation/files/media/media.js +325 -0
- package/dist/workstation/files/media/packedAudio.js +23 -0
- package/dist/workstation/files/media/scheduler.js +551 -0
- package/dist/workstation/files/media/types.js +5 -0
- package/dist/workstation/files/scope.js +45 -0
- package/dist/workstation/files/structured.js +284 -0
- package/dist/workstation/{fileOps.js → files/text.js} +117 -38
- package/dist/workstation/files/uploads.js +351 -0
- package/dist/workstation/journal.js +65 -236
- package/dist/workstation/keepers/acp/client.js +101 -0
- package/dist/workstation/keepers/acp/envelope.js +62 -0
- package/dist/workstation/keepers/acp/host.js +419 -0
- package/dist/workstation/keepers/acp/main.js +18 -0
- package/dist/workstation/keepers/acp/memoryStream.js +121 -0
- package/dist/workstation/keepers/acp/params.js +137 -0
- package/dist/workstation/keepers/acp/protocol.js +66 -0
- package/dist/workstation/keepers/acp/recover.js +120 -0
- package/dist/workstation/keepers/acp/session.js +584 -0
- package/dist/workstation/keepers/acp/stderr.js +154 -0
- package/dist/workstation/keepers/kit/activity.js +103 -0
- package/dist/workstation/keepers/kit/bootstrap.js +164 -0
- package/dist/workstation/keepers/kit/buildVersion.js +51 -0
- package/dist/workstation/keepers/kit/bundle.js +120 -0
- package/dist/workstation/keepers/kit/client.js +432 -0
- package/dist/workstation/keepers/kit/identity.js +21 -0
- package/dist/workstation/keepers/kit/ipc.js +112 -0
- package/dist/workstation/keepers/kit/launchConfig.js +8 -0
- package/dist/workstation/keepers/kit/launcher.js +249 -0
- package/dist/workstation/keepers/kit/lock.js +123 -0
- package/dist/workstation/keepers/kit/orphanSweep.js +86 -0
- package/dist/workstation/keepers/kit/paths.js +75 -0
- package/dist/workstation/keepers/kit/protocol.js +43 -0
- package/dist/workstation/keepers/kit/server.js +518 -0
- package/dist/workstation/keepers/kit/streamLog.js +697 -0
- package/dist/workstation/keepers/legacy.js +296 -0
- package/dist/workstation/keepers/policy.js +576 -0
- package/dist/workstation/keepers/stop.js +34 -0
- package/dist/workstation/keepers/terminal/client.js +213 -0
- package/dist/workstation/keepers/terminal/exec.js +981 -0
- package/dist/workstation/keepers/terminal/generations.js +129 -0
- package/dist/workstation/keepers/terminal/keeper.js +62 -0
- package/dist/workstation/keepers/terminal/main.js +43 -0
- package/dist/workstation/keepers/terminal/orphanSweep.js +3 -0
- package/dist/workstation/keepers/terminal/params.js +27 -0
- package/dist/workstation/keepers/terminal/protocol.js +56 -0
- package/dist/workstation/keepers/terminal/pty.js +330 -0
- package/dist/workstation/protocol/accountLimits.js +47 -0
- package/dist/workstation/protocol/agent.js +48 -4
- package/dist/workstation/protocol/common.js +30 -0
- package/dist/workstation/protocol/computer.js +15 -4
- package/dist/workstation/protocol/management.js +50 -2
- package/dist/workstation/qoderAdapter/backgroundProcess.js +18 -6
- package/dist/workstation/qoderAdapter/backgroundTerminal.js +78 -147
- package/dist/workstation/qoderAdapter/backgroundTerminalFold.js +372 -0
- package/dist/workstation/qoderAdapter/callbackContext.js +76 -0
- package/dist/workstation/qoderAdapter/foregroundOutput.js +15 -9
- package/dist/workstation/qoderAdapter/history.js +1 -3
- package/dist/workstation/qoderAdapter/main.js +4 -2
- package/dist/workstation/qoderAdapter/sdkDriver.js +1 -2
- package/dist/workstation/qoderAdapter/sdkRuntime.js +93 -0
- package/dist/workstation/qoderAdapter/sdkRuntimeInstall.js +145 -0
- package/dist/workstation/qoderAdapter/session.js +1 -1
- package/dist/workstation/qoderAdapter/subwork.js +15 -7
- package/dist/workstation/systemMetrics.js +110 -1
- package/dist/workstation/tools/client.js +9 -1
- package/dist/workstation/tools/info.js +50 -0
- package/dist/workstation/tools/keeperProcess.js +15 -5
- package/dist/workstation/tools/router.js +55 -0
- package/dist/workstation/tools/terminalRouter.js +222 -0
- package/dist/workstation/tools/validation.js +37 -1
- package/dist/workstation/update/coordinator.js +3 -0
- package/dist/workstation/update/ptyPreflight.js +21 -0
- package/dist/workstation/update/taskRegistry.js +105 -11
- package/package.json +10 -7
- package/dist/workstation/acp/acpSession.js +0 -1475
- package/dist/workstation/acp/contract.js +0 -499
- package/dist/workstation/acp/draftInterceptor.js +0 -163
- package/dist/workstation/acp/sessionScope.js +0 -19
- package/dist/workstation/filePaths.js +0 -174
- package/dist/workstation/fileWorker.js +0 -81
- package/dist/workstation/fileWorkerClient.js +0 -121
- package/dist/workstation/qoderAdapter/taskEvent.js +0 -26
- package/dist/workstation/tools/core.js +0 -50
- package/dist/workstation/tools/files.js +0 -525
- package/dist/workstation/tools/terminal.js +0 -214
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2019, Microsoft Corporation (MIT License).
|
|
4
|
+
*
|
|
5
|
+
* This module fetches the console process list for a particular PID. It must be
|
|
6
|
+
* called from a different process (child_process.fork) as there can only be a
|
|
7
|
+
* single console attached to a process.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
var utils_1 = require("./utils");
|
|
11
|
+
var getConsoleProcessList = (0, utils_1.loadNativeModule)('conpty_console_list').module.getConsoleProcessList;
|
|
12
|
+
var shellPid = parseInt(process.argv[2], 10);
|
|
13
|
+
var consoleProcessList = [];
|
|
14
|
+
if (shellPid > 0) {
|
|
15
|
+
try {
|
|
16
|
+
consoleProcessList = getConsoleProcessList(shellPid);
|
|
17
|
+
}
|
|
18
|
+
catch (_a) {
|
|
19
|
+
// AttachConsole can fail if the process already exited or is invalid.
|
|
20
|
+
consoleProcessList = [];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
process.send({ consoleProcessList: consoleProcessList });
|
|
24
|
+
process.exit(0);
|
|
25
|
+
//# sourceMappingURL=conpty_console_list_agent.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2019, Microsoft Corporation (MIT License).
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.EventEmitter2 = void 0;
|
|
7
|
+
var EventEmitter2 = /** @class */ (function () {
|
|
8
|
+
function EventEmitter2() {
|
|
9
|
+
this._listeners = [];
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(EventEmitter2.prototype, "event", {
|
|
12
|
+
get: function () {
|
|
13
|
+
var _this = this;
|
|
14
|
+
if (!this._event) {
|
|
15
|
+
this._event = function (listener) {
|
|
16
|
+
_this._listeners.push(listener);
|
|
17
|
+
var disposable = {
|
|
18
|
+
dispose: function () {
|
|
19
|
+
for (var i = 0; i < _this._listeners.length; i++) {
|
|
20
|
+
if (_this._listeners[i] === listener) {
|
|
21
|
+
_this._listeners.splice(i, 1);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
return disposable;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return this._event;
|
|
31
|
+
},
|
|
32
|
+
enumerable: false,
|
|
33
|
+
configurable: true
|
|
34
|
+
});
|
|
35
|
+
EventEmitter2.prototype.fire = function (data) {
|
|
36
|
+
var queue = [];
|
|
37
|
+
for (var i = 0; i < this._listeners.length; i++) {
|
|
38
|
+
queue.push(this._listeners[i]);
|
|
39
|
+
}
|
|
40
|
+
for (var i = 0; i < queue.length; i++) {
|
|
41
|
+
queue[i].call(undefined, data);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return EventEmitter2;
|
|
45
|
+
}());
|
|
46
|
+
exports.EventEmitter2 = EventEmitter2;
|
|
47
|
+
//# sourceMappingURL=eventEmitter2.js.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2012-2015, Christopher Jeffrey, Peter Sunde (MIT License)
|
|
4
|
+
* Copyright (c) 2016, Daniel Imms (MIT License).
|
|
5
|
+
* Copyright (c) 2018, Microsoft Corporation (MIT License).
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.native = void 0;
|
|
9
|
+
exports.spawn = spawn;
|
|
10
|
+
exports.fork = fork;
|
|
11
|
+
exports.createTerminal = createTerminal;
|
|
12
|
+
exports.open = open;
|
|
13
|
+
var utils_1 = require("./utils");
|
|
14
|
+
var terminalCtor;
|
|
15
|
+
if (process.platform === 'win32') {
|
|
16
|
+
terminalCtor = require('./windowsTerminal').WindowsTerminal;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
terminalCtor = require('./unixTerminal').UnixTerminal;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Forks a process as a pseudoterminal.
|
|
23
|
+
* @param file The file to launch.
|
|
24
|
+
* @param args The file's arguments as argv (string[]) or in a pre-escaped
|
|
25
|
+
* CommandLine format (string). Note that the CommandLine option is only
|
|
26
|
+
* available on Windows and is expected to be escaped properly.
|
|
27
|
+
* @param options The options of the terminal.
|
|
28
|
+
* @throws When the file passed to spawn with does not exists.
|
|
29
|
+
* @see CommandLineToArgvW https://msdn.microsoft.com/en-us/library/windows/desktop/bb776391(v=vs.85).aspx
|
|
30
|
+
* @see Parsing C++ Comamnd-Line Arguments https://msdn.microsoft.com/en-us/library/17w5ykft.aspx
|
|
31
|
+
* @see GetCommandLine https://msdn.microsoft.com/en-us/library/windows/desktop/ms683156.aspx
|
|
32
|
+
*/
|
|
33
|
+
function spawn(file, args, opt) {
|
|
34
|
+
return new terminalCtor(file, args, opt);
|
|
35
|
+
}
|
|
36
|
+
/** @deprecated */
|
|
37
|
+
function fork(file, args, opt) {
|
|
38
|
+
return new terminalCtor(file, args, opt);
|
|
39
|
+
}
|
|
40
|
+
/** @deprecated */
|
|
41
|
+
function createTerminal(file, args, opt) {
|
|
42
|
+
return new terminalCtor(file, args, opt);
|
|
43
|
+
}
|
|
44
|
+
function open(options) {
|
|
45
|
+
return terminalCtor.open(options);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Expose the native API when not Windows, note that this is not public API and
|
|
49
|
+
* could be removed at any time.
|
|
50
|
+
*/
|
|
51
|
+
exports.native = (process.platform !== 'win32' ? (0, utils_1.loadNativeModule)('pty').module : null);
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2020, Microsoft Corporation (MIT License).
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getWorkerPipeName = getWorkerPipeName;
|
|
7
|
+
function getWorkerPipeName(conoutPipeName) {
|
|
8
|
+
return "".concat(conoutPipeName, "-worker");
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=conout.js.map
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2012-2015, Christopher Jeffrey (MIT License)
|
|
4
|
+
* Copyright (c) 2016, Daniel Imms (MIT License).
|
|
5
|
+
* Copyright (c) 2018, Microsoft Corporation (MIT License).
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.Terminal = exports.DEFAULT_ROWS = exports.DEFAULT_COLS = void 0;
|
|
9
|
+
var events_1 = require("events");
|
|
10
|
+
var eventEmitter2_1 = require("./eventEmitter2");
|
|
11
|
+
exports.DEFAULT_COLS = 80;
|
|
12
|
+
exports.DEFAULT_ROWS = 24;
|
|
13
|
+
/**
|
|
14
|
+
* Default messages to indicate PAUSE/RESUME for automatic flow control.
|
|
15
|
+
* To avoid conflicts with rebound XON/XOFF control codes (such as on-my-zsh),
|
|
16
|
+
* the sequences can be customized in `IPtyForkOptions`.
|
|
17
|
+
*/
|
|
18
|
+
var FLOW_CONTROL_PAUSE = '\x13'; // defaults to XOFF
|
|
19
|
+
var FLOW_CONTROL_RESUME = '\x11'; // defaults to XON
|
|
20
|
+
var Terminal = /** @class */ (function () {
|
|
21
|
+
function Terminal(opt) {
|
|
22
|
+
this._pid = 0;
|
|
23
|
+
this._fd = 0;
|
|
24
|
+
this._cols = 0;
|
|
25
|
+
this._rows = 0;
|
|
26
|
+
this._readable = false;
|
|
27
|
+
this._writable = false;
|
|
28
|
+
this._onData = new eventEmitter2_1.EventEmitter2();
|
|
29
|
+
this._onExit = new eventEmitter2_1.EventEmitter2();
|
|
30
|
+
// for 'close'
|
|
31
|
+
this._internalee = new events_1.EventEmitter();
|
|
32
|
+
// setup flow control handling
|
|
33
|
+
this.handleFlowControl = !!(opt === null || opt === void 0 ? void 0 : opt.handleFlowControl);
|
|
34
|
+
this._flowControlPause = (opt === null || opt === void 0 ? void 0 : opt.flowControlPause) || FLOW_CONTROL_PAUSE;
|
|
35
|
+
this._flowControlResume = (opt === null || opt === void 0 ? void 0 : opt.flowControlResume) || FLOW_CONTROL_RESUME;
|
|
36
|
+
if (!opt) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
// Do basic type checks here in case node-pty is being used within JavaScript. If the wrong
|
|
40
|
+
// types go through to the C++ side it can lead to hard to diagnose exceptions.
|
|
41
|
+
this._checkType('name', opt.name ? opt.name : undefined, 'string');
|
|
42
|
+
this._checkType('cols', opt.cols ? opt.cols : undefined, 'number');
|
|
43
|
+
this._checkType('rows', opt.rows ? opt.rows : undefined, 'number');
|
|
44
|
+
this._checkType('cwd', opt.cwd ? opt.cwd : undefined, 'string');
|
|
45
|
+
this._checkType('env', opt.env ? opt.env : undefined, 'object');
|
|
46
|
+
this._checkType('uid', opt.uid ? opt.uid : undefined, 'number');
|
|
47
|
+
this._checkType('gid', opt.gid ? opt.gid : undefined, 'number');
|
|
48
|
+
this._checkType('encoding', opt.encoding ? opt.encoding : undefined, 'string');
|
|
49
|
+
}
|
|
50
|
+
Object.defineProperty(Terminal.prototype, "onData", {
|
|
51
|
+
get: function () { return this._onData.event; },
|
|
52
|
+
enumerable: false,
|
|
53
|
+
configurable: true
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(Terminal.prototype, "onExit", {
|
|
56
|
+
get: function () { return this._onExit.event; },
|
|
57
|
+
enumerable: false,
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(Terminal.prototype, "pid", {
|
|
61
|
+
get: function () { return this._pid; },
|
|
62
|
+
enumerable: false,
|
|
63
|
+
configurable: true
|
|
64
|
+
});
|
|
65
|
+
Object.defineProperty(Terminal.prototype, "cols", {
|
|
66
|
+
get: function () { return this._cols; },
|
|
67
|
+
enumerable: false,
|
|
68
|
+
configurable: true
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(Terminal.prototype, "rows", {
|
|
71
|
+
get: function () { return this._rows; },
|
|
72
|
+
enumerable: false,
|
|
73
|
+
configurable: true
|
|
74
|
+
});
|
|
75
|
+
Terminal.prototype.write = function (data) {
|
|
76
|
+
if (this.handleFlowControl) {
|
|
77
|
+
// PAUSE/RESUME messages are not forwarded to the pty
|
|
78
|
+
if (data === this._flowControlPause) {
|
|
79
|
+
this.pause();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (data === this._flowControlResume) {
|
|
83
|
+
this.resume();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// everything else goes to the real pty
|
|
88
|
+
this._write(data);
|
|
89
|
+
};
|
|
90
|
+
Terminal.prototype._forwardEvents = function () {
|
|
91
|
+
var _this = this;
|
|
92
|
+
this.on('data', function (e) { return _this._onData.fire(e); });
|
|
93
|
+
this.on('exit', function (exitCode, signal) { return _this._onExit.fire({ exitCode: exitCode, signal: signal }); });
|
|
94
|
+
};
|
|
95
|
+
Terminal.prototype._checkType = function (name, value, type, allowArray) {
|
|
96
|
+
if (allowArray === void 0) { allowArray = false; }
|
|
97
|
+
if (value === undefined) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (allowArray) {
|
|
101
|
+
if (Array.isArray(value)) {
|
|
102
|
+
value.forEach(function (v, i) {
|
|
103
|
+
if (typeof v !== type) {
|
|
104
|
+
throw new Error("".concat(name, "[").concat(i, "] must be a ").concat(type, " (not a ").concat(typeof v[i], ")"));
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (typeof value !== type) {
|
|
111
|
+
throw new Error("".concat(name, " must be a ").concat(type, " (not a ").concat(typeof value, ")"));
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
/** See net.Socket.end */
|
|
115
|
+
Terminal.prototype.end = function (data) {
|
|
116
|
+
this._socket.end(data);
|
|
117
|
+
};
|
|
118
|
+
/** See stream.Readable.pipe */
|
|
119
|
+
Terminal.prototype.pipe = function (dest, options) {
|
|
120
|
+
return this._socket.pipe(dest, options);
|
|
121
|
+
};
|
|
122
|
+
/** See net.Socket.pause */
|
|
123
|
+
Terminal.prototype.pause = function () {
|
|
124
|
+
return this._socket.pause();
|
|
125
|
+
};
|
|
126
|
+
/** See net.Socket.resume */
|
|
127
|
+
Terminal.prototype.resume = function () {
|
|
128
|
+
return this._socket.resume();
|
|
129
|
+
};
|
|
130
|
+
/** See net.Socket.setEncoding */
|
|
131
|
+
Terminal.prototype.setEncoding = function (encoding) {
|
|
132
|
+
if (this._socket._decoder) {
|
|
133
|
+
delete this._socket._decoder;
|
|
134
|
+
}
|
|
135
|
+
if (encoding) {
|
|
136
|
+
this._socket.setEncoding(encoding);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
Terminal.prototype.addListener = function (eventName, listener) { this.on(eventName, listener); };
|
|
140
|
+
Terminal.prototype.on = function (eventName, listener) {
|
|
141
|
+
if (eventName === 'close') {
|
|
142
|
+
this._internalee.on('close', listener);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
this._socket.on(eventName, listener);
|
|
146
|
+
};
|
|
147
|
+
Terminal.prototype.emit = function (eventName) {
|
|
148
|
+
var args = [];
|
|
149
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
150
|
+
args[_i - 1] = arguments[_i];
|
|
151
|
+
}
|
|
152
|
+
if (eventName === 'close') {
|
|
153
|
+
return this._internalee.emit.apply(this._internalee, arguments);
|
|
154
|
+
}
|
|
155
|
+
return this._socket.emit.apply(this._socket, arguments);
|
|
156
|
+
};
|
|
157
|
+
Terminal.prototype.listeners = function (eventName) {
|
|
158
|
+
return this._socket.listeners(eventName);
|
|
159
|
+
};
|
|
160
|
+
Terminal.prototype.removeListener = function (eventName, listener) {
|
|
161
|
+
this._socket.removeListener(eventName, listener);
|
|
162
|
+
};
|
|
163
|
+
Terminal.prototype.removeAllListeners = function (eventName) {
|
|
164
|
+
this._socket.removeAllListeners(eventName);
|
|
165
|
+
};
|
|
166
|
+
Terminal.prototype.once = function (eventName, listener) {
|
|
167
|
+
this._socket.once(eventName, listener);
|
|
168
|
+
};
|
|
169
|
+
Terminal.prototype._close = function () {
|
|
170
|
+
this._socket.readable = false;
|
|
171
|
+
this.write = function () { };
|
|
172
|
+
this.end = function () { };
|
|
173
|
+
this._writable = false;
|
|
174
|
+
this._readable = false;
|
|
175
|
+
};
|
|
176
|
+
Terminal.prototype._parseEnv = function (env) {
|
|
177
|
+
var keys = Object.keys(env || {});
|
|
178
|
+
var pairs = [];
|
|
179
|
+
for (var i = 0; i < keys.length; i++) {
|
|
180
|
+
if (keys[i] === undefined) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
pairs.push(keys[i] + '=' + env[keys[i]]);
|
|
184
|
+
}
|
|
185
|
+
return pairs;
|
|
186
|
+
};
|
|
187
|
+
return Terminal;
|
|
188
|
+
}());
|
|
189
|
+
exports.Terminal = Terminal;
|
|
190
|
+
//# sourceMappingURL=terminal.js.map
|