Improve dashboard portability and installer smoke checks
This commit is contained in:
@@ -1,28 +1,9 @@
|
||||
import { NextResponse } from "next/server"
|
||||
import { execFile } from "node:child_process"
|
||||
import { existsSync } from "node:fs"
|
||||
import { promisify } from "node:util"
|
||||
import { HOST_PATH, OPENSHELL_BIN } from "@/app/lib/hostCommands"
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
const HOME = process.env.HOME || ""
|
||||
const OPENSHELL_BIN_CANDIDATES = [
|
||||
process.env.OPENSHELL_BIN,
|
||||
HOME ? `${HOME}/.local/bin/openshell` : undefined,
|
||||
"/usr/local/bin/openshell",
|
||||
"/opt/homebrew/bin/openshell",
|
||||
].filter((value): value is string => Boolean(value))
|
||||
const OPENSHELL_BIN =
|
||||
OPENSHELL_BIN_CANDIDATES.find((candidate) => existsSync(candidate)) ?? OPENSHELL_BIN_CANDIDATES[0]
|
||||
const HOST_PATH = [
|
||||
`${HOME}/.local/bin`,
|
||||
`${HOME}/.nvm/versions/node/v22.22.2/bin`,
|
||||
`${HOME}/.nvm/versions/node/v22.22.1/bin`,
|
||||
"/usr/local/bin",
|
||||
"/opt/homebrew/bin",
|
||||
"/usr/bin",
|
||||
"/bin",
|
||||
process.env.PATH || "",
|
||||
].filter(Boolean).join(":")
|
||||
|
||||
const PROVIDER_TYPES = new Set(["openai", "anthropic", "nvidia", "generic", "claude", "opencode", "codex", "copilot", "gitlab", "github", "outlook"])
|
||||
|
||||
|
||||
@@ -8,6 +8,15 @@ const TERMINAL_WS_PROXY_PORT = process.env.TERMINAL_WS_PROXY_PORT || ''
|
||||
const PUBLIC_BROWSER_HOST = process.env.PUBLIC_BROWSER_HOST || process.env.PUBLIC_WS_HOST || null
|
||||
const PUBLIC_BASE_URL = process.env.PUBLIC_BASE_URL || null
|
||||
|
||||
function describeTerminalServerError(error: unknown, terminalServerUrl: string) {
|
||||
const message = error instanceof Error ? error.message : String(error || 'unknown error')
|
||||
const cause = error instanceof Error && error.cause instanceof Error ? ` (${error.cause.message})` : ''
|
||||
if (/fetch failed|ECONNREFUSED|ENOTFOUND|EHOSTUNREACH|UND_ERR_SOCKET/i.test(`${message} ${cause}`)) {
|
||||
return `Could not reach the operator terminal bridge at ${terminalServerUrl}. Restart the dashboard so it can auto-start the local bridge, or run npm run terminal-server in this repo. Details: ${message}${cause}`
|
||||
}
|
||||
return message
|
||||
}
|
||||
|
||||
function isNonRoutableHost(candidate: string, protocol = 'http:') {
|
||||
const normalized = candidate.trim()
|
||||
if (!normalized) return true
|
||||
@@ -115,18 +124,26 @@ export async function POST(request: Request) {
|
||||
const terminalServerUrl = authority.terminalServerUrl || TERMINAL_SERVER_URL
|
||||
const resolvedSandboxId = authority.resolvedSandboxId || requestedSandboxId
|
||||
|
||||
const response = await fetch(`${terminalServerUrl}/session`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
sandboxId: resolvedSandboxId,
|
||||
sessionId,
|
||||
dashboardSessionId,
|
||||
}),
|
||||
cache: 'no-store',
|
||||
})
|
||||
let response: Response
|
||||
try {
|
||||
response = await fetch(`${terminalServerUrl}/session`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
sandboxId: resolvedSandboxId,
|
||||
sessionId,
|
||||
dashboardSessionId,
|
||||
}),
|
||||
cache: 'no-store',
|
||||
})
|
||||
} catch (error) {
|
||||
return NextResponse.json({
|
||||
ok: false,
|
||||
error: describeTerminalServerError(error, terminalServerUrl),
|
||||
}, { status: 502 })
|
||||
}
|
||||
|
||||
const result = await response.json()
|
||||
if (!response.ok) {
|
||||
|
||||
@@ -2,23 +2,9 @@ import { NextResponse } from "next/server"
|
||||
import { execFile, spawn } from "node:child_process"
|
||||
import { promisify } from "node:util"
|
||||
import { inspectSandbox } from "@/app/lib/openshellHost"
|
||||
import { commandExists, HOST_PATH, NEMOCLAW_SETUP, OPENSHELL_BIN } from "@/app/lib/hostCommands"
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
const HOME = process.env.HOME || ""
|
||||
const NEMOCLAW_SETUP = process.env.NEMOCLAW_SETUP || `${HOME}/NemoClaw/scripts/setup.sh`
|
||||
const OPENSHELL_BIN = process.env.OPENSHELL_BIN || `${HOME}/.local/bin/openshell`
|
||||
const HOST_PATH = [
|
||||
`${HOME}/.local/bin`,
|
||||
`${HOME}/.nvm/versions/node/v22.22.2/bin`,
|
||||
`${HOME}/.nvm/versions/node/v22.22.1/bin`,
|
||||
"/opt/homebrew/bin",
|
||||
"/usr/local/bin",
|
||||
"/usr/bin",
|
||||
"/bin",
|
||||
"/usr/sbin",
|
||||
"/sbin",
|
||||
process.env.PATH || "",
|
||||
].filter(Boolean).join(":")
|
||||
|
||||
function validateSandboxName(name: string) {
|
||||
if (!name || typeof name !== "string") throw new Error("sandbox name is required")
|
||||
@@ -55,6 +41,13 @@ function appendNote(...parts: Array<string | false | null | undefined>) {
|
||||
return parts.filter(Boolean).join(" ")
|
||||
}
|
||||
|
||||
function requireNemoClawSetup() {
|
||||
if (NEMOCLAW_SETUP && commandExists(NEMOCLAW_SETUP)) return NEMOCLAW_SETUP
|
||||
throw new Error(
|
||||
"NemoClaw blueprint setup script was not found. Install NemoClaw on this host or set NEMOCLAW_SETUP in .env.local to the absolute path of scripts/setup.sh.",
|
||||
)
|
||||
}
|
||||
|
||||
async function verifySandboxCreation(sandboxName: string): Promise<SandboxVerification> {
|
||||
const startedAt = Date.now()
|
||||
console.log(`[sandbox/create] verify:start sandbox=${sandboxName}`)
|
||||
@@ -320,6 +313,7 @@ export async function POST(request: Request) {
|
||||
}
|
||||
|
||||
if (blueprint === "nemoclaw-blueprint") {
|
||||
const setupPath = requireNemoClawSetup()
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
...process.env,
|
||||
PATH: HOST_PATH,
|
||||
@@ -330,7 +324,7 @@ export async function POST(request: Request) {
|
||||
env.NVIDIA_API_KEY = env.NVIDIA_API_KEY || "optional-local-mode"
|
||||
}
|
||||
|
||||
const result = await runCommand("/bin/bash", [NEMOCLAW_SETUP, sandboxName], env)
|
||||
const result = await runCommand("/bin/bash", [setupPath, sandboxName], env)
|
||||
|
||||
if (!result.ok) {
|
||||
return NextResponse.json({
|
||||
@@ -365,7 +359,7 @@ export async function POST(request: Request) {
|
||||
verification,
|
||||
mode: "nemoclaw-blueprint",
|
||||
enableTailscale,
|
||||
setupPath: NEMOCLAW_SETUP,
|
||||
setupPath,
|
||||
hostPath: HOST_PATH,
|
||||
readiness: {
|
||||
attempts: readiness.attempts,
|
||||
|
||||
@@ -2,23 +2,9 @@ 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"
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
const HOME = process.env.HOME || ""
|
||||
const OPENSHELL_BIN = process.env.OPENSHELL_BIN || `${HOME}/.local/bin/openshell`
|
||||
const NEMOCLAW_BIN = process.env.NEMOCLAW_BIN || `${HOME}/NemoClaw/bin/nemoclaw.js`
|
||||
const HOST_PATH = [
|
||||
`${HOME}/.local/bin`,
|
||||
`${HOME}/.nvm/versions/node/v22.22.2/bin`,
|
||||
`${HOME}/.nvm/versions/node/v22.22.1/bin`,
|
||||
"/opt/homebrew/bin",
|
||||
"/usr/local/bin",
|
||||
"/usr/bin",
|
||||
"/bin",
|
||||
"/usr/sbin",
|
||||
"/sbin",
|
||||
process.env.PATH || "",
|
||||
].filter(Boolean).join(":")
|
||||
|
||||
function elapsedMs(start: number) {
|
||||
return Date.now() - start
|
||||
@@ -106,7 +92,7 @@ async function cleanupNemoClawSandbox(sandboxName: string) {
|
||||
console.log(`[sandbox/delete] nemoclaw-cleanup:start sandbox=${sandboxName}`)
|
||||
try {
|
||||
const { stdout, stderr } = await execFileAsync(NEMOCLAW_BIN, [sandboxName, "destroy", "--yes"], {
|
||||
cwd: `${HOME}/NemoClaw`,
|
||||
cwd: NEMOCLAW_CWD,
|
||||
env: {
|
||||
...process.env,
|
||||
PATH: HOST_PATH,
|
||||
|
||||
@@ -3,6 +3,7 @@ import { promisify } from "node:util"
|
||||
import { NextResponse } from "next/server"
|
||||
import { listActivity } from "@/app/lib/activityLog"
|
||||
import { listBackupCatalog } from "@/app/lib/backupCatalog"
|
||||
import { HOST_PATH, OPENSHELL_BIN } from "@/app/lib/hostCommands"
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
|
||||
@@ -12,7 +13,7 @@ async function run(command: string, args: string[]) {
|
||||
try {
|
||||
const { stdout, stderr } = await execFileAsync(command, args, {
|
||||
timeout: 10000,
|
||||
env: { ...process.env, NO_COLOR: "1", CLICOLOR: "0", CLICOLOR_FORCE: "0" },
|
||||
env: { ...process.env, PATH: HOST_PATH, NO_COLOR: "1", CLICOLOR: "0", CLICOLOR_FORCE: "0" },
|
||||
})
|
||||
return { ok: true, stdout: stdout.trim(), stderr: stderr.trim() }
|
||||
} catch (error) {
|
||||
@@ -28,7 +29,7 @@ export async function GET() {
|
||||
const [gitHead, gitStatus, sandboxList, activity, backups] = await Promise.all([
|
||||
run("git", ["rev-parse", "--short", "HEAD"]),
|
||||
run("git", ["status", "--short", "--branch"]),
|
||||
run(process.env.OPENSHELL_BIN || `${process.env.HOME || ""}/.local/bin/openshell`, ["sandbox", "list"]),
|
||||
run(OPENSHELL_BIN, ["sandbox", "list"]),
|
||||
listActivity(75),
|
||||
listBackupCatalog(),
|
||||
])
|
||||
|
||||
@@ -1,55 +1,12 @@
|
||||
import { NextResponse } from "next/server"
|
||||
import { execFile } from "node:child_process"
|
||||
import { existsSync } from "node:fs"
|
||||
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 { resolveRuntimeAuthority } from "@/app/lib/runtimeAuthority"
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
|
||||
const HOME = process.env.HOME || ""
|
||||
|
||||
const NODE_BIN_CANDIDATES = [
|
||||
process.env.NODE_BIN,
|
||||
HOME ? `${HOME}/.nvm/versions/node/v22.22.2/bin/node` : undefined,
|
||||
HOME ? `${HOME}/.nvm/versions/node/v22.22.1/bin/node` : undefined,
|
||||
"/Users/markmckeen/.nvm/versions/node/v22.22.2/bin/node",
|
||||
"/Users/markmckeen/.nvm/versions/node/v22.22.1/bin/node",
|
||||
"/opt/homebrew/bin/node",
|
||||
"/usr/local/bin/node",
|
||||
"/usr/bin/node",
|
||||
].filter((value): value is string => Boolean(value))
|
||||
const NODE_BIN = NODE_BIN_CANDIDATES.find((candidate) => existsSync(candidate)) ?? NODE_BIN_CANDIDATES[0]
|
||||
const NEMOCLAW_BIN_CANDIDATES = [
|
||||
process.env.NEMOCLAW_BIN,
|
||||
HOME ? `${HOME}/.local/bin/nemoclaw` : undefined,
|
||||
HOME ? `${HOME}/.nemoclaw/source/bin/nemoclaw.js` : undefined,
|
||||
HOME ? `${HOME}/NemoClaw/bin/nemoclaw.js` : undefined,
|
||||
HOME ? `${HOME}/.nvm/versions/node/v22.22.2/bin/nemoclaw` : undefined,
|
||||
"/Users/markmckeen/.local/bin/nemoclaw",
|
||||
"/Users/markmckeen/.nemoclaw/source/bin/nemoclaw.js",
|
||||
"/Users/markmckeen/NemoClaw/bin/nemoclaw.js",
|
||||
"/Users/markmckeen/NemoClaw-mmckeen/bin/nemoclaw.js",
|
||||
"/Users/markmckeen/.nvm/versions/node/v22.22.2/bin/nemoclaw",
|
||||
"/usr/local/bin/nemoclaw",
|
||||
"/opt/homebrew/bin/nemoclaw",
|
||||
].filter((value): value is string => Boolean(value))
|
||||
const NEMOCLAW_BIN =
|
||||
NEMOCLAW_BIN_CANDIDATES.find((candidate) => existsSync(candidate)) ?? NEMOCLAW_BIN_CANDIDATES[0]
|
||||
|
||||
const OPENSHELL_BIN_CANDIDATES = [
|
||||
process.env.OPENSHELL_BIN,
|
||||
HOME ? `${HOME}/.local/bin/openshell` : undefined,
|
||||
"/Users/markmckeen/.local/bin/openshell",
|
||||
"/Users/markmckeen/OpenShell/target/release/openshell",
|
||||
"/Users/markmckeen/openshell/target/release/openshell",
|
||||
"/Users/markmckeen/openshell/scripts/bin/openshell",
|
||||
"/usr/local/bin/openshell",
|
||||
"/opt/homebrew/bin/openshell",
|
||||
].filter((value): value is string => Boolean(value))
|
||||
const OPENSHELL_BIN =
|
||||
OPENSHELL_BIN_CANDIDATES.find((candidate) => existsSync(candidate)) ?? OPENSHELL_BIN_CANDIDATES[0]
|
||||
|
||||
type SandboxSummary = {
|
||||
id: string
|
||||
name: string
|
||||
@@ -191,7 +148,7 @@ function buildNemoClawSummary(output: string | null, defaultSandboxNames: Set<st
|
||||
async function execNemoclaw(args: string[]) {
|
||||
const env = {
|
||||
...process.env,
|
||||
PATH: `${process.env.PATH ?? ""}:${HOME ? `${HOME}/.local/bin:${HOME}/.nvm/versions/node/v22.22.2/bin:${HOME}/.nvm/versions/node/v22.22.1/bin:` : ""}/opt/homebrew/bin:/usr/local/bin:/usr/bin`,
|
||||
PATH: HOST_PATH,
|
||||
NO_COLOR: "1",
|
||||
CLICOLOR: "0",
|
||||
CLICOLOR_FORCE: "0",
|
||||
@@ -209,6 +166,7 @@ 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",
|
||||
|
||||
@@ -10,6 +10,10 @@ function quoteEnvValue(value: string) {
|
||||
return JSON.stringify(value)
|
||||
}
|
||||
|
||||
function envKeyMatcher(key: string) {
|
||||
return new RegExp(`^\\s*(?:export\\s+)?${key}\\s*=`)
|
||||
}
|
||||
|
||||
async function readEnvFile() {
|
||||
if (!existsSync(ENV_PATH)) return ""
|
||||
return readFile(ENV_PATH, "utf8")
|
||||
@@ -17,9 +21,22 @@ async function readEnvFile() {
|
||||
|
||||
function upsertEnv(content: string, key: string, value: string) {
|
||||
const line = `${key}=${quoteEnvValue(value)}`
|
||||
const matcher = new RegExp(`^${key}=.*$`, "m")
|
||||
if (matcher.test(content)) return content.replace(matcher, line)
|
||||
return `${content.trimEnd()}${content.trim() ? "\n" : ""}${line}\n`
|
||||
const matcher = envKeyMatcher(key)
|
||||
const lines = content.split(/\r?\n/)
|
||||
let replaced = false
|
||||
const nextLines = lines.filter((existingLine) => {
|
||||
if (!matcher.test(existingLine)) return true
|
||||
if (replaced) return false
|
||||
replaced = true
|
||||
return true
|
||||
}).map((existingLine) => (matcher.test(existingLine) ? line : existingLine))
|
||||
|
||||
if (!replaced) {
|
||||
const trimmed = content.trimEnd()
|
||||
return `${trimmed}${trimmed ? "\n" : ""}${line}\n`
|
||||
}
|
||||
|
||||
return `${nextLines.join("\n").trimEnd()}\n`
|
||||
}
|
||||
|
||||
export function generateToken(bytes = 24) {
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import { existsSync } from "node:fs"
|
||||
import path from "node:path"
|
||||
|
||||
const HOME = process.env.HOME || ""
|
||||
|
||||
function firstExisting(candidates: Array<string | undefined>, fallback: string) {
|
||||
return candidates.filter((value): value is string => Boolean(value)).find((candidate) => existsSync(candidate)) || fallback
|
||||
}
|
||||
|
||||
function pathEntries() {
|
||||
return [
|
||||
process.env.TERMINAL_EXTRA_PATH,
|
||||
HOME ? path.join(HOME, ".local/bin") : undefined,
|
||||
HOME ? path.join(HOME, ".nvm/versions/node/v22.22.2/bin") : undefined,
|
||||
HOME ? path.join(HOME, ".nvm/versions/node/v22.22.1/bin") : undefined,
|
||||
HOME ? path.join(HOME, ".nemoclaw/source/node_modules/.bin") : undefined,
|
||||
HOME ? path.join(HOME, "NemoClaw/node_modules/.bin") : undefined,
|
||||
"/opt/homebrew/bin",
|
||||
"/usr/local/bin",
|
||||
"/usr/bin",
|
||||
"/bin",
|
||||
"/usr/sbin",
|
||||
"/sbin",
|
||||
process.env.PATH,
|
||||
].filter((value): value is string => Boolean(value))
|
||||
}
|
||||
|
||||
export const HOST_PATH = Array.from(new Set(pathEntries())).join(":")
|
||||
|
||||
export const NODE_BIN = firstExisting([
|
||||
process.env.NODE_BIN,
|
||||
HOME ? path.join(HOME, ".nvm/versions/node/v22.22.2/bin/node") : undefined,
|
||||
HOME ? path.join(HOME, ".nvm/versions/node/v22.22.1/bin/node") : undefined,
|
||||
"/opt/homebrew/bin/node",
|
||||
"/usr/local/bin/node",
|
||||
"/usr/bin/node",
|
||||
], "node")
|
||||
|
||||
export const OPENSHELL_BIN = firstExisting([
|
||||
process.env.OPENSHELL_BIN,
|
||||
HOME ? path.join(HOME, ".local/bin/openshell") : undefined,
|
||||
"/opt/homebrew/bin/openshell",
|
||||
"/usr/local/bin/openshell",
|
||||
], "openshell")
|
||||
|
||||
export const OPENCLAW_BIN = firstExisting([
|
||||
process.env.OPENCLAW_BIN,
|
||||
HOME ? path.join(HOME, ".local/bin/openclaw") : undefined,
|
||||
HOME ? path.join(HOME, ".nemoclaw/source/node_modules/.bin/openclaw") : undefined,
|
||||
HOME ? path.join(HOME, "NemoClaw/node_modules/.bin/openclaw") : undefined,
|
||||
"/opt/homebrew/bin/openclaw",
|
||||
"/usr/local/bin/openclaw",
|
||||
], "openclaw")
|
||||
|
||||
export const NEMOCLAW_BIN = firstExisting([
|
||||
process.env.NEMOCLAW_BIN,
|
||||
HOME ? path.join(HOME, ".local/bin/nemoclaw") : undefined,
|
||||
HOME ? path.join(HOME, ".nemoclaw/source/bin/nemoclaw.js") : undefined,
|
||||
HOME ? path.join(HOME, "NemoClaw/bin/nemoclaw.js") : undefined,
|
||||
HOME ? path.join(HOME, ".nvm/versions/node/v22.22.2/bin/nemoclaw") : undefined,
|
||||
"/opt/homebrew/bin/nemoclaw",
|
||||
"/usr/local/bin/nemoclaw",
|
||||
], "nemoclaw")
|
||||
|
||||
export const NEMOCLAW_SETUP = firstExisting([
|
||||
process.env.NEMOCLAW_SETUP,
|
||||
HOME ? path.join(HOME, ".nemoclaw/source/scripts/setup.sh") : undefined,
|
||||
HOME ? path.join(HOME, "NemoClaw/scripts/setup.sh") : undefined,
|
||||
], "")
|
||||
|
||||
export const NEMOCLAW_CWD = firstExisting([
|
||||
process.env.NEMOCLAW_CWD,
|
||||
HOME ? path.join(HOME, ".nemoclaw/source") : undefined,
|
||||
HOME ? path.join(HOME, "NemoClaw") : undefined,
|
||||
], process.cwd())
|
||||
|
||||
export function commandExists(command: string) {
|
||||
return command.includes("/") ? existsSync(command) : true
|
||||
}
|
||||
@@ -1,33 +1,9 @@
|
||||
import { execFile, spawn } from "node:child_process"
|
||||
import { existsSync } from "node:fs"
|
||||
import { promisify } from "node:util"
|
||||
import { HOST_PATH, OPENCLAW_BIN, OPENSHELL_BIN } from "./hostCommands"
|
||||
import { getDefaultOpenClawInstance, getOpenClawDashboardPortForSandbox, resolveOpenClawInstance } from "./openclawInstances"
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
|
||||
const OPENSHELL_BIN_CANDIDATES = [
|
||||
process.env.OPENSHELL_BIN,
|
||||
process.env.HOME ? `${process.env.HOME}/.local/bin/openshell` : undefined,
|
||||
"/Users/markmckeen/.local/bin/openshell",
|
||||
"/Users/markmckeen/OpenShell/target/release/openshell",
|
||||
"/Users/markmckeen/openshell/target/release/openshell",
|
||||
"/Users/markmckeen/openshell/scripts/bin/openshell",
|
||||
"/usr/local/bin/openshell",
|
||||
"/opt/homebrew/bin/openshell",
|
||||
].filter((value): value is string => Boolean(value))
|
||||
|
||||
const OPENCLAW_BIN_CANDIDATES = [
|
||||
process.env.OPENCLAW_BIN,
|
||||
process.env.HOME ? `${process.env.HOME}/NemoClaw/node_modules/.bin/openclaw` : undefined,
|
||||
process.env.HOME ? `${process.env.HOME}/.local/bin/openclaw` : undefined,
|
||||
"/usr/local/bin/openclaw",
|
||||
"/opt/homebrew/bin/openclaw",
|
||||
].filter((value): value is string => Boolean(value))
|
||||
|
||||
const OPENSHELL_BIN =
|
||||
OPENSHELL_BIN_CANDIDATES.find((candidate) => existsSync(candidate)) ?? OPENSHELL_BIN_CANDIDATES[0]
|
||||
const OPENCLAW_BIN =
|
||||
OPENCLAW_BIN_CANDIDATES.find((candidate) => existsSync(candidate)) ?? OPENCLAW_BIN_CANDIDATES[0] ?? "openclaw"
|
||||
const OPENSHELL_GATEWAY = process.env.OPENSHELL_GATEWAY || "openshell"
|
||||
const OPENSHELL_NAMESPACE = "agent-sandbox-system"
|
||||
const SANDBOX_DASHBOARD_REMOTE_PORT = Number.parseInt(process.env.OPENCLAW_SANDBOX_DASHBOARD_REMOTE_PORT || "18789", 10)
|
||||
@@ -70,6 +46,7 @@ export 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",
|
||||
@@ -80,9 +57,7 @@ export async function execOpenShell(args: string[]) {
|
||||
|
||||
function buildOpenClawEnv() {
|
||||
const pathEntries = [
|
||||
process.env.HOME ? `${process.env.HOME}/NemoClaw/node_modules/.bin` : null,
|
||||
process.env.HOME ? `${process.env.HOME}/.local/bin` : null,
|
||||
process.env.PATH,
|
||||
HOST_PATH,
|
||||
].filter(Boolean)
|
||||
|
||||
return {
|
||||
|
||||
+1
-12
@@ -1,19 +1,8 @@
|
||||
import { spawn } from "node:child_process"
|
||||
import path from "node:path"
|
||||
import { HOST_PATH, OPENSHELL_BIN } from "./hostCommands"
|
||||
import { resolveSandboxRef } from "./openshellHost"
|
||||
|
||||
const HOME = process.env.HOME || ""
|
||||
const OPENSHELL_BIN = process.env.OPENSHELL_BIN || `${HOME}/.local/bin/openshell`
|
||||
const HOST_PATH = [
|
||||
`${HOME}/.local/bin`,
|
||||
`${HOME}/.nvm/versions/node/v22.22.2/bin`,
|
||||
`${HOME}/.nvm/versions/node/v22.22.1/bin`,
|
||||
"/usr/local/bin",
|
||||
"/usr/bin",
|
||||
"/bin",
|
||||
process.env.PATH || "",
|
||||
].filter(Boolean).join(":")
|
||||
|
||||
export const MAX_FILE_BYTES = Number.parseInt(process.env.SANDBOX_FILE_TRANSFER_MAX_BYTES || String(128 * 1024 * 1024), 10)
|
||||
export const MAX_MULTIPART_REQUEST_BYTES = MAX_FILE_BYTES + Math.min(10 * 1024 * 1024, Math.max(1024 * 1024, Math.floor(MAX_FILE_BYTES / 10)))
|
||||
const ALLOWED_ROOTS = ["/sandbox", "/tmp"]
|
||||
|
||||
@@ -1,21 +1,11 @@
|
||||
import { execFile, spawn } from "node:child_process"
|
||||
import { promisify } from "node:util"
|
||||
import { HOST_PATH, OPENSHELL_BIN } from "./hostCommands"
|
||||
import { getSandboxInferenceConfig, type SandboxInferenceRoute } from "./sandboxInferenceStore"
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
const HOME = process.env.HOME || ""
|
||||
const OPENSHELL_BIN = process.env.OPENSHELL_BIN || `${HOME}/.local/bin/openshell`
|
||||
const DOCKER_BIN = process.env.DOCKER_BIN || "docker"
|
||||
const OPENSHELL_CLUSTER_CONTAINER = process.env.OPENSHELL_CLUSTER_CONTAINER || "openshell-cluster-nemoclaw"
|
||||
const HOST_PATH = [
|
||||
`${HOME}/.local/bin`,
|
||||
`${HOME}/.nvm/versions/node/v22.22.2/bin`,
|
||||
`${HOME}/.nvm/versions/node/v22.22.1/bin`,
|
||||
"/usr/local/bin",
|
||||
"/usr/bin",
|
||||
"/bin",
|
||||
process.env.PATH || "",
|
||||
].filter(Boolean).join(":")
|
||||
|
||||
function modelEntry(route: SandboxInferenceRoute, openClawModelRef: string, compat: Record<string, unknown> | null) {
|
||||
return {
|
||||
|
||||
@@ -1,19 +1,9 @@
|
||||
import { execFile } from "node:child_process"
|
||||
import { promisify } from "node:util"
|
||||
import { HOST_PATH, OPENSHELL_BIN } from "./hostCommands"
|
||||
import { resolveSandboxRef } from "./openshellHost"
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
const HOME = process.env.HOME || ""
|
||||
const OPENSHELL_BIN = process.env.OPENSHELL_BIN || `${HOME}/.local/bin/openshell`
|
||||
const HOST_PATH = [
|
||||
`${HOME}/.local/bin`,
|
||||
`${HOME}/.nvm/versions/node/v22.22.2/bin`,
|
||||
`${HOME}/.nvm/versions/node/v22.22.1/bin`,
|
||||
"/usr/local/bin",
|
||||
"/usr/bin",
|
||||
"/bin",
|
||||
process.env.PATH || "",
|
||||
].filter(Boolean).join(":")
|
||||
|
||||
export type SandboxNetworkRule = {
|
||||
chunkId: string
|
||||
|
||||
@@ -135,7 +135,9 @@ function OperatorTerminalInner() {
|
||||
})
|
||||
const result = await response.json()
|
||||
if (!response.ok || !result.ok) {
|
||||
throw new Error(result.error || 'Failed to initialize live terminal session.')
|
||||
setTerminalState('error')
|
||||
setTerminalStatus(result.error || 'Failed to initialize live terminal session.')
|
||||
return
|
||||
}
|
||||
liveSessionIdRef.current = result.sessionId
|
||||
setLiveSession({
|
||||
|
||||
Reference in New Issue
Block a user