MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / createBatchExecutor

Function createBatchExecutor

src/mcp/tools/ui-automation/batch.ts:164–232  ·  view source on GitHub ↗
(
  executor: CommandExecutor,
  axeHelpers: AxeHelpers = defaultAxeHelpers,
  debuggerManager: DebuggerManager = getDefaultDebuggerManager(),
)

Source from the content-addressed store, hash-verified

162}
163
164export function createBatchExecutor(
165 executor: CommandExecutor,
166 axeHelpers: AxeHelpers = defaultAxeHelpers,
167 debuggerManager: DebuggerManager = getDefaultDebuggerManager(),
168): NonStreamingExecutor<BatchParams, BatchResult> {
169 return async (params) =>
170 withSimulatorUiAutomationTransaction(params.simulatorId, async () => {
171 const toolName = 'batch';
172 const { simulatorId, steps } = params;
173 const action = { type: 'batch' as const, stepCount: steps.length };
174
175 const guard = await guardUiAutomationAgainstStoppedDebugger({
176 debugger: debuggerManager,
177 simulatorId,
178 toolName,
179 });
180 if (guard.blockedMessage) {
181 return createUiActionFailureResult(action, simulatorId, guard.blockedMessage);
182 }
183
184 const resolvedSteps = resolveBatchSteps(params);
185 if (!resolvedSteps.ok) {
186 return resolvedSteps.result;
187 }
188
189 const commandArgs = buildBatchCommandArgs(params, resolvedSteps.steps);
190 log(
191 'info',
192 `${LOG_PREFIX}/${toolName}: Starting ${steps.length} step batch on ${simulatorId}`,
193 );
194
195 try {
196 await executeAxeCommand(commandArgs, simulatorId, 'batch', executor, axeHelpers);
197 clearRuntimeSnapshot(simulatorId);
198 log('info', `${LOG_PREFIX}/${toolName}: Success for ${simulatorId}`);
199 } catch (error) {
200 if (shouldInvalidateRuntimeSnapshotAfterActionError(error)) {
201 clearRuntimeSnapshot(simulatorId);
202 }
203 const failure = mapAxeCommandError(error, {
204 axeFailureMessage: () => `Failed to execute AXe batch with ${steps.length} steps.`,
205 });
206 log('error', `${LOG_PREFIX}/${toolName}: Failed - ${failure.message}`);
207 return createUiActionFailureResult(action, simulatorId, failure.message, {
208 details: failure.diagnostics?.errors.map((entry) => entry.message),
209 uiError: createUiAutomationRecoverableError({
210 code: 'ACTION_FAILED',
211 message: failure.message,
212 }),
213 });
214 }
215
216 const captureResult = await captureRuntimeSnapshotAfterActionSafely({
217 simulatorId,
218 executor,
219 axeHelpers,
220 });
221 return createUiActionSuccessResult(

Callers 2

batch.test.tsFile · 0.90
batchLogicFunction · 0.85

Tested by

no test coverage detected