sparkecoder 0.1.6 → 0.1.7
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/agent/index.js +2 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/cli.js +23 -12
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +23 -12
- package/dist/index.js.map +1 -1
- package/dist/server/index.js +23 -12
- package/dist/server/index.js.map +1 -1
- package/dist/tools/index.js +2 -1
- package/dist/tools/index.js.map +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -1131,7 +1131,8 @@ async function runBackground(command, workingDirectory, options) {
|
|
|
1131
1131
|
cwd: workingDirectory,
|
|
1132
1132
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1133
1133
|
sessionId: options.sessionId,
|
|
1134
|
-
background: true
|
|
1134
|
+
background: true,
|
|
1135
|
+
name: options.name
|
|
1135
1136
|
}, workingDirectory);
|
|
1136
1137
|
const logFile = join2(logDir, "output.log");
|
|
1137
1138
|
const wrappedCommand = `(${command}) 2>&1 | tee -a ${shellEscape(logFile)}`;
|
|
@@ -3954,7 +3955,10 @@ terminals2.post(
|
|
|
3954
3955
|
return c.json({ error: "tmux is not installed. Background terminals require tmux." }, 400);
|
|
3955
3956
|
}
|
|
3956
3957
|
const workingDirectory = body.cwd || session.workingDirectory;
|
|
3957
|
-
const result = await runBackground(body.command, workingDirectory, {
|
|
3958
|
+
const result = await runBackground(body.command, workingDirectory, {
|
|
3959
|
+
sessionId,
|
|
3960
|
+
name: body.name
|
|
3961
|
+
});
|
|
3958
3962
|
return c.json({
|
|
3959
3963
|
id: result.id,
|
|
3960
3964
|
name: body.name || null,
|
|
@@ -3978,7 +3982,7 @@ terminals2.get("/:sessionId/terminals", async (c) => {
|
|
|
3978
3982
|
const running = await isRunning(meta.id);
|
|
3979
3983
|
return {
|
|
3980
3984
|
id: meta.id,
|
|
3981
|
-
name: null,
|
|
3985
|
+
name: meta.name || null,
|
|
3982
3986
|
command: meta.command,
|
|
3983
3987
|
cwd: meta.cwd,
|
|
3984
3988
|
status: running ? "running" : "stopped",
|
|
@@ -4062,10 +4066,17 @@ terminals2.post(
|
|
|
4062
4066
|
"/:sessionId/terminals/:terminalId/write",
|
|
4063
4067
|
zValidator4("json", writeSchema),
|
|
4064
4068
|
async (c) => {
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
+
const terminalId = c.req.param("terminalId");
|
|
4070
|
+
const body = c.req.valid("json");
|
|
4071
|
+
const isRunning2 = await isRunning(terminalId);
|
|
4072
|
+
if (!isRunning2) {
|
|
4073
|
+
return c.json({ error: "Terminal is not running" }, 400);
|
|
4074
|
+
}
|
|
4075
|
+
const success = await sendInput(terminalId, body.input, { pressEnter: false });
|
|
4076
|
+
if (!success) {
|
|
4077
|
+
return c.json({ error: "Failed to write to terminal" }, 500);
|
|
4078
|
+
}
|
|
4079
|
+
return c.json({ success: true, written: body.input.length });
|
|
4069
4080
|
}
|
|
4070
4081
|
);
|
|
4071
4082
|
terminals2.post("/:sessionId/terminals/kill-all", async (c) => {
|
|
@@ -4074,12 +4085,12 @@ terminals2.post("/:sessionId/terminals/kill-all", async (c) => {
|
|
|
4074
4085
|
if (!session) {
|
|
4075
4086
|
return c.json({ error: "Session not found" }, 404);
|
|
4076
4087
|
}
|
|
4077
|
-
const
|
|
4088
|
+
const sessionTerminals = await listSessionTerminals(sessionId, session.workingDirectory);
|
|
4078
4089
|
let killed = 0;
|
|
4079
|
-
for (const
|
|
4080
|
-
const
|
|
4081
|
-
if (
|
|
4082
|
-
const success = await killTerminal(id);
|
|
4090
|
+
for (const terminal of sessionTerminals) {
|
|
4091
|
+
const isRunning2 = await isRunning(terminal.id);
|
|
4092
|
+
if (isRunning2) {
|
|
4093
|
+
const success = await killTerminal(terminal.id);
|
|
4083
4094
|
if (success) killed++;
|
|
4084
4095
|
}
|
|
4085
4096
|
}
|