UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

22 lines (21 loc) • 1.41 kB
import { t as formatCliCommand } from "./command-format-CqdwUgPk.mjs"; import { n as quotePowerShellArg, t as quoteCliArg } from "./quote-cli-arg-J7A9UE6m.mjs"; //#region src/cli/installation-target-format.ts /** Bind diagnostic handoffs to their installation in POSIX shells or Windows PowerShell. */ function formatInstallationTargetCommand(e, t, n = {}) { const r = process.platform === "win32"; const quote = (e) => r ? quotePowerShellArg(e) : `'${e.replaceAll("'", "'\\''")}'`; const i = formatCliCommand(e.map((e) => r ? /^[a-z0-9_-]+$/iu.test(e) ? e : quote(e) : quoteCliArg(e)).join(" "), n.env); const a = [ ["OPENCLAW_STATE_DIR", t.stateDir], ["OPENCLAW_CONFIG_PATH", t.configPath], ["OPENCLAW_WORKSPACE_DIR", t.defaultWorkspaceDir] ]; if (!r) return `env ${a.map(([e, t]) => `${e}=${quote(t)}`).join(" ")} ${i}${n.stdinPath ? ` < ${quote(n.stdinPath)}` : ""}`; const o = a.map(([e]) => `$env:${e}`).join(", "); const s = a.map(([e, t]) => `$env:${e}=${quote(t)};`).join(" "); const c = a.map(([e], t) => `$env:${e}=$previousTarget[${t}];`).join(" "); return `& { $previousTarget=@(${o}); try { ${s} ${n.stdinPath ? `$prompt=Get-Content -Raw -Encoding UTF8 -LiteralPath ${quote(n.stdinPath)} -ErrorAction Stop; $OutputEncoding=[System.Text.UTF8Encoding]::new(); $prompt | & ${i}` : `& ${i}`} } finally { ${c} } }`; } //#endregion export { formatInstallationTargetCommand as t };