Use OpenShell config home for host commands
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { NextResponse } from "next/server"
|
||||
import { execFile } from "node:child_process"
|
||||
import { promisify } from "node:util"
|
||||
import { HOST_PATH, OPENSHELL_BIN } from "@/app/lib/hostCommands"
|
||||
import { OPENSHELL_BIN, hostCommandEnv } from "@/app/lib/hostCommands"
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
|
||||
@@ -21,15 +21,10 @@ function stripAnsi(value: string) {
|
||||
|
||||
async function runOpenShell(args: string[], extraEnv: Record<string, string> = {}) {
|
||||
const { stdout, stderr } = await execFileAsync(OPENSHELL_BIN, args, {
|
||||
env: {
|
||||
...process.env,
|
||||
env: hostCommandEnv({
|
||||
...extraEnv,
|
||||
PATH: HOST_PATH,
|
||||
OPENSHELL_GATEWAY: process.env.OPENSHELL_GATEWAY || "nemoclaw",
|
||||
NO_COLOR: "1",
|
||||
CLICOLOR: "0",
|
||||
CLICOLOR_FORCE: "0",
|
||||
},
|
||||
}),
|
||||
timeout: 60000,
|
||||
maxBuffer: 20 * 1024 * 1024,
|
||||
})
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
NEMOCLAW_SETUP_CANDIDATES,
|
||||
NODE_BIN,
|
||||
OPENSHELL_BIN,
|
||||
hostCommandEnv,
|
||||
} from "@/app/lib/hostCommands"
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
@@ -240,14 +241,9 @@ async function approveOpenClawDeviceRequests(sandboxName: string) {
|
||||
"sh",
|
||||
"-lc",
|
||||
"openclaw devices approve --latest --json --timeout 10000",
|
||||
], {
|
||||
...process.env,
|
||||
PATH: HOST_PATH,
|
||||
], hostCommandEnv({
|
||||
OPENSHELL_GATEWAY: process.env.OPENSHELL_GATEWAY || "nemoclaw",
|
||||
NO_COLOR: "1",
|
||||
CLICOLOR: "0",
|
||||
CLICOLOR_FORCE: "0",
|
||||
}, 15000)
|
||||
}), 15000)
|
||||
|
||||
const combinedOutput = `${result.stdout}\n${result.stderr}`.trim()
|
||||
const noPending = NO_PENDING_DEVICE_REQUESTS.test(combinedOutput)
|
||||
@@ -339,15 +335,13 @@ export async function POST(request: Request) {
|
||||
|
||||
if (blueprint === "nemoclaw-blueprint") {
|
||||
const createCommand = buildNemoClawCreateCommand()
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
...process.env,
|
||||
PATH: HOST_PATH,
|
||||
const env: NodeJS.ProcessEnv = hostCommandEnv({
|
||||
NEMOCLAW_SANDBOX_NAME: sandboxName,
|
||||
NEMOCLAW_NON_INTERACTIVE: "1",
|
||||
NEMOCLAW_RECREATE_SANDBOX: "1",
|
||||
NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE: "1",
|
||||
OPENSHELL_GATEWAY: process.env.OPENSHELL_GATEWAY || "nemoclaw",
|
||||
}
|
||||
})
|
||||
|
||||
if (!enableTailscale) {
|
||||
env.NVIDIA_API_KEY = env.NVIDIA_API_KEY || "optional-local-mode"
|
||||
@@ -414,13 +408,7 @@ export async function POST(request: Request) {
|
||||
}
|
||||
|
||||
if (blueprint === "custom-sandbox") {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
...process.env,
|
||||
PATH: HOST_PATH,
|
||||
NO_COLOR: "1",
|
||||
CLICOLOR: "0",
|
||||
CLICOLOR_FORCE: "0",
|
||||
}
|
||||
const env: NodeJS.ProcessEnv = hostCommandEnv()
|
||||
const createAttempt = await runCreateCommandBounded(OPENSHELL_BIN, ["sandbox", "create", "--name", sandboxName], env, 15000)
|
||||
|
||||
if (createAttempt.completed && createAttempt.exitCode !== 0) {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextResponse } from "next/server"
|
||||
import { execFile } from "node:child_process"
|
||||
import { promisify } from "node:util"
|
||||
import { resolveSandboxRef } from "@/app/lib/openshellHost"
|
||||
import { HOST_PATH, NEMOCLAW_BIN, NEMOCLAW_CWD, OPENSHELL_BIN } from "@/app/lib/hostCommands"
|
||||
import { NEMOCLAW_BIN, NEMOCLAW_CWD, OPENSHELL_BIN, hostCommandEnv } from "@/app/lib/hostCommands"
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
|
||||
@@ -54,14 +54,9 @@ async function deleteSandbox(sandboxName: string) {
|
||||
console.log(`[sandbox/delete] command:start sandbox=${sandboxName}`)
|
||||
try {
|
||||
const { stdout, stderr } = await execFileAsync(OPENSHELL_BIN, ["sandbox", "delete", sandboxName], {
|
||||
env: {
|
||||
...process.env,
|
||||
PATH: HOST_PATH,
|
||||
env: hostCommandEnv({
|
||||
OPENSHELL_GATEWAY: process.env.OPENSHELL_GATEWAY || "nemoclaw",
|
||||
NO_COLOR: "1",
|
||||
CLICOLOR: "0",
|
||||
CLICOLOR_FORCE: "0",
|
||||
},
|
||||
}),
|
||||
timeout: 60000,
|
||||
maxBuffer: 20 * 1024 * 1024,
|
||||
})
|
||||
@@ -93,14 +88,9 @@ async function cleanupNemoClawSandbox(sandboxName: string) {
|
||||
try {
|
||||
const { stdout, stderr } = await execFileAsync(NEMOCLAW_BIN, [sandboxName, "destroy", "--yes"], {
|
||||
cwd: NEMOCLAW_CWD,
|
||||
env: {
|
||||
...process.env,
|
||||
PATH: HOST_PATH,
|
||||
env: hostCommandEnv({
|
||||
OPENSHELL_GATEWAY: process.env.OPENSHELL_GATEWAY || "nemoclaw",
|
||||
NO_COLOR: "1",
|
||||
CLICOLOR: "0",
|
||||
CLICOLOR_FORCE: "0",
|
||||
},
|
||||
}),
|
||||
timeout: 90000,
|
||||
maxBuffer: 20 * 1024 * 1024,
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextResponse } from "next/server"
|
||||
import { execFile } from "node:child_process"
|
||||
import { hostname, networkInterfaces } from "node:os"
|
||||
import { promisify } from "node:util"
|
||||
import { HOST_PATH, NEMOCLAW_BIN, NODE_BIN, OPENSHELL_BIN } from "@/app/lib/hostCommands"
|
||||
import { HOST_PATH, NEMOCLAW_BIN, NODE_BIN, OPENSHELL_BIN, hostCommandEnv } from "@/app/lib/hostCommands"
|
||||
import { resolveRuntimeAuthority } from "@/app/lib/runtimeAuthority"
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
@@ -164,13 +164,7 @@ async function execNemoclaw(args: string[]) {
|
||||
|
||||
async function execOpenShell(args: string[]) {
|
||||
const { stdout, stderr } = await execFileAsync(OPENSHELL_BIN, args, {
|
||||
env: {
|
||||
...process.env,
|
||||
PATH: HOST_PATH,
|
||||
NO_COLOR: "1",
|
||||
CLICOLOR: "0",
|
||||
CLICOLOR_FORCE: "0",
|
||||
},
|
||||
env: hostCommandEnv(),
|
||||
})
|
||||
|
||||
return { stdout, stderr }
|
||||
|
||||
Reference in New Issue
Block a user