MCPcopy
hub / github.com/callstack/agent-device / createExecTraceContext

Function createExecTraceContext

src/utils/exec.ts:430–470  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

428};
429
430function createExecTraceContext(): ExecTraceContext {
431 const diagnosticsMeta = getDiagnosticsMeta();
432 const diagnosticsDebugEnabled = diagnosticsMeta.debug === true;
433 const envTraceEnabled = parseBooleanLiteral(process.env.AGENT_DEVICE_EXEC_TRACE ?? '') === true;
434 if (!diagnosticsDebugEnabled && !envTraceEnabled) {
435 return createDisabledExecTraceContext();
436 }
437 if (envTraceEnabled && diagnosticsMeta.flushOnSuccess !== true) {
438 updateDiagnosticsScope({ flushOnSuccess: true });
439 }
440 const startedAtMs = Date.now();
441 let completionEmitted = false;
442 return {
443 emitForegroundCompletion: (cmd, args) => {
444 if (completionEmitted) return;
445 completionEmitted = true;
446 emitExecCommandDiagnostic({
447 cmd,
448 args,
449 startedAtMs,
450 });
451 },
452 emitBackgroundSpawn: (cmd, args) => {
453 emitExecCommandDiagnostic({
454 cmd,
455 args,
456 data: { event: 'spawn' },
457 });
458 },
459 emitBackgroundCompletion: (cmd, args, event) => {
460 if (completionEmitted) return;
461 completionEmitted = true;
462 emitExecCommandDiagnostic({
463 cmd,
464 args,
465 startedAtMs,
466 data: { event },
467 });
468 },
469 };
470}
471
472function createDisabledExecTraceContext(): ExecTraceContext {
473 return {

Callers 2

runSpawnedCommandFunction · 0.85
runCmdBackgroundFunction · 0.85

Calls 5

getDiagnosticsMetaFunction · 0.90
parseBooleanLiteralFunction · 0.90
updateDiagnosticsScopeFunction · 0.90

Tested by

no test coverage detected