@openspecui/server 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +42 -20
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1144,6 +1144,21 @@ function detectPtyPlatform() {
|
|
|
1144
1144
|
if (process.platform === "darwin") return "macos";
|
|
1145
1145
|
return "common";
|
|
1146
1146
|
}
|
|
1147
|
+
function resolveDefaultShell(platform, env) {
|
|
1148
|
+
if (platform === "windows") return env.ComSpec?.trim() || "cmd.exe";
|
|
1149
|
+
return env.SHELL?.trim() || "/bin/sh";
|
|
1150
|
+
}
|
|
1151
|
+
function resolvePtyCommand(opts) {
|
|
1152
|
+
const command = opts.command?.trim();
|
|
1153
|
+
if (command) return {
|
|
1154
|
+
command,
|
|
1155
|
+
args: opts.args ?? []
|
|
1156
|
+
};
|
|
1157
|
+
return {
|
|
1158
|
+
command: resolveDefaultShell(opts.platform, opts.env),
|
|
1159
|
+
args: []
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1147
1162
|
var PtySession = class extends EventEmitter$1 {
|
|
1148
1163
|
id;
|
|
1149
1164
|
command;
|
|
@@ -1163,14 +1178,18 @@ var PtySession = class extends EventEmitter$1 {
|
|
|
1163
1178
|
super();
|
|
1164
1179
|
this.id = id;
|
|
1165
1180
|
this.createdAt = Date.now();
|
|
1166
|
-
const
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1181
|
+
const resolvedCommand = resolvePtyCommand({
|
|
1182
|
+
platform: opts.platform,
|
|
1183
|
+
command: opts.command,
|
|
1184
|
+
args: opts.args,
|
|
1185
|
+
env: process.env
|
|
1186
|
+
});
|
|
1187
|
+
this.command = resolvedCommand.command;
|
|
1188
|
+
this.args = resolvedCommand.args;
|
|
1170
1189
|
this.platform = opts.platform;
|
|
1171
1190
|
this.maxBufferLines = opts.scrollback ?? DEFAULT_SCROLLBACK;
|
|
1172
1191
|
this.maxBufferBytes = opts.maxBufferBytes ?? DEFAULT_MAX_BUFFER_BYTES;
|
|
1173
|
-
this.process = pty.spawn(
|
|
1192
|
+
this.process = pty.spawn(this.command, this.args, {
|
|
1174
1193
|
name: "xterm-256color",
|
|
1175
1194
|
cols: opts.cols ?? 80,
|
|
1176
1195
|
rows: opts.rows ?? 24,
|
|
@@ -1369,22 +1388,25 @@ function createPtyWebSocketHandler(ptyManager) {
|
|
|
1369
1388
|
}
|
|
1370
1389
|
const msg = parsedMessage.data;
|
|
1371
1390
|
switch (msg.type) {
|
|
1372
|
-
case "create":
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1391
|
+
case "create":
|
|
1392
|
+
try {
|
|
1393
|
+
const session = ptyManager.create({
|
|
1394
|
+
cols: msg.cols,
|
|
1395
|
+
rows: msg.rows,
|
|
1396
|
+
command: msg.command,
|
|
1397
|
+
args: msg.args
|
|
1398
|
+
});
|
|
1399
|
+
send({
|
|
1400
|
+
type: "created",
|
|
1401
|
+
requestId: msg.requestId,
|
|
1402
|
+
sessionId: session.id,
|
|
1403
|
+
platform: session.platform
|
|
1404
|
+
});
|
|
1405
|
+
attachToSession(session);
|
|
1406
|
+
} catch (err) {
|
|
1407
|
+
sendError("PTY_CREATE_FAILED", err instanceof Error ? err.message : String(err), { sessionId: msg.requestId });
|
|
1408
|
+
}
|
|
1386
1409
|
break;
|
|
1387
|
-
}
|
|
1388
1410
|
case "attach": {
|
|
1389
1411
|
const session = ptyManager.get(msg.sessionId);
|
|
1390
1412
|
if (!session) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openspecui/server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"yaml": "^2.8.0",
|
|
21
21
|
"yargs": "^18.0.0",
|
|
22
22
|
"zod": "^3.24.1",
|
|
23
|
-
"@openspecui/core": "1.0.
|
|
23
|
+
"@openspecui/core": "1.0.4"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^22.10.2",
|