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