MCPcopy Index your code
hub / github.com/callstack/agent-device / runBatchStep

Function runBatchStep

src/core/batch.ts:240–291  ·  view source on GitHub ↗
(
  req: BatchRequest,
  sessionName: string,
  step: NormalizedBatchStep,
  invoke: BatchInvoke,
  stepNumber: number,
  isFinalStep: boolean,
)

Source from the content-addressed store, hash-verified

238}
239
240async function runBatchStep(
241 req: BatchRequest,
242 sessionName: string,
243 step: NormalizedBatchStep,
244 invoke: BatchInvoke,
245 stepNumber: number,
246 isFinalStep: boolean,
247): Promise<
248 | { ok: true; step: number; result: BatchStepResult }
249 | {
250 ok: false;
251 step: number;
252 error: {
253 code: string;
254 message: string;
255 hint?: string;
256 diagnosticId?: string;
257 logPath?: string;
258 details?: Record<string, unknown>;
259 };
260 }
261> {
262 const stepStartedAt = Date.now();
263 const stepFlags = buildBatchStepFlags(req.flags, step.flags);
264 if (stepFlags.session === undefined) {
265 stepFlags.session = sessionName;
266 }
267 const response = await invoke({
268 token: req.token,
269 session: sessionName,
270 command: step.command,
271 positionals: step.positionals,
272 flags: stepFlags,
273 runtime: step.runtime === undefined ? req.runtime : step.runtime,
274 meta: batchStepMeta(req.meta, isFinalStep),
275 });
276 const durationMs = Date.now() - stepStartedAt;
277 if (!response.ok) {
278 return { ok: false, step: stepNumber, error: response.error };
279 }
280 return {
281 ok: true,
282 step: stepNumber,
283 result: {
284 step: stepNumber,
285 command: step.command,
286 ok: true,
287 data: response.data ?? {},
288 durationMs,
289 },
290 };
291}
292
293function readBatchFlags(
294 flags: BatchFlags | Record<string, unknown> | undefined,

Callers 1

runBatchFunction · 0.85

Calls 3

buildBatchStepFlagsFunction · 0.85
batchStepMetaFunction · 0.85
invokeFunction · 0.50

Tested by

no test coverage detected