orchestrating 0.1.28 → 0.1.30
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 +58 -1
- package/package.json +1 -1
package/bin/orch
CHANGED
|
@@ -4,7 +4,7 @@ import os from "os";
|
|
|
4
4
|
import http from "http";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import readline from "readline";
|
|
7
|
-
import { readFileSync, writeFileSync, mkdirSync, unlinkSync, existsSync } from "fs";
|
|
7
|
+
import { readFileSync, writeFileSync, mkdirSync, unlinkSync, existsSync, readdirSync, statSync } from "fs";
|
|
8
8
|
import { spawn, execSync } from "child_process";
|
|
9
9
|
import { randomUUID } from "crypto";
|
|
10
10
|
import { fileURLToPath } from "url";
|
|
@@ -767,6 +767,63 @@ if (adapter) {
|
|
|
767
767
|
broadcastPermissions();
|
|
768
768
|
}
|
|
769
769
|
|
|
770
|
+
// Load and forward prior conversation history when resuming with -c
|
|
771
|
+
if (adapterFlags.continue) {
|
|
772
|
+
try {
|
|
773
|
+
const cwdPath = process.cwd().replace(/\//g, "-").replace(/^-/, "-");
|
|
774
|
+
const claudeProjectDir = path.join(os.homedir(), ".claude", "projects", cwdPath);
|
|
775
|
+
const jsonlFiles = readdirSync(claudeProjectDir)
|
|
776
|
+
.filter((f) => f.endsWith(".jsonl"))
|
|
777
|
+
.map((f) => ({ name: f, mtime: statSync(path.join(claudeProjectDir, f)).mtimeMs }))
|
|
778
|
+
.sort((a, b) => b.mtime - a.mtime);
|
|
779
|
+
|
|
780
|
+
if (jsonlFiles.length > 0) {
|
|
781
|
+
const latest = readFileSync(path.join(claudeProjectDir, jsonlFiles[0].name), "utf-8");
|
|
782
|
+
const historyEvents = [];
|
|
783
|
+
let msgCounter = 0;
|
|
784
|
+
for (const line of latest.split("\n").filter(Boolean)) {
|
|
785
|
+
try {
|
|
786
|
+
const record = JSON.parse(line);
|
|
787
|
+
if (record.type === "user" && record.message?.content) {
|
|
788
|
+
const text = typeof record.message.content === "string"
|
|
789
|
+
? record.message.content
|
|
790
|
+
: record.message.content.filter((b) => b.type === "text").map((b) => b.text).join("\n");
|
|
791
|
+
if (text) {
|
|
792
|
+
historyEvents.push({ kind: "user_message", text });
|
|
793
|
+
}
|
|
794
|
+
} else if (record.message?.role === "assistant" && record.message?.content) {
|
|
795
|
+
const msgId = `hist-${msgCounter++}`;
|
|
796
|
+
historyEvents.push({ kind: "message_start", messageId: msgId });
|
|
797
|
+
for (const block of record.message.content) {
|
|
798
|
+
if (block.type === "text" && block.text) {
|
|
799
|
+
const blockId = `hist-text-${msgCounter++}`;
|
|
800
|
+
historyEvents.push({ kind: "text_delta", blockId, text: block.text });
|
|
801
|
+
} else if (block.type === "tool_use") {
|
|
802
|
+
const blockId = `hist-tool-${msgCounter++}`;
|
|
803
|
+
historyEvents.push({
|
|
804
|
+
kind: "tool_start", blockId,
|
|
805
|
+
toolName: block.name || "unknown",
|
|
806
|
+
toolId: block.id || blockId,
|
|
807
|
+
input: typeof block.input === "string" ? block.input : JSON.stringify(block.input || {}),
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
historyEvents.push({ kind: "message_end", messageId: msgId });
|
|
812
|
+
}
|
|
813
|
+
} catch {}
|
|
814
|
+
}
|
|
815
|
+
if (historyEvents.length > 0) {
|
|
816
|
+
process.stderr.write(`${DIM}[orch] Forwarding ${historyEvents.length} history events to dashboard${RESET}\n`);
|
|
817
|
+
// Prepend to eventHistory so they get replayed on reconnect too
|
|
818
|
+
eventHistory.unshift(...historyEvents);
|
|
819
|
+
while (eventHistory.length > MAX_EVENT_HISTORY) eventHistory.pop();
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
} catch (err) {
|
|
823
|
+
process.stderr.write(`${DIM}[orch] Could not load conversation history: ${err.message}${RESET}\n`);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
770
827
|
// Start the initial claude process
|
|
771
828
|
const initialArgs = adapter.buildArgs(prompt, adapterFlags);
|
|
772
829
|
if (yoloMode) {
|