agent-relay-orchestrator 0.60.0 → 0.60.1
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/package.json +1 -1
- package/src/control.ts +12 -1
- package/src/workspace-pr.ts +32 -0
package/package.json
CHANGED
package/src/control.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { ManagedAgentReport, RelayClient, RelayCommand } from "./relay";
|
|
|
4
4
|
import { handleSelfUpgrade } from "./self-upgrade";
|
|
5
5
|
import { spawnAgent, stopSession, type SpawnOptions } from "./spawn";
|
|
6
6
|
import { cleanupWorkspace, mergeWorkspace, pruneWorktrees, reconcileWorkspace, refreshWorkspaceDeps, workspacesRoot } from "./workspace-probe";
|
|
7
|
-
import { armWorkspacePrAutoMerge, mergeWorkspacePr } from "./workspace-pr";
|
|
7
|
+
import { armWorkspacePrAutoMerge, mergeWorkspacePr, refreshWorkspacePrBranch } from "./workspace-pr";
|
|
8
8
|
|
|
9
9
|
interface ControlHandler {
|
|
10
10
|
handleCommand(command: RelayCommand): Promise<boolean>;
|
|
@@ -152,6 +152,17 @@ export function createControlHandler(
|
|
|
152
152
|
prUrl: typeof command.params.prUrl === "string" ? command.params.prUrl : undefined,
|
|
153
153
|
});
|
|
154
154
|
await relay.updateCommand(command.id, result.relayMerged ? "succeeded" : "failed", result as unknown as Record<string, unknown>, result.error);
|
|
155
|
+
} else if (command.type === "workspace.pr-refresh") {
|
|
156
|
+
const rawPrNumber = command.params.prNumber;
|
|
157
|
+
const result = refreshWorkspacePrBranch({
|
|
158
|
+
id: typeof command.params.workspaceId === "string" ? command.params.workspaceId : undefined,
|
|
159
|
+
repoRoot: typeof command.params.repoRoot === "string" ? command.params.repoRoot : undefined,
|
|
160
|
+
worktreePath: typeof command.params.worktreePath === "string" ? command.params.worktreePath : undefined,
|
|
161
|
+
branch: typeof command.params.branch === "string" ? command.params.branch : undefined,
|
|
162
|
+
prNumber: typeof rawPrNumber === "number" && Number.isSafeInteger(rawPrNumber) ? rawPrNumber : undefined,
|
|
163
|
+
prUrl: typeof command.params.prUrl === "string" ? command.params.prUrl : undefined,
|
|
164
|
+
});
|
|
165
|
+
await relay.updateCommand(command.id, result.prRefreshed ? "succeeded" : "failed", result as unknown as Record<string, unknown>, result.error);
|
|
155
166
|
} else if (command.type === "workspace.deps-refresh") {
|
|
156
167
|
const result = refreshWorkspaceDeps(
|
|
157
168
|
typeof command.params.repoRoot === "string" ? command.params.repoRoot : "",
|
package/src/workspace-pr.ts
CHANGED
|
@@ -127,3 +127,35 @@ export function mergeWorkspacePr(input: {
|
|
|
127
127
|
}
|
|
128
128
|
return { workspaceId: input.id, status: "merge_planned", relayMerged: true, prNumber: input.prNumber, prUrl: input.prUrl };
|
|
129
129
|
}
|
|
130
|
+
|
|
131
|
+
export function refreshWorkspacePrBranch(input: {
|
|
132
|
+
id?: string;
|
|
133
|
+
repoRoot?: string;
|
|
134
|
+
worktreePath?: string;
|
|
135
|
+
branch?: string;
|
|
136
|
+
prNumber?: number;
|
|
137
|
+
prUrl?: string;
|
|
138
|
+
}): { workspaceId?: string; status: "merge_planned"; prRefreshed: boolean; prNumber?: number; prUrl?: string; error?: string } {
|
|
139
|
+
const cwd = input.worktreePath ? resolve(input.worktreePath) : input.repoRoot ? resolve(input.repoRoot) : undefined;
|
|
140
|
+
if (!cwd) return { workspaceId: input.id, status: "merge_planned", prRefreshed: false, error: "worktreePath or repoRoot required" };
|
|
141
|
+
const target = input.prNumber ? String(input.prNumber) : input.prUrl ?? input.branch;
|
|
142
|
+
if (!target) return { workspaceId: input.id, status: "merge_planned", prRefreshed: false, error: "prNumber, prUrl, or branch required" };
|
|
143
|
+
const proc = Bun.spawnSync(["gh", "pr", "update-branch", target], {
|
|
144
|
+
cwd,
|
|
145
|
+
stdin: "ignore",
|
|
146
|
+
stdout: "pipe",
|
|
147
|
+
stderr: "pipe",
|
|
148
|
+
env: process.env,
|
|
149
|
+
});
|
|
150
|
+
if (proc.exitCode !== 0) {
|
|
151
|
+
return {
|
|
152
|
+
workspaceId: input.id,
|
|
153
|
+
status: "merge_planned",
|
|
154
|
+
prRefreshed: false,
|
|
155
|
+
prNumber: input.prNumber,
|
|
156
|
+
prUrl: input.prUrl,
|
|
157
|
+
error: proc.stderr.toString().trim() || proc.stdout.toString().trim() || "gh pr update-branch failed",
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
return { workspaceId: input.id, status: "merge_planned", prRefreshed: true, prNumber: input.prNumber, prUrl: input.prUrl };
|
|
161
|
+
}
|