orchestrating 0.1.27 → 0.1.29

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 (2) hide show
  1. package/bin/orch +62 -1
  2. 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";
@@ -248,6 +248,7 @@ async function handleDaemon(projectsDir) {
248
248
  process.stderr.write(`${DIM}${PREFIX} Tip: Use 'nohup orch daemon &' to run in background${RESET}\n`);
249
249
 
250
250
  let reconnecting = false;
251
+ const recentRequests = new Set();
251
252
 
252
253
  function scheduleReconnect(delaySec) {
253
254
  if (reconnecting) return;
@@ -330,6 +331,11 @@ async function handleDaemon(projectsDir) {
330
331
 
331
332
  if (msg.type === "start_session") {
332
333
  const { requestId, command: cmd, args: cmdArgs, cwd, label: lbl, yolo } = msg;
334
+ // Dedup: ignore if we already handled this request
335
+ if (recentRequests.has(requestId)) return;
336
+ recentRequests.add(requestId);
337
+ setTimeout(() => recentRequests.delete(requestId), 30_000);
338
+
333
339
  const cmdStr = [cmd, ...cmdArgs].join(" ");
334
340
  process.stderr.write(`${GREEN}${PREFIX} Spawning: ${cmdStr}${RESET}\n`);
335
341
 
@@ -761,6 +767,61 @@ if (adapter) {
761
767
  broadcastPermissions();
762
768
  }
763
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
+ sendToServer({ type: "agent_history_replay", sessionId, events: historyEvents });
818
+ }
819
+ }
820
+ } catch (err) {
821
+ process.stderr.write(`${DIM}[orch] Could not load conversation history: ${err.message}${RESET}\n`);
822
+ }
823
+ }
824
+
764
825
  // Start the initial claude process
765
826
  const initialArgs = adapter.buildArgs(prompt, adapterFlags);
766
827
  if (yoloMode) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orchestrating",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "Stream terminal sessions to the orchestrat.ing dashboard",
5
5
  "type": "module",
6
6
  "bin": {