forge-remote 0.1.19 → 0.1.21
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/package.json +1 -1
- package/src/session-manager.js +27 -5
package/package.json
CHANGED
package/src/session-manager.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Created by Daniel Wendel, CEO/Founder of Iron Forge Apps
|
|
4
4
|
|
|
5
5
|
import { getDb, FieldValue } from "./firebase.js";
|
|
6
|
-
import { readdir, realpath } from "node:fs/promises";
|
|
6
|
+
import { readdir, realpath, mkdir } from "node:fs/promises";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import { spawn, execSync } from "child_process";
|
|
@@ -490,8 +490,14 @@ export async function startNewSession(desktopId, payload) {
|
|
|
490
490
|
);
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
-
const {
|
|
494
|
-
|
|
493
|
+
const {
|
|
494
|
+
prompt,
|
|
495
|
+
projectPath,
|
|
496
|
+
model,
|
|
497
|
+
webhookMeta,
|
|
498
|
+
allowedTools,
|
|
499
|
+
createIfMissing,
|
|
500
|
+
} = payload || {};
|
|
495
501
|
const db = getDb();
|
|
496
502
|
const resolvedModel = model || "sonnet";
|
|
497
503
|
const resolvedPath = projectPath || process.cwd();
|
|
@@ -503,7 +509,12 @@ export async function startNewSession(desktopId, payload) {
|
|
|
503
509
|
try {
|
|
504
510
|
await realpath(resolvedPath);
|
|
505
511
|
} catch {
|
|
506
|
-
|
|
512
|
+
if (createIfMissing) {
|
|
513
|
+
log.info(`Creating project directory: ${resolvedPath}`);
|
|
514
|
+
await mkdir(resolvedPath, { recursive: true });
|
|
515
|
+
} else {
|
|
516
|
+
throw new Error(`projectPath does not exist: ${resolvedPath}`);
|
|
517
|
+
}
|
|
507
518
|
}
|
|
508
519
|
|
|
509
520
|
const projectName = resolvedPath.split("/").pop();
|
|
@@ -923,6 +934,18 @@ async function runClaudeProcess(sessionId, prompt) {
|
|
|
923
934
|
`Process exited — code: ${code}, signal: ${signal}, PID: ${claudeProcess.pid}`,
|
|
924
935
|
);
|
|
925
936
|
|
|
937
|
+
// If session.process was already set to null, this was an intentional
|
|
938
|
+
// interruption (e.g., sendFollowUpPrompt killed it to send a new prompt).
|
|
939
|
+
// Skip all cleanup — the new prompt handler will take over.
|
|
940
|
+
const sess = activeSessions.get(sessionId);
|
|
941
|
+
if (sess && sess.process === null) {
|
|
942
|
+
log.session(
|
|
943
|
+
sessionId,
|
|
944
|
+
"Interrupted intentionally — skipping close cleanup",
|
|
945
|
+
);
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
|
|
926
949
|
// Flush any remaining data in buffers.
|
|
927
950
|
if (stdoutBuffer.trim()) {
|
|
928
951
|
log.claudeOutput(sessionId, `[flush] ${stdoutBuffer.trim()}`);
|
|
@@ -940,7 +963,6 @@ async function runClaudeProcess(sessionId, prompt) {
|
|
|
940
963
|
});
|
|
941
964
|
}
|
|
942
965
|
|
|
943
|
-
const sess = activeSessions.get(sessionId);
|
|
944
966
|
if (sess) sess.process = null; // Clear process so follow-ups can spawn.
|
|
945
967
|
|
|
946
968
|
if (code === 0) {
|