sparkecoder 0.1.5 → 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.d.ts +1 -1
- package/dist/agent/index.js +2 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/cli.js +43 -15
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +4 -2
- 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/{index-Btr542-G.d.ts → index-BeKylVnB.d.ts} +4 -4
package/dist/cli.js
CHANGED
|
@@ -1166,7 +1166,8 @@ async function runBackground(command, workingDirectory, options) {
|
|
|
1166
1166
|
cwd: workingDirectory,
|
|
1167
1167
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1168
1168
|
sessionId: options.sessionId,
|
|
1169
|
-
background: true
|
|
1169
|
+
background: true,
|
|
1170
|
+
name: options.name
|
|
1170
1171
|
}, workingDirectory);
|
|
1171
1172
|
const logFile = join2(logDir, "output.log");
|
|
1172
1173
|
const wrappedCommand = `(${command}) 2>&1 | tee -a ${shellEscape(logFile)}`;
|
|
@@ -3989,7 +3990,10 @@ terminals2.post(
|
|
|
3989
3990
|
return c.json({ error: "tmux is not installed. Background terminals require tmux." }, 400);
|
|
3990
3991
|
}
|
|
3991
3992
|
const workingDirectory = body.cwd || session.workingDirectory;
|
|
3992
|
-
const result = await runBackground(body.command, workingDirectory, {
|
|
3993
|
+
const result = await runBackground(body.command, workingDirectory, {
|
|
3994
|
+
sessionId,
|
|
3995
|
+
name: body.name
|
|
3996
|
+
});
|
|
3993
3997
|
return c.json({
|
|
3994
3998
|
id: result.id,
|
|
3995
3999
|
name: body.name || null,
|
|
@@ -4013,7 +4017,7 @@ terminals2.get("/:sessionId/terminals", async (c) => {
|
|
|
4013
4017
|
const running = await isRunning(meta.id);
|
|
4014
4018
|
return {
|
|
4015
4019
|
id: meta.id,
|
|
4016
|
-
name: null,
|
|
4020
|
+
name: meta.name || null,
|
|
4017
4021
|
command: meta.command,
|
|
4018
4022
|
cwd: meta.cwd,
|
|
4019
4023
|
status: running ? "running" : "stopped",
|
|
@@ -4097,10 +4101,17 @@ terminals2.post(
|
|
|
4097
4101
|
"/:sessionId/terminals/:terminalId/write",
|
|
4098
4102
|
zValidator4("json", writeSchema),
|
|
4099
4103
|
async (c) => {
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
+
const terminalId = c.req.param("terminalId");
|
|
4105
|
+
const body = c.req.valid("json");
|
|
4106
|
+
const isRunning2 = await isRunning(terminalId);
|
|
4107
|
+
if (!isRunning2) {
|
|
4108
|
+
return c.json({ error: "Terminal is not running" }, 400);
|
|
4109
|
+
}
|
|
4110
|
+
const success = await sendInput(terminalId, body.input, { pressEnter: false });
|
|
4111
|
+
if (!success) {
|
|
4112
|
+
return c.json({ error: "Failed to write to terminal" }, 500);
|
|
4113
|
+
}
|
|
4114
|
+
return c.json({ success: true, written: body.input.length });
|
|
4104
4115
|
}
|
|
4105
4116
|
);
|
|
4106
4117
|
terminals2.post("/:sessionId/terminals/kill-all", async (c) => {
|
|
@@ -4109,12 +4120,12 @@ terminals2.post("/:sessionId/terminals/kill-all", async (c) => {
|
|
|
4109
4120
|
if (!session) {
|
|
4110
4121
|
return c.json({ error: "Session not found" }, 404);
|
|
4111
4122
|
}
|
|
4112
|
-
const
|
|
4123
|
+
const sessionTerminals = await listSessionTerminals(sessionId, session.workingDirectory);
|
|
4113
4124
|
let killed = 0;
|
|
4114
|
-
for (const
|
|
4115
|
-
const
|
|
4116
|
-
if (
|
|
4117
|
-
const success = await killTerminal(id);
|
|
4125
|
+
for (const terminal of sessionTerminals) {
|
|
4126
|
+
const isRunning2 = await isRunning(terminal.id);
|
|
4127
|
+
if (isRunning2) {
|
|
4128
|
+
const success = await killTerminal(terminal.id);
|
|
4118
4129
|
if (success) killed++;
|
|
4119
4130
|
}
|
|
4120
4131
|
}
|
|
@@ -5234,7 +5245,24 @@ async function runChat(options) {
|
|
|
5234
5245
|
try {
|
|
5235
5246
|
const running = await isServerRunning(baseUrl);
|
|
5236
5247
|
if (running) {
|
|
5237
|
-
const
|
|
5248
|
+
const webPortSequence = [6969, 6970, 6971, 6972, 6973, 6974, 6975, 6976, 6977, 6978];
|
|
5249
|
+
let actualWebPort = options.webPort || "6969";
|
|
5250
|
+
for (const port of webPortSequence) {
|
|
5251
|
+
try {
|
|
5252
|
+
const response = await fetch(`http://localhost:${port}/api/health`, {
|
|
5253
|
+
signal: AbortSignal.timeout(500)
|
|
5254
|
+
});
|
|
5255
|
+
if (response.ok) {
|
|
5256
|
+
const data = await response.json();
|
|
5257
|
+
if (data.name === "sparkecoder-web") {
|
|
5258
|
+
actualWebPort = String(port);
|
|
5259
|
+
break;
|
|
5260
|
+
}
|
|
5261
|
+
}
|
|
5262
|
+
} catch {
|
|
5263
|
+
}
|
|
5264
|
+
}
|
|
5265
|
+
const webUrl = `http://localhost:${actualWebPort}`;
|
|
5238
5266
|
console.log(`\u2714 Web UI: ${chalk.cyan(webUrl)}`);
|
|
5239
5267
|
} else {
|
|
5240
5268
|
if (options.autoStart === false) {
|
|
@@ -5244,7 +5272,7 @@ async function runChat(options) {
|
|
|
5244
5272
|
}
|
|
5245
5273
|
const spinner = ora("Starting server...").start();
|
|
5246
5274
|
try {
|
|
5247
|
-
await startServer({
|
|
5275
|
+
const serverResult = await startServer({
|
|
5248
5276
|
port: parseInt(options.port),
|
|
5249
5277
|
host: options.host,
|
|
5250
5278
|
configPath: options.config,
|
|
@@ -5256,7 +5284,7 @@ async function runChat(options) {
|
|
|
5256
5284
|
webPort: parseInt(options.webPort || "6969")
|
|
5257
5285
|
});
|
|
5258
5286
|
serverStartedByUs = true;
|
|
5259
|
-
const webUrl = `http://localhost:${options.webPort || "6969"}`;
|
|
5287
|
+
const webUrl = `http://localhost:${serverResult.webPort || options.webPort || "6969"}`;
|
|
5260
5288
|
spinner.succeed(`Web UI: ${chalk.cyan(webUrl)}`);
|
|
5261
5289
|
const cleanup = () => {
|
|
5262
5290
|
if (serverStartedByUs) {
|