MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / buildAutomationCommand

Function buildAutomationCommand

scripts/dev-with-automation.mjs:309–373  ·  view source on GitHub ↗

* Build the uvx command for running automation backend. * * Environment variables (highest precedence first): * - OH_AUTOMATION_LOCAL_PATH: Absolute path to a local checkout * - OH_AUTOMATION_GIT_REF: Git commit SHA or branch name * - OH_AUTOMATION_VERSION: Specific PyPI version (e.g., "1.0.0a1

(env = process.env)

Source from the content-addressed store, hash-verified

307 * git branch or commit instead.
308 */
309function buildAutomationCommand(env = process.env) {
310 const localPath = env.OH_AUTOMATION_LOCAL_PATH;
311 const gitRef = env.OH_AUTOMATION_GIT_REF;
312 const version = env.OH_AUTOMATION_VERSION;
313 const repoUrl = env.OH_AUTOMATION_REPO || DEFAULT_AUTOMATION_REPO;
314
315 const uvxArgs = [];
316 let source = "";
317
318 if (localPath) {
319 // Run straight from a local checkout via `uv run --project`, so
320 // uncommitted working-tree changes are picked up. Outranks the other
321 // automation env vars, mirroring OH_AGENT_SERVER_LOCAL_PATH for the
322 // agent-server SDK; buildConfig drops it when --automation-git-ref asks
323 // for a specific ref.
324 return {
325 command: "uv",
326 args: [
327 "run",
328 "--project",
329 localPath,
330 "uvicorn",
331 "openhands.automation.app:app",
332 ],
333 source: `local (${localPath})`,
334 };
335 }
336
337 if (gitRef) {
338 // Use git ref - refresh to ensure latest commit is fetched
339 const gitUrl = `git+${repoUrl}@${gitRef}`;
340 uvxArgs.push(
341 "--refresh",
342 "--from",
343 gitUrl,
344 "uvicorn",
345 "openhands.automation.app:app",
346 );
347 source = `git (${gitRef})`;
348 } else if (version) {
349 // Use specific PyPI version
350 uvxArgs.push(
351 "--from",
352 `${DEFAULT_AUTOMATION_PACKAGE}==${version}`,
353 "uvicorn",
354 "openhands.automation.app:app",
355 );
356 source = `PyPI (${version})`;
357 } else {
358 // Default to released PyPI version
359 uvxArgs.push(
360 "--from",
361 `${DEFAULT_AUTOMATION_PACKAGE}==${DEFAULT_AUTOMATION_VERSION}`,
362 "uvicorn",
363 "openhands.automation.app:app",
364 );
365 source = `PyPI (${DEFAULT_AUTOMATION_VERSION}, default)`;
366 }

Callers 3

startAutomationBackendFunction · 0.90
startAutomationBackendFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected