@algosuite/vo-mcp 0.2.0-beta.44 → 0.2.0-beta.46

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.
@@ -7011,6 +7011,7 @@ async function openCodeTaskPrAsync(worktreeDir, files, {
7011
7011
  if (!Array.isArray(files) || files.length === 0) throw new Error("openCodeTaskPrAsync: no files to commit");
7012
7012
  let branch;
7013
7013
  let truncated = false;
7014
+ let newCommit = null;
7014
7015
  if (alreadyCommitted) {
7015
7016
  branch = await resolveOrCreateBranchAsync(worktreeDir, branchPrefix, runCommand);
7016
7017
  } else {
@@ -7023,6 +7024,7 @@ async function openCodeTaskPrAsync(worktreeDir, files, {
7023
7024
  });
7024
7025
  branch = committed.branch;
7025
7026
  truncated = committed.truncated;
7027
+ newCommit = committed.committed;
7026
7028
  }
7027
7029
  const prBranch = String(targetBranch || branch).trim() || branch;
7028
7030
  const overlap = await runOverlapGate(worktreeDir, files.filter((file) => !isAgentScratch(file)), {
@@ -7077,6 +7079,7 @@ async function openCodeTaskPrAsync(worktreeDir, files, {
7077
7079
  prNumber: existing.number,
7078
7080
  branch: prBranch,
7079
7081
  truncated,
7082
+ newCommit,
7080
7083
  resumed: true,
7081
7084
  markedReady,
7082
7085
  overlapDraft,
@@ -7115,7 +7118,7 @@ async function openCodeTaskPrAsync(worktreeDir, files, {
7115
7118
  runCommand,
7116
7119
  onCleanupWarning
7117
7120
  });
7118
- return { prUrl, prNumber, branch: prBranch, truncated, overlapDraft, overlapBlockedBy, ...autoMerge, ...superseded };
7121
+ return { prUrl, prNumber, branch: prBranch, truncated, newCommit, overlapDraft, overlapBlockedBy, ...autoMerge, ...superseded };
7119
7122
  }
7120
7123
  var sleep;
7121
7124
  var init_publish_async = __esm({
@@ -12866,7 +12869,7 @@ async function finalizePublishedPr({
12866
12869
  log: log2,
12867
12870
  patch: {
12868
12871
  status: "pr_opened",
12869
- message: `opened ${pr.prUrl}${overlapNote}`,
12872
+ message: `opened ${pr.prUrl}${overlapNote}${pr.newCommit === false ? " (no new commits \u2014 the branch already held every change)" : ""}`,
12870
12873
  pr_url: pr.prUrl,
12871
12874
  pr_number: pr.prNumber,
12872
12875
  pr_branch: pr.branch,
@@ -13095,7 +13098,10 @@ async function readLedger(file, readFile5) {
13095
13098
  async function findPreservedRecovery(task, {
13096
13099
  clonesRoot: clonesRoot2 = process.env.VO_CODE_RUNNER_CLONES_ROOT || "",
13097
13100
  readFile: readFile5 = fsp13.readFile,
13098
- exists = fs13.existsSync
13101
+ exists = fs13.existsSync,
13102
+ alreadyPublished = preservedHeadAlreadyOnBranch,
13103
+ log: log2 = () => {
13104
+ }
13099
13105
  } = {}) {
13100
13106
  const resumedFrom = /^[0-9a-f-]{36}$/iu.test(String(task.resumed_from || "")) ? String(task.resumed_from).toLowerCase() : null;
13101
13107
  const originalTaskId = recoveryTaskId(task.prompt) ?? resumedFrom;
@@ -13106,11 +13112,41 @@ async function findPreservedRecovery(task, {
13106
13112
  const resolved = entries.some((entry) => RESOLVED_RECOVERY_TYPES.has(entry.type) && entry.taskId === originalTaskId);
13107
13113
  const preserved = [...entries].reverse().find((entry) => entry.taskId === originalTaskId && entry.worktreeDir);
13108
13114
  if (!resolved && preserved && exists(preserved.worktreeDir)) {
13115
+ if (task.pr_branch && await alreadyPublished(preserved.worktreeDir, task.pr_branch)) {
13116
+ log2(`recovery: preserved worktree of ${originalTaskId} is already on ${task.pr_branch}; running the agent instead`);
13117
+ return null;
13118
+ }
13109
13119
  return { originalTaskId, ledgerPath, preserved };
13110
13120
  }
13111
13121
  }
13112
13122
  return null;
13113
13123
  }
13124
+ async function preservedHeadAlreadyOnBranch(worktreeDir, prBranch, { runGit = defaultRunGit } = {}) {
13125
+ try {
13126
+ const dirty = (await runGit(["status", "--porcelain"], worktreeDir)).trim();
13127
+ if (dirty.length > 0) return false;
13128
+ const head = (await runGit(["rev-parse", "HEAD"], worktreeDir)).trim();
13129
+ if (!/^[0-9a-f]{40}$/u.test(head)) return false;
13130
+ let tip = "";
13131
+ try {
13132
+ tip = (await runGit(["rev-parse", `refs/remotes/origin/${prBranch}`], worktreeDir)).trim();
13133
+ } catch {
13134
+ tip = (await runGit(["ls-remote", "origin", `refs/heads/${prBranch}`], worktreeDir)).trim().split(/\s+/u)[0] || "";
13135
+ }
13136
+ if (!/^[0-9a-f]{40}$/u.test(tip)) return false;
13137
+ if (head === tip) return true;
13138
+ await runGit(["merge-base", "--is-ancestor", head, tip], worktreeDir);
13139
+ return true;
13140
+ } catch {
13141
+ return false;
13142
+ }
13143
+ }
13144
+ async function defaultRunGit(args, cwd) {
13145
+ const { execFile: execFile2 } = await import("node:child_process");
13146
+ return new Promise((resolve2, reject) => {
13147
+ execFile2("git", args, { cwd, encoding: "utf8", timeout: 6e4 }, (err, stdout) => err ? reject(err) : resolve2(stdout));
13148
+ });
13149
+ }
13114
13150
  async function recoverPreservedCodeTask({
13115
13151
  task,
13116
13152
  cfg,
@@ -13123,7 +13159,7 @@ async function recoverPreservedCodeTask({
13123
13159
  finalizePublished = finalizePublishedPr,
13124
13160
  track
13125
13161
  } = {}) {
13126
- const recovery = await find(task);
13162
+ const recovery = await find(task, { log: log2 });
13127
13163
  if (!recovery) return null;
13128
13164
  const cwd = recovery.preserved.worktreeDir;
13129
13165
  const { files, alreadyCommitted } = await prepareScope(cwd);