(params: {
taskId: string;
workspaceId: string;
runtime: ToolConfiguration["runtime"];
runtimeTempDir: string;
trusted: boolean;
repoCwd: string;
projectArtifact: SubagentGitProjectPatchArtifact;
artifactWorkspaceId: string;
artifactSessionDir: string;
artifactLookupNote?: string;
dryRun: boolean;
threeWay: boolean;
force: boolean;
expectedHeadSha?: string;
isReplay: boolean;
abortSignal?: AbortSignal;
})
| 1046 | } |
| 1047 | |
| 1048 | async function applyProjectPatch(params: { |
| 1049 | taskId: string; |
| 1050 | workspaceId: string; |
| 1051 | runtime: ToolConfiguration["runtime"]; |
| 1052 | runtimeTempDir: string; |
| 1053 | trusted: boolean; |
| 1054 | repoCwd: string; |
| 1055 | projectArtifact: SubagentGitProjectPatchArtifact; |
| 1056 | artifactWorkspaceId: string; |
| 1057 | artifactSessionDir: string; |
| 1058 | artifactLookupNote?: string; |
| 1059 | dryRun: boolean; |
| 1060 | threeWay: boolean; |
| 1061 | force: boolean; |
| 1062 | expectedHeadSha?: string; |
| 1063 | isReplay: boolean; |
| 1064 | abortSignal?: AbortSignal; |
| 1065 | }): Promise<{ success: boolean; projectResult: TaskApplyGitPatchProjectResult }> { |
| 1066 | const taskIdError = validatePatchRuntimePathComponent(params.taskId, "task_id"); |
| 1067 | const storageKeyError = validatePatchRuntimePathComponent( |
| 1068 | params.projectArtifact.storageKey, |
| 1069 | "storageKey" |
| 1070 | ); |
| 1071 | if (taskIdError != null || storageKeyError != null) { |
| 1072 | return { |
| 1073 | success: false, |
| 1074 | projectResult: { |
| 1075 | projectPath: params.projectArtifact.projectPath, |
| 1076 | projectName: params.projectArtifact.projectName, |
| 1077 | status: "failed", |
| 1078 | error: taskIdError ?? storageKeyError, |
| 1079 | }, |
| 1080 | }; |
| 1081 | } |
| 1082 | |
| 1083 | const remotePatchPath = buildRuntimeTempPath({ |
| 1084 | runtimeTempDir: params.runtimeTempDir, |
| 1085 | filename: `mux-task-${params.taskId}-${params.projectArtifact.storageKey}-series.mbox`, |
| 1086 | purpose: "patch copy", |
| 1087 | }); |
| 1088 | |
| 1089 | await cleanupRuntimePatchFile({ |
| 1090 | runtime: params.runtime, |
| 1091 | repoCwd: params.repoCwd, |
| 1092 | remotePatchPath, |
| 1093 | taskId: params.taskId, |
| 1094 | workspaceId: params.workspaceId, |
| 1095 | }); |
| 1096 | |
| 1097 | const patchResolution = await resolvePatchPath({ |
| 1098 | taskId: params.taskId, |
| 1099 | artifactSessionDir: params.artifactSessionDir, |
| 1100 | projectArtifact: params.projectArtifact, |
| 1101 | artifactLookupNote: params.artifactLookupNote, |
| 1102 | }); |
| 1103 | if ("error" in patchResolution) { |
| 1104 | return { |
| 1105 | success: false, |
no test coverage detected