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

Function executeRunScriptFile

src/compat/maestro/run-script.ts:59–92  ·  view source on GitHub ↗
(params: {
  scriptPath: string;
  env: Record<string, string>;
})

Source from the content-addressed store, hash-verified

57}
58
59export function executeRunScriptFile(params: {
60 scriptPath: string;
61 env: Record<string, string>;
62}): Record<string, string> {
63 const { scriptPath, env } = params;
64 const script = fs.readFileSync(scriptPath, 'utf8');
65 const output: Record<string, unknown> = Object.create(null) as Record<string, unknown>;
66
67 try {
68 // Compatibility note: node:vm is not a security sandbox. Maestro runScript
69 // files are trusted flow-local setup code; the timeout only bounds
70 // synchronous script execution. Async http.post work is bounded separately
71 // by the child process timeout in runHttpRequestSync.
72 vm.runInNewContext(script, buildScriptGlobals(env, output), {
73 filename: scriptPath,
74 timeout: RUN_SCRIPT_TIMEOUT_MS,
75 });
76 } catch (error) {
77 throw new AppError(
78 'COMMAND_FAILED',
79 `Maestro runScript failed for ${scriptPath}: ${error instanceof Error ? error.message : String(error)}`,
80 { scriptPath },
81 error instanceof Error ? error : undefined,
82 );
83 }
84
85 validateOutputKeys(output, scriptPath);
86 return Object.fromEntries(
87 Object.entries(output).map(([key, rawValue]) => [
88 `output.${key}`,
89 stringifyOutputValue(rawValue),
90 ]),
91 );
92}
93
94function readRunScriptConfig(
95 value: unknown,

Callers 1

invokeMaestroRunScriptFunction · 0.90

Calls 3

buildScriptGlobalsFunction · 0.85
validateOutputKeysFunction · 0.85
stringifyOutputValueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…