@quangnv13/nonstop 1.0.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/README.md +167 -0
- package/README.vi.md +167 -0
- package/dist/bot.js +605 -0
- package/dist/config.js +174 -0
- package/dist/i18n.js +58 -0
- package/dist/index.js +50 -0
- package/dist/logger.js +86 -0
- package/dist/prompt-detection.js +27 -0
- package/dist/runtime-manager.js +77 -0
- package/dist/runtime-state.js +78 -0
- package/dist/runtime.js +622 -0
- package/dist/session-controls.js +56 -0
- package/dist/session-delivery.js +6 -0
- package/dist/session-output.js +52 -0
- package/dist/startup.js +120 -0
- package/dist/store.js +114 -0
- package/dist/terminal.js +138 -0
- package/dist/types.js +2 -0
- package/dist/ui.js +473 -0
- package/images/nonstop.png +0 -0
- package/package.json +56 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildSessionOutputMessages = buildSessionOutputMessages;
|
|
4
|
+
const session_controls_js_1 = require("./session-controls.js");
|
|
5
|
+
const TELEGRAM_MESSAGE_LIMIT = 4000;
|
|
6
|
+
const CODE_FENCE_OVERHEAD = '```\n\n```'.length;
|
|
7
|
+
function buildSessionOutputMessages(options) {
|
|
8
|
+
const markup = (0, session_controls_js_1.buildSessionActionMarkup)({
|
|
9
|
+
sessionId: options.sessionId,
|
|
10
|
+
inputMode: options.inputMode,
|
|
11
|
+
autoEnter: options.autoEnter,
|
|
12
|
+
includeBackButton: false
|
|
13
|
+
});
|
|
14
|
+
return chunkTelegramCodeBlocks(options.snapshot, TELEGRAM_MESSAGE_LIMIT).map((chunk) => ({
|
|
15
|
+
text: `\`\`\`\n${chunk}\n\`\`\``,
|
|
16
|
+
options: {
|
|
17
|
+
parse_mode: 'MarkdownV2',
|
|
18
|
+
reply_markup: markup
|
|
19
|
+
}
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
function chunkTelegramCodeBlocks(text, limit) {
|
|
23
|
+
const source = text || '';
|
|
24
|
+
if (!source) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const maxChunkLength = Math.max(1, limit - CODE_FENCE_OVERHEAD);
|
|
28
|
+
const chunks = [];
|
|
29
|
+
let currentChunk = '';
|
|
30
|
+
for (const character of source) {
|
|
31
|
+
const escapedCharacter = escapeTelegramCodeBlockCharacter(character);
|
|
32
|
+
if (currentChunk.length + escapedCharacter.length > maxChunkLength) {
|
|
33
|
+
chunks.push(currentChunk);
|
|
34
|
+
currentChunk = escapedCharacter;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
currentChunk += escapedCharacter;
|
|
38
|
+
}
|
|
39
|
+
if (currentChunk) {
|
|
40
|
+
chunks.push(currentChunk);
|
|
41
|
+
}
|
|
42
|
+
return chunks;
|
|
43
|
+
}
|
|
44
|
+
function escapeTelegramCodeBlockCharacter(character) {
|
|
45
|
+
if (character === '\\') {
|
|
46
|
+
return '\\\\';
|
|
47
|
+
}
|
|
48
|
+
if (character === '`') {
|
|
49
|
+
return '\\`';
|
|
50
|
+
}
|
|
51
|
+
return character;
|
|
52
|
+
}
|
package/dist/startup.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.buildWindowsStartupCommand = buildWindowsStartupCommand;
|
|
37
|
+
exports.buildLinuxAutostartDesktopEntry = buildLinuxAutostartDesktopEntry;
|
|
38
|
+
exports.buildLinuxSystemdService = buildLinuxSystemdService;
|
|
39
|
+
exports.detectPlatform = detectPlatform;
|
|
40
|
+
exports.applyStartupMode = applyStartupMode;
|
|
41
|
+
exports.clearStartupArtifacts = clearStartupArtifacts;
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const os = __importStar(require("os"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
function buildWindowsStartupCommand(entryScriptPath, mode) {
|
|
46
|
+
const runtimeFlag = mode === 'background' ? '--background' : '--open-ui';
|
|
47
|
+
return `node "${entryScriptPath}" ${runtimeFlag}`;
|
|
48
|
+
}
|
|
49
|
+
function buildLinuxAutostartDesktopEntry(entryScriptPath) {
|
|
50
|
+
return [
|
|
51
|
+
'[Desktop Entry]',
|
|
52
|
+
'Type=Application',
|
|
53
|
+
'Name=nonstop',
|
|
54
|
+
`Exec=node ${entryScriptPath} --open-ui`,
|
|
55
|
+
'X-GNOME-Autostart-enabled=true',
|
|
56
|
+
''
|
|
57
|
+
].join('\n');
|
|
58
|
+
}
|
|
59
|
+
function buildLinuxSystemdService(workdir, entryScriptPath) {
|
|
60
|
+
return [
|
|
61
|
+
'[Unit]',
|
|
62
|
+
'Description=nonstop background runtime',
|
|
63
|
+
'',
|
|
64
|
+
'[Service]',
|
|
65
|
+
`WorkingDirectory=${workdir}`,
|
|
66
|
+
`ExecStart=node ${entryScriptPath} --background`,
|
|
67
|
+
'Restart=on-failure',
|
|
68
|
+
'',
|
|
69
|
+
'[Install]',
|
|
70
|
+
'WantedBy=default.target',
|
|
71
|
+
''
|
|
72
|
+
].join('\n');
|
|
73
|
+
}
|
|
74
|
+
function detectPlatform() {
|
|
75
|
+
if (process.platform === 'win32') {
|
|
76
|
+
return 'windows';
|
|
77
|
+
}
|
|
78
|
+
if (process.platform === 'linux') {
|
|
79
|
+
return 'linux';
|
|
80
|
+
}
|
|
81
|
+
return 'unsupported';
|
|
82
|
+
}
|
|
83
|
+
function applyStartupMode(mode, entryScriptPath, workdir, language) {
|
|
84
|
+
const platform = detectPlatform();
|
|
85
|
+
const isVi = language === 'vi';
|
|
86
|
+
if (platform === 'unsupported') {
|
|
87
|
+
return isVi ? 'Hệ điều hành không hỗ trợ cấu hình khởi động.' : 'Unsupported OS for startup integration.';
|
|
88
|
+
}
|
|
89
|
+
clearStartupArtifacts();
|
|
90
|
+
if (mode === 'disabled') {
|
|
91
|
+
return isVi ? 'Đã tắt khởi động cùng hệ điều hành.' : 'Startup with OS disabled.';
|
|
92
|
+
}
|
|
93
|
+
if (platform === 'windows') {
|
|
94
|
+
const startupDir = path.join(process.env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming'), 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Startup');
|
|
95
|
+
fs.mkdirSync(startupDir, { recursive: true });
|
|
96
|
+
const cmdPath = path.join(startupDir, 'nonstop.cmd');
|
|
97
|
+
fs.writeFileSync(cmdPath, `@echo off\r\ncd /d "${workdir}"\r\n${buildWindowsStartupCommand(entryScriptPath, mode)}\r\n`, 'utf8');
|
|
98
|
+
return isVi ? `Đã bật khởi động cùng Windows (${mode === 'background' ? 'chạy nền' : 'mở giao diện'}).` : `Startup enabled on Windows (${mode}).`;
|
|
99
|
+
}
|
|
100
|
+
if (mode === 'open-ui') {
|
|
101
|
+
const autostartDir = path.join(os.homedir(), '.config', 'autostart');
|
|
102
|
+
fs.mkdirSync(autostartDir, { recursive: true });
|
|
103
|
+
fs.writeFileSync(path.join(autostartDir, 'nonstop.desktop'), buildLinuxAutostartDesktopEntry(entryScriptPath), 'utf8');
|
|
104
|
+
return isVi ? 'Đã bật khởi động khi đăng nhập Linux desktop (open-ui).' : 'Startup enabled on Linux desktop login (open-ui).';
|
|
105
|
+
}
|
|
106
|
+
const systemdDir = path.join(os.homedir(), '.config', 'systemd', 'user');
|
|
107
|
+
fs.mkdirSync(systemdDir, { recursive: true });
|
|
108
|
+
fs.writeFileSync(path.join(systemdDir, 'nonstop.service'), buildLinuxSystemdService(workdir, entryScriptPath), 'utf8');
|
|
109
|
+
return isVi ? 'Đã bật khởi động dạng user service trên Linux (background).' : 'Startup enabled on Linux user service (background).';
|
|
110
|
+
}
|
|
111
|
+
function clearStartupArtifacts() {
|
|
112
|
+
const windowsStartupScript = path.join(process.env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming'), 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Startup', 'nonstop.cmd');
|
|
113
|
+
const linuxDesktop = path.join(os.homedir(), '.config', 'autostart', 'nonstop.desktop');
|
|
114
|
+
const linuxService = path.join(os.homedir(), '.config', 'systemd', 'user', 'nonstop.service');
|
|
115
|
+
for (const filePath of [windowsStartupScript, linuxDesktop, linuxService]) {
|
|
116
|
+
if (fs.existsSync(filePath)) {
|
|
117
|
+
fs.unlinkSync(filePath);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
package/dist/store.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.workspacesFilePath = exports.DATA_DIR = void 0;
|
|
37
|
+
exports.loadWorkspaces = loadWorkspaces;
|
|
38
|
+
exports.saveWorkspaces = saveWorkspaces;
|
|
39
|
+
exports.createWorkspaceId = createWorkspaceId;
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
function findDataDir() {
|
|
43
|
+
return path.join(process.cwd(), 'data');
|
|
44
|
+
}
|
|
45
|
+
function ensureDataDir() {
|
|
46
|
+
if (!fs.existsSync(exports.DATA_DIR)) {
|
|
47
|
+
fs.mkdirSync(exports.DATA_DIR, { recursive: true });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.DATA_DIR = findDataDir();
|
|
51
|
+
exports.workspacesFilePath = path.join(exports.DATA_DIR, 'workspaces.json');
|
|
52
|
+
function loadWorkspaces() {
|
|
53
|
+
ensureDataDir();
|
|
54
|
+
if (!fs.existsSync(exports.workspacesFilePath)) {
|
|
55
|
+
return regenerateDefaultWorkspaces();
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const raw = fs.readFileSync(exports.workspacesFilePath, 'utf8');
|
|
59
|
+
const parsed = JSON.parse(raw);
|
|
60
|
+
if (!Array.isArray(parsed)) {
|
|
61
|
+
return regenerateDefaultWorkspaces();
|
|
62
|
+
}
|
|
63
|
+
const workspaces = parsed.filter(isWorkspaceRecord).map((workspace) => ({
|
|
64
|
+
id: workspace.id,
|
|
65
|
+
name: workspace.name,
|
|
66
|
+
path: workspace.path
|
|
67
|
+
}));
|
|
68
|
+
if (workspaces.length === 0) {
|
|
69
|
+
return regenerateDefaultWorkspaces();
|
|
70
|
+
}
|
|
71
|
+
return workspaces;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return regenerateDefaultWorkspaces();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function saveWorkspaces(workspaces) {
|
|
78
|
+
ensureDataDir();
|
|
79
|
+
fs.writeFileSync(exports.workspacesFilePath, JSON.stringify(workspaces, null, 2), 'utf8');
|
|
80
|
+
}
|
|
81
|
+
function createWorkspaceId() {
|
|
82
|
+
return `ws_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
83
|
+
}
|
|
84
|
+
function isWorkspaceRecord(value) {
|
|
85
|
+
if (!value || typeof value !== 'object') {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
const record = value;
|
|
89
|
+
return (typeof record.id === 'string' &&
|
|
90
|
+
typeof record.name === 'string' &&
|
|
91
|
+
typeof record.path === 'string');
|
|
92
|
+
}
|
|
93
|
+
function regenerateDefaultWorkspaces() {
|
|
94
|
+
const rootDir = path.resolve(exports.DATA_DIR, '..');
|
|
95
|
+
const defaultWorkspaces = [
|
|
96
|
+
{
|
|
97
|
+
id: 'ws_root',
|
|
98
|
+
name: 'Project Root',
|
|
99
|
+
path: rootDir.replace(/\\/g, '/')
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: 'ws_src',
|
|
103
|
+
name: 'Source',
|
|
104
|
+
path: path.join(rootDir, 'src').replace(/\\/g, '/')
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: 'ws_docs',
|
|
108
|
+
name: 'Docs',
|
|
109
|
+
path: path.join(rootDir, 'docs').replace(/\\/g, '/')
|
|
110
|
+
}
|
|
111
|
+
];
|
|
112
|
+
saveWorkspaces(defaultWorkspaces);
|
|
113
|
+
return defaultWorkspaces;
|
|
114
|
+
}
|
package/dist/terminal.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SUPPORTED_PRESETS = exports.NodePtyTerminalDriver = void 0;
|
|
37
|
+
exports.resolvePreset = resolvePreset;
|
|
38
|
+
const pty = __importStar(require("node-pty"));
|
|
39
|
+
const logger_js_1 = require("./logger.js");
|
|
40
|
+
class NodePtyTerminalDriver {
|
|
41
|
+
ptyProcess;
|
|
42
|
+
constructor(command, args, cwd) {
|
|
43
|
+
const isWindows = process.platform === 'win32';
|
|
44
|
+
let spawnCmd = command;
|
|
45
|
+
let spawnArgs = args;
|
|
46
|
+
if (isWindows) {
|
|
47
|
+
const lowerCmd = command.toLowerCase();
|
|
48
|
+
if (!lowerCmd.endsWith('.exe')) {
|
|
49
|
+
spawnCmd = 'cmd.exe';
|
|
50
|
+
spawnArgs = ['/c', command, ...args];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
logger_js_1.logger.info('Spawning PTY process', {
|
|
54
|
+
command,
|
|
55
|
+
args,
|
|
56
|
+
spawnCmd,
|
|
57
|
+
spawnArgs,
|
|
58
|
+
cwd
|
|
59
|
+
});
|
|
60
|
+
this.ptyProcess = pty.spawn(spawnCmd, spawnArgs, {
|
|
61
|
+
name: 'xterm-color',
|
|
62
|
+
cols: 80,
|
|
63
|
+
rows: 24,
|
|
64
|
+
cwd,
|
|
65
|
+
env: process.env
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
write(data) {
|
|
69
|
+
this.ptyProcess.write(data);
|
|
70
|
+
}
|
|
71
|
+
resize(cols, rows) {
|
|
72
|
+
this.ptyProcess.resize(cols, rows);
|
|
73
|
+
}
|
|
74
|
+
kill(signal) {
|
|
75
|
+
try {
|
|
76
|
+
logger_js_1.logger.warn('Killing PTY process', { signal: signal ?? 'default' });
|
|
77
|
+
this.ptyProcess.kill(signal);
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
logger_js_1.logger.error('Error killing PTY process', {
|
|
81
|
+
error: err instanceof Error ? err.message : String(err)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
onData(cb) {
|
|
86
|
+
this.ptyProcess.onData(cb);
|
|
87
|
+
}
|
|
88
|
+
onExit(cb) {
|
|
89
|
+
this.ptyProcess.onExit(({ exitCode, signal }) => {
|
|
90
|
+
cb(exitCode, signal);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.NodePtyTerminalDriver = NodePtyTerminalDriver;
|
|
95
|
+
exports.SUPPORTED_PRESETS = ['powershell', 'bash', 'codex', 'antigravity'];
|
|
96
|
+
function resolvePreset(presetName) {
|
|
97
|
+
const isWindows = process.platform === 'win32';
|
|
98
|
+
switch (presetName) {
|
|
99
|
+
case 'powershell':
|
|
100
|
+
return {
|
|
101
|
+
command: isWindows ? 'powershell.exe' : 'pwsh',
|
|
102
|
+
args: []
|
|
103
|
+
};
|
|
104
|
+
case 'bash':
|
|
105
|
+
return {
|
|
106
|
+
command: 'bash',
|
|
107
|
+
args: []
|
|
108
|
+
};
|
|
109
|
+
case 'codex': {
|
|
110
|
+
const command = process.env.CODEX_CMD || 'codex';
|
|
111
|
+
let args = [];
|
|
112
|
+
if (process.env.CODEX_ARGS) {
|
|
113
|
+
try {
|
|
114
|
+
args = JSON.parse(process.env.CODEX_ARGS);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
args = process.env.CODEX_ARGS.split(/\s+/).filter(Boolean);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return { command, args };
|
|
121
|
+
}
|
|
122
|
+
case 'antigravity': {
|
|
123
|
+
const command = process.env.ANTIGRAVITY_CMD || 'agy';
|
|
124
|
+
let args = [];
|
|
125
|
+
if (process.env.ANTIGRAVITY_ARGS) {
|
|
126
|
+
try {
|
|
127
|
+
args = JSON.parse(process.env.ANTIGRAVITY_ARGS);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
args = process.env.ANTIGRAVITY_ARGS.split(/\s+/).filter(Boolean);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return { command, args };
|
|
134
|
+
}
|
|
135
|
+
default:
|
|
136
|
+
throw new Error(`Unsupported preset "${presetName}".`);
|
|
137
|
+
}
|
|
138
|
+
}
|
package/dist/types.js
ADDED