UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

49 lines (48 loc) • 2.51 kB
import { n as resolveRuntimeWorkerArgv } from "./runtime-worker-url-DRDkoS4J.mjs"; import { a as resolveRuntimeProcessEntrypointUrl } from "./runtime-process-url-CoHTemu-.mjs"; import { n as quotePowerShellArg, t as quoteCliArg } from "./quote-cli-arg-J7A9UE6m.mjs"; import { a as resolveConfiguredGitHubHost, n as GITHUB_PUBLIC_HOST } from "./github-host-CjR25cOO.mjs"; import { fileURLToPath } from "node:url"; //#region src/agents/github-exec-launch.ts /** Carry only a selected profile path through supervision; resolve its token in the child. */ function buildGitHubExecLaunchArgv(e, t, n) { const r = resolveRuntimeProcessEntrypointUrl("githubExec"); const i = resolveConfiguredGitHubHost({ gateway: { github: { host: n?.githubHost } } }); const a = [ process.execPath, ...resolveRuntimeWorkerArgv(r), t, i ]; const o = i === "github.com" || i.endsWith(".ghe.com"); if (process.platform === "win32") { const t = n?.externalCommandShell; const s = t ? [ t.shell, ...t.args, `$ErrorActionPreference = 'Stop'; & ${e.map(quotePowerShellArg).join(" ")}; exit $LASTEXITCODE` ] : e; const c = s.at(-1); if (c === void 0) throw new Error("Managed GitHub execution requires a shell command."); const l = [ `Push-Location -LiteralPath ${quotePowerShellArg(fileURLToPath(new URL(".", r)))} -ErrorAction Stop;`, `try { $env:GH_TOKEN = & ${a.map(quotePowerShellArg).join(" ")};`, "if (-not $? -or $LASTEXITCODE -ne 0 -or [string]::IsNullOrEmpty($env:GH_TOKEN)) { exit 1 }", "} finally { Pop-Location };", `$env:GH_HOST = ${quotePowerShellArg(i)};`, o ? "$env:GH_ENTERPRISE_TOKEN = '';" : "$env:GH_ENTERPRISE_TOKEN = $env:GH_TOKEN; $env:GH_TOKEN = '';", "$env:GITHUB_TOKEN = ''; $env:GITHUB_ENTERPRISE_TOKEN = ''; $LASTEXITCODE = $null;", `& ([scriptblock]::Create(${quotePowerShellArg(c)}))` ].join(" "); return [...s.slice(0, -1), l]; } return [ "/bin/sh", "-c", `set +x; GH_TOKEN="$(${`cd ${quoteCliArg(fileURLToPath(new URL(".", r)))} 2>/dev/null || { printf '%s\\n' 'GitHub Identity launcher is unavailable. Restart OpenClaw, then retry.' >&2; exit 1; }`}; exec ${a.map(quoteCliArg).join(" ")})" || exit $?; GH_HOST=${quoteCliArg(i)}; ${o ? "GH_ENTERPRISE_TOKEN=;" : "GH_ENTERPRISE_TOKEN=$GH_TOKEN; GH_TOKEN=;"} GITHUB_TOKEN=; GITHUB_ENTERPRISE_TOKEN=; export GH_HOST GH_TOKEN GH_ENTERPRISE_TOKEN GITHUB_TOKEN GITHUB_ENTERPRISE_TOKEN; exec "$@"`, "openclaw-github-exec", ...e ]; } //#endregion export { buildGitHubExecLaunchArgv as t };