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

Function buildAutomationCommand

scripts/dev-with-automation.mjs:360–424  ·  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

358 * python.uvxRequest range in config/defaults.json) given to uvx.
359 */
360function buildAutomationCommand(env = process.env) {
361 const localPath = env.OH_AUTOMATION_LOCAL_PATH;
362 const gitRef = env.OH_AUTOMATION_GIT_REF;
363 const version = env.OH_AUTOMATION_VERSION;
364 const repoUrl = env.OH_AUTOMATION_REPO || DEFAULT_AUTOMATION_REPO;
365
366 const uvxArgs = buildUvxPythonArgs(env);
367 let source = "";
368
369 if (localPath) {
370 // Run straight from a local checkout via `uv run --project`, so
371 // uncommitted working-tree changes are picked up. Outranks the other
372 // automation env vars, mirroring OH_AGENT_SERVER_LOCAL_PATH for the
373 // agent-server SDK; buildConfig drops it when --automation-git-ref asks
374 // for a specific ref.
375 return {
376 command: "uv",
377 args: [
378 "run",
379 "--project",
380 localPath,
381 "uvicorn",
382 "openhands.automation.app:app",
383 ],
384 source: `local (${localPath})`,
385 };
386 }
387
388 if (gitRef) {
389 // Use git ref - refresh to ensure latest commit is fetched
390 const gitUrl = `git+${repoUrl}@${gitRef}`;
391 uvxArgs.push(
392 "--refresh",
393 "--from",
394 gitUrl,
395 "uvicorn",
396 "openhands.automation.app:app",
397 );
398 source = `git (${gitRef})`;
399 } else if (version) {
400 // Use specific PyPI version
401 uvxArgs.push(
402 "--from",
403 `${DEFAULT_AUTOMATION_PACKAGE}==${version}`,
404 "uvicorn",
405 "openhands.automation.app:app",
406 );
407 source = `PyPI (${version})`;
408 } else {
409 // Default to released PyPI version
410 uvxArgs.push(
411 "--from",
412 `${DEFAULT_AUTOMATION_PACKAGE}==${DEFAULT_AUTOMATION_VERSION}`,
413 "uvicorn",
414 "openhands.automation.app:app",
415 );
416 source = `PyPI (${DEFAULT_AUTOMATION_VERSION}, default)`;
417 }

Callers 3

startAutomationBackendFunction · 0.90
startAutomationBackendFunction · 0.85

Calls 1

buildUvxPythonArgsFunction · 0.90

Tested by

no test coverage detected