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

Function buildAgentServerCommand

scripts/dev-safe.mjs:418–519  ·  view source on GitHub ↗
(env = process.env)

Source from the content-addressed store, hash-verified

416 * @returns {{ command: string, args: string[], source: string }}
417 */
418export function buildAgentServerCommand(env = process.env) {
419 const localPath = env.OH_AGENT_SERVER_LOCAL_PATH;
420 const gitRef = env.OH_AGENT_SERVER_GIT_REF;
421 const version = env.OH_AGENT_SERVER_VERSION;
422
423 const uvxArgs = [];
424 let source = "";
425
426 if (localPath) {
427 if (!path.isAbsolute(localPath)) {
428 throw new Error(
429 `OH_AGENT_SERVER_LOCAL_PATH must be an absolute path, got: ${localPath}`,
430 );
431 }
432 uvxArgs.push(
433 "--reinstall",
434 "--from",
435 path.join(localPath, "openhands-agent-server"),
436 "--with-editable",
437 path.join(localPath, "openhands-sdk"),
438 "--with-editable",
439 path.join(localPath, "openhands-tools"),
440 "--with-editable",
441 path.join(localPath, "openhands-workspace"),
442 "--with",
443 AGENT_SERVER_POSTHOG_CONSTRAINT,
444 "agent-server",
445 );
446 source = `local (${localPath})`;
447 } else if (gitRef) {
448 // Use git ref with subdirectory syntax for uv workspace monorepo.
449 // The software-agent-sdk repo has packages in subdirectories:
450 // openhands-agent-server/, openhands-sdk/, openhands-tools/, openhands-workspace/
451 // All four must come from the same ref so inter-package APIs stay in sync.
452 //
453 // --reinstall is required because the git branch may carry the same version
454 // string as the current PyPI release (e.g. both "1.26.0"). Without it, uv
455 // silently reuses the cached PyPI wheels and the git ref is never actually
456 // used, even though it was explicitly requested.
457 const baseGitUrl = `git+${AGENT_SERVER_GIT_REPO}@${gitRef}`;
458 uvxArgs.push(
459 "--reinstall",
460 "--from",
461 `${baseGitUrl}#subdirectory=openhands-agent-server`,
462 "--with",
463 `${baseGitUrl}#subdirectory=openhands-sdk`,
464 "--with",
465 `${baseGitUrl}#subdirectory=openhands-tools`,
466 "--with",
467 `${baseGitUrl}#subdirectory=openhands-workspace`,
468 "--with",
469 AGENT_SERVER_POSTHOG_CONSTRAINT,
470 "agent-server",
471 );
472 source = `git (${gitRef})`;
473 } else if (version) {
474 // Use specific PyPI version: uvx --from openhands-agent-server==version agent-server
475 // The package name differs from the executable name, so we need --from syntax

Callers 5

startAgentServerFunction · 0.90
mainFunction · 0.90
startAgentServerFunction · 0.90
dev-safe.test.tsFile · 0.90
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected