@love-moon/conductor-cli 0.13.3 → 0.15.0

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.
@@ -18,6 +18,8 @@ const KILL_GRACE_MS = 5_000;
18
18
  const NUL = String.fromCharCode(0);
19
19
 
20
20
  export const REMOTE_EXEC_CAPABILITY = "remote_exec";
21
+ /** `exec` honours a caller-chosen `runId`, so a retried request cannot spawn twice. */
22
+ export const REMOTE_EXEC_RUN_ID_CAPABILITY = "remote_exec_run_id";
21
23
 
22
24
  /**
23
25
  * Run arbitrary commands on this daemon's host on behalf of the account that
@@ -51,6 +53,15 @@ export function createRemoteExecHandlers(opts = {}) {
51
53
  // never learned.
52
54
  const waitMs = clampWaitMs(args.timeoutMs ?? args.timeout_ms);
53
55
  const waitDeadline = Date.now() + waitMs;
56
+ const attach = async (runState) => {
57
+ await waitForSettle(runState, Math.max(0, waitDeadline - Date.now()));
58
+ return toPublicRun(runState);
59
+ };
60
+
61
+ // A retry of a request that already started gets that run back rather than
62
+ // a second copy of the command.
63
+ const runId = typeof args.runId === "string" ? args.runId.trim() : "";
64
+ if (runId && runs.has(runId)) return attach(runs.get(runId));
54
65
 
55
66
  const command = normalizeCommand(args.command);
56
67
  if (!command) {
@@ -65,9 +76,11 @@ export function createRemoteExecHandlers(opts = {}) {
65
76
  }
66
77
  const cwd = await resolveWorkspace(args.workspace ?? args.workspace_path, defaultWorkspace);
67
78
  const env = buildExecEnv(args.env);
79
+ // ...including one that landed while `stat` above was still pending.
80
+ if (runId && runs.has(runId)) return attach(runs.get(runId));
68
81
 
69
82
  const runState = {
70
- runId: randomUUID(),
83
+ runId: runId || randomUUID(),
71
84
  command,
72
85
  args: argv,
73
86
  workspace: cwd,
@@ -126,8 +139,7 @@ export function createRemoteExecHandlers(opts = {}) {
126
139
  });
127
140
  });
128
141
 
129
- await waitForSettle(runState, Math.max(0, waitDeadline - Date.now()));
130
- return toPublicRun(runState);
142
+ return attach(runState);
131
143
  }
132
144
 
133
145
  async function status(args = {}) {