openfox 1.5.2 → 1.5.3

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.
Files changed (32) hide show
  1. package/dist/agent-defaults/builder.agent.md +1 -0
  2. package/dist/agent-defaults/planner.agent.md +1 -0
  3. package/dist/{auto-compaction-MNK2FZ6E.js → auto-compaction-DDQPVS7Z.js} +6 -4
  4. package/dist/{chat-handler-Y7KR2RLL.js → chat-handler-S3LRWAEV.js} +10 -8
  5. package/dist/chunk-574HZVLE.js +149 -0
  6. package/dist/{chunk-UBWZDTZ4.js → chunk-AL7KUHBF.js} +51 -14
  7. package/dist/{chunk-S4QKTRGJ.js → chunk-EBOKO2PW.js} +2 -2
  8. package/dist/chunk-JHL5ZO3K.js +156 -0
  9. package/dist/{chunk-6PV24MJB.js → chunk-KUHCFENT.js} +2 -2
  10. package/dist/{chunk-GXVA5W7Q.js → chunk-QJIHXG4P.js} +165 -4
  11. package/dist/{chunk-F7PUG5WA.js → chunk-TWUJFSH6.js} +3 -3
  12. package/dist/{chunk-TPT6HP4H.js → chunk-XQQ2BRJA.js} +1 -1
  13. package/dist/cli/dev.js +1 -1
  14. package/dist/cli/index.js +1 -1
  15. package/dist/manager-TMIDRUVA.js +20 -0
  16. package/dist/{orchestrator-QGFC5QB6.js → orchestrator-6VETL3Z7.js} +7 -5
  17. package/dist/package.json +1 -1
  18. package/dist/{processor-BFTXIEDV.js → processor-HYEPZECF.js} +4 -4
  19. package/dist/{protocol-WQENDK72.js → protocol-ODKD7QJO.js} +3 -3
  20. package/dist/{protocol-CLWtTnMd.d.ts → protocol-vX_YbJXE.d.ts} +40 -2
  21. package/dist/{serve-JJLKBQXS.js → serve-DCCIXC4Q.js} +9 -7
  22. package/dist/server/index.d.ts +1 -1
  23. package/dist/server/index.js +7 -5
  24. package/dist/shared/index.d.ts +2 -2
  25. package/dist/shared/index.js +1 -1
  26. package/dist/store-2IF3ZSLD.js +33 -0
  27. package/dist/{tools-MY4TPRP4.js → tools-XSK3J4II.js} +6 -4
  28. package/dist/web/assets/{index-xs6xUYKs.js → index-CglBHzrV.js} +62 -62
  29. package/dist/web/assets/{index-BnJ4NNAw.css → index-DteeMapx.css} +1 -1
  30. package/dist/web/index.html +2 -2
  31. package/dist/web/sw.js +1 -1
  32. package/package.json +1 -1
@@ -16,6 +16,7 @@ allowedTools:
16
16
  - call_sub_agent
17
17
  - load_skill
18
18
  - dev_server
19
+ - background_process
19
20
  - step_done
20
21
  ---
21
22
 
@@ -11,6 +11,7 @@ allowedTools:
11
11
  - criterion:add,get,update,remove
12
12
  - call_sub_agent
13
13
  - load_skill
14
+ - background_process
14
15
  ---
15
16
 
16
17
  # Plan Mode
@@ -2,16 +2,18 @@ import {
2
2
  maybeAutoCompactContext,
3
3
  performManualContextCompaction,
4
4
  resolveCompactionStatsIdentity
5
- } from "./chunk-GXVA5W7Q.js";
5
+ } from "./chunk-QJIHXG4P.js";
6
+ import "./chunk-JHL5ZO3K.js";
7
+ import "./chunk-574HZVLE.js";
6
8
  import "./chunk-XFXOSPYH.js";
7
9
  import "./chunk-NW7PIZH3.js";
8
10
  import "./chunk-WQ4W5H6A.js";
9
- import "./chunk-S4QKTRGJ.js";
11
+ import "./chunk-EBOKO2PW.js";
10
12
  import "./chunk-22CTURMH.js";
11
13
  import "./chunk-7IOZFJBW.js";
12
14
  import "./chunk-XKFPU2FA.js";
13
15
  import "./chunk-3EHGGBWE.js";
14
- import "./chunk-TPT6HP4H.js";
16
+ import "./chunk-XQQ2BRJA.js";
15
17
  import "./chunk-R4HADRYO.js";
16
18
  import "./chunk-TVQOONDR.js";
17
19
  import "./chunk-PNBH3RAX.js";
@@ -20,4 +22,4 @@ export {
20
22
  performManualContextCompaction,
21
23
  resolveCompactionStatsIdentity
22
24
  };
23
- //# sourceMappingURL=auto-compaction-MNK2FZ6E.js.map
25
+ //# sourceMappingURL=auto-compaction-DDQPVS7Z.js.map
@@ -1,11 +1,13 @@
1
- import {
2
- runChatTurn
3
- } from "./chunk-F7PUG5WA.js";
4
- import "./chunk-GXVA5W7Q.js";
5
1
  import {
6
2
  generateSessionName,
7
3
  needsNameGeneration
8
4
  } from "./chunk-QDEKU5RL.js";
5
+ import {
6
+ runChatTurn
7
+ } from "./chunk-TWUJFSH6.js";
8
+ import "./chunk-QJIHXG4P.js";
9
+ import "./chunk-JHL5ZO3K.js";
10
+ import "./chunk-574HZVLE.js";
9
11
  import "./chunk-XFXOSPYH.js";
10
12
  import {
11
13
  getEventStore,
@@ -21,12 +23,12 @@ import {
21
23
  createPhaseChangedMessage,
22
24
  createSessionRunningMessage,
23
25
  createSessionStateMessage
24
- } from "./chunk-S4QKTRGJ.js";
26
+ } from "./chunk-EBOKO2PW.js";
25
27
  import "./chunk-22CTURMH.js";
26
28
  import "./chunk-7IOZFJBW.js";
27
29
  import "./chunk-XKFPU2FA.js";
28
30
  import "./chunk-3EHGGBWE.js";
29
- import "./chunk-TPT6HP4H.js";
31
+ import "./chunk-XQQ2BRJA.js";
30
32
  import "./chunk-R4HADRYO.js";
31
33
  import "./chunk-TVQOONDR.js";
32
34
  import {
@@ -59,7 +61,7 @@ async function startChatSession(sessionId, content, deps, options) {
59
61
  sessionManager.setRunning(sessionId, true);
60
62
  broadcastForSession(sessionId, createSessionRunningMessage(true));
61
63
  try {
62
- const { maybeAutoCompactContext } = await import("./auto-compaction-MNK2FZ6E.js");
64
+ const { maybeAutoCompactContext } = await import("./auto-compaction-DDQPVS7Z.js");
63
65
  await maybeAutoCompactContext({
64
66
  sessionManager,
65
67
  sessionId,
@@ -198,4 +200,4 @@ export {
198
200
  startChatSession,
199
201
  stopSessionExecution
200
202
  };
201
- //# sourceMappingURL=chat-handler-Y7KR2RLL.js.map
203
+ //# sourceMappingURL=chat-handler-S3LRWAEV.js.map
@@ -0,0 +1,149 @@
1
+ // src/server/tools/background-process/store.ts
2
+ var MAX_PER_SESSION = 5;
3
+ var processesBySession = /* @__PURE__ */ new Map();
4
+ var logsByProcess = /* @__PURE__ */ new Map();
5
+ function getMaxPerSession() {
6
+ return MAX_PER_SESSION;
7
+ }
8
+ function getProcess(processId, sessionId) {
9
+ return processesBySession.get(sessionId)?.get(processId);
10
+ }
11
+ function getSessionProcesses(sessionId) {
12
+ const sessionProcesses = processesBySession.get(sessionId);
13
+ if (!sessionProcesses) return [];
14
+ return Array.from(sessionProcesses.values());
15
+ }
16
+ function getSessionProcessCount(sessionId) {
17
+ return getSessionProcesses(sessionId).filter((p) => p.status !== "exited").length;
18
+ }
19
+ function createProcess(sessionId, name, command, cwd) {
20
+ const count = getSessionProcessCount(sessionId);
21
+ if (count >= MAX_PER_SESSION) {
22
+ return null;
23
+ }
24
+ const process2 = {
25
+ id: crypto.randomUUID(),
26
+ sessionId,
27
+ name,
28
+ command,
29
+ cwd,
30
+ pid: null,
31
+ status: "pending",
32
+ exitCode: null,
33
+ createdAt: Date.now(),
34
+ startedAt: null,
35
+ endedAt: null
36
+ };
37
+ if (!processesBySession.has(sessionId)) {
38
+ processesBySession.set(sessionId, /* @__PURE__ */ new Map());
39
+ }
40
+ processesBySession.get(sessionId).set(process2.id, process2);
41
+ logsByProcess.set(process2.id, []);
42
+ return process2;
43
+ }
44
+ function startProcess(processId, sessionId, pid) {
45
+ const process2 = getProcess(processId, sessionId);
46
+ if (!process2) return void 0;
47
+ process2.pid = pid;
48
+ process2.status = "running";
49
+ process2.startedAt = Date.now();
50
+ return process2;
51
+ }
52
+ function updateStatus(processId, sessionId, status, exitCode) {
53
+ const process2 = getProcess(processId, sessionId);
54
+ if (!process2) return void 0;
55
+ process2.status = status;
56
+ if (exitCode !== void 0) {
57
+ process2.exitCode = exitCode;
58
+ }
59
+ if (status === "exited" || status === "stopping") {
60
+ process2.endedAt = Date.now();
61
+ }
62
+ return process2;
63
+ }
64
+ function removeProcess(processId, sessionId) {
65
+ const sessionProcesses = processesBySession.get(sessionId);
66
+ if (!sessionProcesses) return false;
67
+ const deleted = sessionProcesses.delete(processId);
68
+ logsByProcess.delete(processId);
69
+ return deleted;
70
+ }
71
+ function appendLog(processId, content, stream = "stdout") {
72
+ const logs = logsByProcess.get(processId);
73
+ if (!logs) return;
74
+ const offset = logs.length;
75
+ logs.push({
76
+ offset,
77
+ content,
78
+ timestamp: Date.now(),
79
+ stream
80
+ });
81
+ }
82
+ function getLogs(processId, offset = 0, limit) {
83
+ const logs = logsByProcess.get(processId) ?? [];
84
+ const start = Math.min(offset, logs.length);
85
+ const end = limit !== void 0 ? Math.min(start + limit, logs.length) : logs.length;
86
+ return logs.slice(start, end);
87
+ }
88
+ function getLogsPaginated(processId, since = 0, maxLines = 500) {
89
+ const logs = logsByProcess.get(processId) ?? [];
90
+ const totalLines = logs.length;
91
+ const filteredLogs = logs.filter((_, index) => index >= since);
92
+ const slicedLogs = filteredLogs.slice(0, maxLines);
93
+ const lastLine = slicedLogs[slicedLogs.length - 1];
94
+ const nextOffset = lastLine ? lastLine.offset + 1 : totalLines;
95
+ const hasMore = slicedLogs.length < filteredLogs.length;
96
+ return {
97
+ lines: slicedLogs,
98
+ totalLines,
99
+ nextOffset,
100
+ hasMore
101
+ };
102
+ }
103
+ function clearLogs(processId) {
104
+ logsByProcess.delete(processId);
105
+ logsByProcess.set(processId, []);
106
+ }
107
+ function getProcessById(processId) {
108
+ for (const sessionProcesses of processesBySession.values()) {
109
+ const proc = sessionProcesses.get(processId);
110
+ if (proc) return proc;
111
+ }
112
+ return void 0;
113
+ }
114
+ function cleanupAllProcesses() {
115
+ for (const sessionProcesses of processesBySession.values()) {
116
+ for (const proc of sessionProcesses.values()) {
117
+ if (proc.status === "running" && proc.pid) {
118
+ try {
119
+ process.kill(-proc.pid, "SIGTERM");
120
+ } catch {
121
+ try {
122
+ process.kill(proc.pid, "SIGTERM");
123
+ } catch (_) {
124
+ }
125
+ }
126
+ }
127
+ }
128
+ }
129
+ processesBySession.clear();
130
+ logsByProcess.clear();
131
+ }
132
+
133
+ export {
134
+ getMaxPerSession,
135
+ getProcess,
136
+ getSessionProcesses,
137
+ getSessionProcessCount,
138
+ createProcess,
139
+ startProcess,
140
+ updateStatus,
141
+ removeProcess,
142
+ appendLog,
143
+ getLogs,
144
+ getLogsPaginated,
145
+ clearLogs,
146
+ getProcessById,
147
+ cleanupAllProcesses
148
+ };
149
+ //# sourceMappingURL=chunk-574HZVLE.js.map
@@ -1,8 +1,12 @@
1
+ import {
2
+ generateSessionName,
3
+ needsNameGeneration
4
+ } from "./chunk-QDEKU5RL.js";
1
5
  import {
2
6
  createVerifierNudgeConfig,
3
7
  runBuilderTurn,
4
8
  runChatTurn
5
- } from "./chunk-F7PUG5WA.js";
9
+ } from "./chunk-TWUJFSH6.js";
6
10
  import {
7
11
  TurnMetrics,
8
12
  agentExists,
@@ -40,11 +44,10 @@ import {
40
44
  saveSkill,
41
45
  setSkillEnabled,
42
46
  skillExists
43
- } from "./chunk-GXVA5W7Q.js";
47
+ } from "./chunk-QJIHXG4P.js";
44
48
  import {
45
- generateSessionName,
46
- needsNameGeneration
47
- } from "./chunk-QDEKU5RL.js";
49
+ onProcessEvent
50
+ } from "./chunk-JHL5ZO3K.js";
48
51
  import {
49
52
  createProviderManager,
50
53
  parseDefaultModelSelection
@@ -103,7 +106,7 @@ import {
103
106
  parseClientMessage,
104
107
  serializeServerMessage,
105
108
  storedEventToServerMessage
106
- } from "./chunk-S4QKTRGJ.js";
109
+ } from "./chunk-EBOKO2PW.js";
107
110
  import {
108
111
  EventEmitter,
109
112
  cancelQuestionsForSession,
@@ -120,7 +123,7 @@ import {
120
123
  } from "./chunk-QY7BMXWT.js";
121
124
  import {
122
125
  createServerMessage
123
- } from "./chunk-TPT6HP4H.js";
126
+ } from "./chunk-XQQ2BRJA.js";
124
127
  import {
125
128
  getGlobalConfigDir
126
129
  } from "./chunk-R4HADRYO.js";
@@ -2488,6 +2491,17 @@ function createWebSocketServer(httpServer, config, getLLMClient, getActiveProvid
2488
2491
  errorMessage
2489
2492
  }));
2490
2493
  });
2494
+ onProcessEvent((_processId, msg) => {
2495
+ const sessionId = msg.sessionId;
2496
+ if (!sessionId) return;
2497
+ for (const [clientWs, client] of clients) {
2498
+ if (client.activeSessionId === sessionId || client.subscribedSessions.has(sessionId) || client.eventStoreSubscriptions.has(sessionId)) {
2499
+ if (clientWs.readyState === WebSocket2.OPEN) {
2500
+ clientWs.send(serializeServerMessage(msg));
2501
+ }
2502
+ }
2503
+ }
2504
+ });
2491
2505
  wss.on("connection", async (ws, req) => {
2492
2506
  const url = new URL(req.url || "/", `http://${req.headers.host}`);
2493
2507
  const token = url.searchParams.get("token");
@@ -5853,14 +5867,14 @@ async function createServerHandle(config) {
5853
5867
  if (!callId || approved === void 0) {
5854
5868
  return res.status(400).json({ error: "callId and approved are required" });
5855
5869
  }
5856
- const { providePathConfirmation: providePathConfirmation2 } = await import("./tools-MY4TPRP4.js");
5870
+ const { providePathConfirmation: providePathConfirmation2 } = await import("./tools-XSK3J4II.js");
5857
5871
  const result = providePathConfirmation2(callId, approved, alwaysAllow);
5858
5872
  if (!result.found) {
5859
5873
  return res.status(404).json({ error: "No pending path confirmation with that ID" });
5860
5874
  }
5861
5875
  const { getEventStore: getEventStore2 } = await import("./events-B7S4U4DB.js");
5862
5876
  const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2, foldPendingConfirmations: foldPendingConfirmations2 } = await import("./folding-NZYOXNKK.js");
5863
- const { createSessionStateMessage: createSessionStateMessage2 } = await import("./protocol-WQENDK72.js");
5877
+ const { createSessionStateMessage: createSessionStateMessage2 } = await import("./protocol-ODKD7QJO.js");
5864
5878
  const eventStore = getEventStore2();
5865
5879
  const events = eventStore.getEvents(sessionId);
5866
5880
  const messages = buildMessagesFromStoredEvents2(events);
@@ -5878,7 +5892,7 @@ async function createServerHandle(config) {
5878
5892
  if (!callId || !answer) {
5879
5893
  return res.status(400).json({ error: "callId and answer are required" });
5880
5894
  }
5881
- const { provideAnswer: provideAnswer2 } = await import("./tools-MY4TPRP4.js");
5895
+ const { provideAnswer: provideAnswer2 } = await import("./tools-XSK3J4II.js");
5882
5896
  const found = provideAnswer2(callId, answer);
5883
5897
  if (!found) {
5884
5898
  return res.status(404).json({ error: "No pending question with that ID" });
@@ -5914,8 +5928,8 @@ async function createServerHandle(config) {
5914
5928
  if (!session) {
5915
5929
  return res.status(404).json({ error: "Session not found" });
5916
5930
  }
5917
- const { stopSessionExecution } = await import("./chat-handler-Y7KR2RLL.js");
5918
- const { cancelQuestionsForSession: cancelQuestionsForSession2, cancelPathConfirmationsForSession: cancelPathConfirmationsForSession2 } = await import("./tools-MY4TPRP4.js");
5931
+ const { stopSessionExecution } = await import("./chat-handler-S3LRWAEV.js");
5932
+ const { cancelQuestionsForSession: cancelQuestionsForSession2, cancelPathConfirmationsForSession: cancelPathConfirmationsForSession2 } = await import("./tools-XSK3J4II.js");
5919
5933
  stopSessionExecution(sessionId, sessionManager);
5920
5934
  abortSession(sessionId);
5921
5935
  cancelQuestionsForSession2(sessionId, "Session stopped by user");
@@ -6201,6 +6215,27 @@ async function createServerHandle(config) {
6201
6215
  app.use("/api/workflows", createWorkflowRoutes(configDir, config));
6202
6216
  app.use("/api/dev-server", createDevServerRoutes());
6203
6217
  app.use("/api/terminals", createTerminalRoutes());
6218
+ app.get("/api/sessions/:id/background-processes", async (req, res) => {
6219
+ const { getSessionProcesses } = await import("./manager-TMIDRUVA.js");
6220
+ const sessionId = req.params.id;
6221
+ const processes = getSessionProcesses(sessionId);
6222
+ res.json({ processes });
6223
+ });
6224
+ app.post("/api/sessions/:id/background-process/:processId/stop", async (req, res) => {
6225
+ const { stopProcess } = await import("./manager-TMIDRUVA.js");
6226
+ const sessionId = req.params.id;
6227
+ const processId = req.params.processId;
6228
+ const session = sessionManager.getSession(sessionId);
6229
+ if (!session) {
6230
+ return res.status(404).json({ error: "Session not found" });
6231
+ }
6232
+ try {
6233
+ await stopProcess(processId, sessionId);
6234
+ res.json({ success: true });
6235
+ } catch (err) {
6236
+ res.status(500).json({ error: err instanceof Error ? err.message : "Failed to stop process" });
6237
+ }
6238
+ });
6204
6239
  const { getCurrentBranch } = await import("./branch.api-XADFZZAA.js");
6205
6240
  app.get("/api/branch", async (req, res) => {
6206
6241
  await getCurrentBranch(req, res);
@@ -6341,7 +6376,7 @@ async function createServerHandle(config) {
6341
6376
  providerManager
6342
6377
  );
6343
6378
  const wss = wssExports.wss;
6344
- const { QueueProcessor } = await import("./processor-BFTXIEDV.js");
6379
+ const { QueueProcessor } = await import("./processor-HYEPZECF.js");
6345
6380
  const queueProcessor = new QueueProcessor({
6346
6381
  sessionManager,
6347
6382
  providerManager,
@@ -6379,6 +6414,8 @@ async function createServerHandle(config) {
6379
6414
  logger.info("Shutting down...");
6380
6415
  void (async () => {
6381
6416
  await devServerManager.stopAll();
6417
+ const { cleanupAllProcesses } = await import("./store-2IF3ZSLD.js");
6418
+ cleanupAllProcesses();
6382
6419
  viteServer?.close();
6383
6420
  for (const client of wss.clients) {
6384
6421
  client.terminate();
@@ -6411,4 +6448,4 @@ export {
6411
6448
  createServerHandle,
6412
6449
  createServer
6413
6450
  };
6414
- //# sourceMappingURL=chunk-UBWZDTZ4.js.map
6451
+ //# sourceMappingURL=chunk-AL7KUHBF.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createServerMessage,
3
3
  isClientMessage
4
- } from "./chunk-TPT6HP4H.js";
4
+ } from "./chunk-XQQ2BRJA.js";
5
5
 
6
6
  // src/server/ws/protocol.ts
7
7
  function enrichMessagesWithToolResults(messages) {
@@ -340,4 +340,4 @@ export {
340
340
  isQueueCancelPayload,
341
341
  storedEventToServerMessage
342
342
  };
343
- //# sourceMappingURL=chunk-S4QKTRGJ.js.map
343
+ //# sourceMappingURL=chunk-EBOKO2PW.js.map
@@ -0,0 +1,156 @@
1
+ import {
2
+ appendLog,
3
+ createProcess,
4
+ getLogsPaginated,
5
+ getProcess,
6
+ getSessionProcesses,
7
+ removeProcess,
8
+ startProcess,
9
+ updateStatus
10
+ } from "./chunk-574HZVLE.js";
11
+
12
+ // src/server/tools/background-process/manager.ts
13
+ import { spawn } from "child_process";
14
+ var STOP_SIGNAL_TIMEOUT = 5e3;
15
+ var listeners = /* @__PURE__ */ new Set();
16
+ function onProcessEvent(callback) {
17
+ listeners.add(callback);
18
+ return () => {
19
+ listeners.delete(callback);
20
+ };
21
+ }
22
+ function emitProcessEvent(processId, msg) {
23
+ for (const listener of listeners) {
24
+ listener(processId, msg);
25
+ }
26
+ }
27
+ function createProcess2(sessionId, name, command, cwd, timeout) {
28
+ const process2 = createProcess(sessionId, name, command, cwd);
29
+ if (!process2) return null;
30
+ if (timeout && timeout > 0) {
31
+ setTimeout(() => {
32
+ const p = getProcess(process2.id, sessionId);
33
+ if (p && p.status === "running") {
34
+ stopProcess(process2.id, sessionId);
35
+ }
36
+ }, timeout);
37
+ }
38
+ return process2;
39
+ }
40
+ function startProcessCommand(processId, sessionId, command, cwd) {
41
+ const proc = startProcess(processId, sessionId, 0);
42
+ if (!proc) return null;
43
+ const child = spawn("sh", ["-c", command], {
44
+ cwd,
45
+ env: { ...process.env, FORCE_COLOR: "1" },
46
+ stdio: ["ignore", "pipe", "pipe"],
47
+ detached: true
48
+ });
49
+ proc.pid = child.pid ?? null;
50
+ updateStatus(processId, sessionId, "running");
51
+ emitProcessEvent(processId, {
52
+ type: "backgroundProcess.started",
53
+ payload: { processId, name: proc.name, pid: child.pid ?? null, status: "running" },
54
+ sessionId
55
+ });
56
+ child.stdout?.on("data", (chunk) => {
57
+ const text = chunk.toString();
58
+ appendLog(processId, text, "stdout");
59
+ emitProcessEvent(processId, {
60
+ type: "backgroundProcess.output",
61
+ payload: { processId, stream: "stdout", content: text },
62
+ sessionId
63
+ });
64
+ });
65
+ child.stderr?.on("data", (chunk) => {
66
+ const text = chunk.toString();
67
+ appendLog(processId, text, "stderr");
68
+ emitProcessEvent(processId, {
69
+ type: "backgroundProcess.output",
70
+ payload: { processId, stream: "stderr", content: text },
71
+ sessionId
72
+ });
73
+ });
74
+ child.on("exit", (code, signal) => {
75
+ updateStatus(processId, sessionId, "exited", code ?? (signal ? 1 : null));
76
+ emitProcessEvent(processId, {
77
+ type: "backgroundProcess.exited",
78
+ payload: { processId, exitCode: code ?? (signal ? 1 : null) },
79
+ sessionId
80
+ });
81
+ });
82
+ child.on("error", (err) => {
83
+ appendLog(processId, `Error: ${err.message}
84
+ `, "stderr");
85
+ updateStatus(processId, sessionId, "exited", 1);
86
+ emitProcessEvent(processId, {
87
+ type: "backgroundProcess.exited",
88
+ payload: { processId, exitCode: 1 },
89
+ sessionId
90
+ });
91
+ });
92
+ return child.pid ?? null;
93
+ }
94
+ async function stopProcess(processId, sessionId) {
95
+ const proc = getProcess(processId, sessionId);
96
+ if (!proc || proc.status !== "running" || !proc.pid) {
97
+ return;
98
+ }
99
+ updateStatus(processId, sessionId, "stopping");
100
+ const pid = proc.pid;
101
+ try {
102
+ try {
103
+ process.kill(-pid, "SIGTERM");
104
+ } catch {
105
+ process.kill(pid, "SIGTERM");
106
+ }
107
+ await new Promise((resolve) => {
108
+ setTimeout(() => {
109
+ try {
110
+ process.kill(-pid, "SIGKILL");
111
+ } catch {
112
+ try {
113
+ process.kill(pid, "SIGKILL");
114
+ } catch (_) {
115
+ }
116
+ }
117
+ resolve();
118
+ }, STOP_SIGNAL_TIMEOUT);
119
+ });
120
+ updateStatus(processId, sessionId, "exited", null);
121
+ emitProcessEvent(processId, {
122
+ type: "backgroundProcess.removed",
123
+ payload: { processId },
124
+ sessionId
125
+ });
126
+ removeProcess(processId, sessionId);
127
+ } catch (_) {
128
+ updateStatus(processId, sessionId, "exited", 1);
129
+ emitProcessEvent(processId, {
130
+ type: "backgroundProcess.removed",
131
+ payload: { processId },
132
+ sessionId
133
+ });
134
+ removeProcess(processId, sessionId);
135
+ }
136
+ }
137
+ function getProcessStatus(processId, sessionId) {
138
+ return getProcess(processId, sessionId);
139
+ }
140
+ function getSessionProcesses2(sessionId) {
141
+ return getSessionProcesses(sessionId);
142
+ }
143
+ function getProcessLogs(processId, since = 0, maxLines) {
144
+ return getLogsPaginated(processId, since, maxLines);
145
+ }
146
+
147
+ export {
148
+ onProcessEvent,
149
+ createProcess2 as createProcess,
150
+ startProcessCommand,
151
+ stopProcess,
152
+ getProcessStatus,
153
+ getSessionProcesses2 as getSessionProcesses,
154
+ getProcessLogs
155
+ };
156
+ //# sourceMappingURL=chunk-JHL5ZO3K.js.map
@@ -154,7 +154,7 @@ async function runCli(options) {
154
154
  if (!configExists) {
155
155
  await runNetworkSetup(mode);
156
156
  }
157
- const { runServe } = await import("./serve-JJLKBQXS.js");
157
+ const { runServe } = await import("./serve-DCCIXC4Q.js");
158
158
  await runServe({
159
159
  mode,
160
160
  port: values.port ? parseInt(values.port) : void 0,
@@ -167,4 +167,4 @@ async function runCli(options) {
167
167
  export {
168
168
  runCli
169
169
  };
170
- //# sourceMappingURL=chunk-6PV24MJB.js.map
170
+ //# sourceMappingURL=chunk-KUHCFENT.js.map