orchestrating 0.1.13 → 0.1.15
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/bin/orch +34 -2
- package/package.json +1 -1
package/bin/orch
CHANGED
|
@@ -213,11 +213,12 @@ if (commandArgs.length === 0) {
|
|
|
213
213
|
|
|
214
214
|
const command = commandArgs[0];
|
|
215
215
|
const spawnArgs = commandArgs.slice(1);
|
|
216
|
-
|
|
216
|
+
let sessionId;
|
|
217
217
|
const hostname = os.hostname();
|
|
218
218
|
const serverUrl = process.env.ORC_URL || process.env.CAST_URL || "wss://api.orchestrat.ing/ws";
|
|
219
219
|
const authToken = getAuthToken();
|
|
220
|
-
const
|
|
220
|
+
const cwdFolder = path.basename(process.cwd());
|
|
221
|
+
const effectiveLabel = label || cwdFolder || commandArgs.join(" ");
|
|
221
222
|
|
|
222
223
|
// Warn if no auth and connecting to remote server
|
|
223
224
|
if (!authToken && !serverUrl.includes("localhost") && !serverUrl.includes("127.0.0.1")) {
|
|
@@ -323,6 +324,24 @@ if (adapter) {
|
|
|
323
324
|
}
|
|
324
325
|
const prompt = promptParts.join(" ") || (adapterFlags.continue ? "continue" : "hello");
|
|
325
326
|
|
|
327
|
+
// Session reuse: persist session ID per cwd so `-c` reconnects the same dashboard session
|
|
328
|
+
const SESSION_FILE = path.join(process.cwd(), ".orch-session");
|
|
329
|
+
if (adapterFlags.continue) {
|
|
330
|
+
try {
|
|
331
|
+
const stored = readFileSync(SESSION_FILE, "utf-8").trim();
|
|
332
|
+
if (stored) {
|
|
333
|
+
sessionId = stored;
|
|
334
|
+
process.stderr.write(`${DIM}[orch] Reusing session ${sessionId.slice(0, 8)}…${RESET}\n`);
|
|
335
|
+
}
|
|
336
|
+
} catch {}
|
|
337
|
+
}
|
|
338
|
+
if (!sessionId) {
|
|
339
|
+
sessionId = randomUUID();
|
|
340
|
+
}
|
|
341
|
+
try {
|
|
342
|
+
writeFileSync(SESSION_FILE, sessionId + "\n");
|
|
343
|
+
} catch {}
|
|
344
|
+
|
|
326
345
|
// Confirmation-type tools — these need "yes" response, not permission grants
|
|
327
346
|
const CONFIRMATION_TOOLS = new Set(["ExitPlanMode", "EnterPlanMode"]);
|
|
328
347
|
|
|
@@ -518,11 +537,21 @@ if (adapter) {
|
|
|
518
537
|
const newMode = msg.mode;
|
|
519
538
|
yoloMode = newMode === "yolo";
|
|
520
539
|
process.stderr.write(`${BOLD}[mode] ${yoloMode ? "YOLO" : "Normal"}${RESET}\n`);
|
|
540
|
+
} else if (msg.type === "stop_session") {
|
|
541
|
+
process.stderr.write(`${RED}[orch] Stopped from dashboard${RESET}\n`);
|
|
542
|
+
exitRequested = true;
|
|
543
|
+
if (childRunning) {
|
|
544
|
+
child.kill("SIGINT");
|
|
545
|
+
} else {
|
|
546
|
+
cleanup();
|
|
547
|
+
process.exit(0);
|
|
548
|
+
}
|
|
521
549
|
}
|
|
522
550
|
};
|
|
523
551
|
|
|
524
552
|
} else {
|
|
525
553
|
// ======== PTY MODE (existing behavior for bash, etc.) ========
|
|
554
|
+
sessionId = randomUUID();
|
|
526
555
|
const cols = process.stdout.columns || 80;
|
|
527
556
|
const rows = process.stdout.rows || 24;
|
|
528
557
|
const shell = process.env.SHELL || "/bin/zsh";
|
|
@@ -599,6 +628,9 @@ if (adapter) {
|
|
|
599
628
|
child.stdin.write(Buffer.from(msg.data, "base64"));
|
|
600
629
|
} else if (msg.type === "resize" && msg.cols && msg.rows) {
|
|
601
630
|
child.stdin.write(`\x1b]R;${msg.cols};${msg.rows}\x07`);
|
|
631
|
+
} else if (msg.type === "stop_session") {
|
|
632
|
+
process.stderr.write(`${RED}[orch] Stopped from dashboard${RESET}\n`);
|
|
633
|
+
child.kill("SIGINT");
|
|
602
634
|
}
|
|
603
635
|
};
|
|
604
636
|
}
|