Fix sandbox delete and inference routing
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
import { NextResponse } from "next/server"
|
import { NextResponse } from "next/server"
|
||||||
import { execFile } from "node:child_process"
|
import { execFile } from "node:child_process"
|
||||||
|
import { mkdir, readFile, writeFile } from "node:fs/promises"
|
||||||
|
import path from "node:path"
|
||||||
import { promisify } from "node:util"
|
import { promisify } from "node:util"
|
||||||
import { resolveSandboxRef } from "@/app/lib/openshellHost"
|
import { resolveSandboxRef } from "@/app/lib/openshellHost"
|
||||||
import { NEMOCLAW_BIN, NEMOCLAW_CWD, OPENSHELL_BIN, hostCommandEnv } from "@/app/lib/hostCommands"
|
import { OPENSHELL_BIN, hostCommandEnv } from "@/app/lib/hostCommands"
|
||||||
|
|
||||||
const execFileAsync = promisify(execFile)
|
const execFileAsync = promisify(execFile)
|
||||||
|
|
||||||
@@ -82,56 +84,46 @@ function isGatewayRecoverable(output: string) {
|
|||||||
return /Unknown gateway|Deploy it first|transport error|tcp connect error|Connection refused|invalid peer certificate|BadSignature/i.test(output)
|
return /Unknown gateway|Deploy it first|transport error|tcp connect error|Connection refused|invalid peer certificate|BadSignature/i.test(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidNemoClawSandboxName(value: string) {
|
const NEMOCLAW_REGISTRY_PATH = path.join(process.env.HOME || "/tmp", ".nemoclaw", "sandboxes.json")
|
||||||
return /^[a-z][a-z0-9-]*[a-z0-9]$|^[a-z]$/.test(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
function isNemoClawSandboxNotRegistered(output: string, sandboxName: string) {
|
|
||||||
return new RegExp(`Unknown command:\\s*${sandboxName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i").test(output)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function cleanupNemoClawSandbox(sandboxName: string) {
|
async function cleanupNemoClawSandbox(sandboxName: string) {
|
||||||
if (!isValidNemoClawSandboxName(sandboxName)) {
|
try {
|
||||||
|
const raw = await readFile(NEMOCLAW_REGISTRY_PATH, "utf8")
|
||||||
|
const registry = JSON.parse(raw)
|
||||||
|
const sandboxes = registry && typeof registry === "object" && registry.sandboxes && typeof registry.sandboxes === "object"
|
||||||
|
? registry.sandboxes
|
||||||
|
: {}
|
||||||
|
const existed = Object.prototype.hasOwnProperty.call(sandboxes, sandboxName)
|
||||||
|
if (existed) delete sandboxes[sandboxName]
|
||||||
|
const remaining = Object.keys(sandboxes)
|
||||||
|
const defaultSandbox = registry.defaultSandbox === sandboxName
|
||||||
|
? remaining[0] || null
|
||||||
|
: (registry.defaultSandbox && sandboxes[registry.defaultSandbox] ? registry.defaultSandbox : remaining[0] || null)
|
||||||
|
const next = { ...registry, sandboxes, defaultSandbox }
|
||||||
|
await mkdir(path.dirname(NEMOCLAW_REGISTRY_PATH), { recursive: true, mode: 0o700 })
|
||||||
|
await writeFile(NEMOCLAW_REGISTRY_PATH, `${JSON.stringify(next, null, 2)}\n`, { mode: 0o600 })
|
||||||
return {
|
return {
|
||||||
ok: true as const,
|
ok: true as const,
|
||||||
stdout: "",
|
stdout: "",
|
||||||
stderr: "",
|
stderr: "",
|
||||||
note: "Skipped NemoClaw registry cleanup because the target is not a valid NemoClaw sandbox name.",
|
note: existed
|
||||||
|
? "Pruned NemoClaw registry entry without destroying the shared OpenShell gateway."
|
||||||
|
: "NemoClaw registry already had no matching sandbox entry.",
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {
|
||||||
|
const message = error instanceof Error ? error.message : String(error ?? "NemoClaw registry cleanup failed")
|
||||||
const startedAt = Date.now()
|
if (/ENOENT/.test(message)) {
|
||||||
console.log(`[sandbox/delete] nemoclaw-cleanup:start sandbox=${sandboxName}`)
|
|
||||||
try {
|
|
||||||
const { stdout, stderr } = await execFileAsync(NEMOCLAW_BIN, [sandboxName, "destroy", "--yes"], {
|
|
||||||
cwd: NEMOCLAW_CWD,
|
|
||||||
env: hostCommandEnv({
|
|
||||||
OPENSHELL_GATEWAY: process.env.OPENSHELL_GATEWAY || "nemoclaw",
|
|
||||||
}),
|
|
||||||
timeout: 90000,
|
|
||||||
maxBuffer: 20 * 1024 * 1024,
|
|
||||||
})
|
|
||||||
console.log(`[sandbox/delete] nemoclaw-cleanup:done sandbox=${sandboxName} elapsedMs=${elapsedMs(startedAt)}`)
|
|
||||||
return { ok: true as const, stdout: String(stdout).trim(), stderr: String(stderr).trim() }
|
|
||||||
} catch (error: any) {
|
|
||||||
const message = error instanceof Error ? error.message : String(error ?? "NemoClaw cleanup failed")
|
|
||||||
const stdout = String(error?.stdout || "").trim()
|
|
||||||
const stderr = String(error?.stderr || "").trim()
|
|
||||||
const output = [message, stdout, stderr].filter(Boolean).join("\n")
|
|
||||||
if (isNemoClawSandboxNotRegistered(output, sandboxName)) {
|
|
||||||
console.log(`[sandbox/delete] nemoclaw-cleanup:already-gone sandbox=${sandboxName} elapsedMs=${elapsedMs(startedAt)}`)
|
|
||||||
return {
|
return {
|
||||||
ok: true as const,
|
ok: true as const,
|
||||||
stdout,
|
stdout: "",
|
||||||
stderr,
|
stderr: "",
|
||||||
note: "NemoClaw registry already had no matching sandbox.",
|
note: "NemoClaw registry file does not exist; skipped registry cleanup.",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(`[sandbox/delete] nemoclaw-cleanup:error sandbox=${sandboxName} elapsedMs=${elapsedMs(startedAt)} message=${message}`)
|
|
||||||
return {
|
return {
|
||||||
ok: false as const,
|
ok: false as const,
|
||||||
stdout,
|
stdout: "",
|
||||||
stderr,
|
stderr: "",
|
||||||
error: message,
|
error: message,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export default function InferenceEndpointPanel() {
|
|||||||
const [system, setSystem] = useState<InferenceRoute>(emptyRoute)
|
const [system, setSystem] = useState<InferenceRoute>(emptyRoute)
|
||||||
const [name, setName] = useState("vllm-local")
|
const [name, setName] = useState("vllm-local")
|
||||||
const [type, setType] = useState("openai")
|
const [type, setType] = useState("openai")
|
||||||
const [model, setModel] = useState("nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4")
|
const [model, setModel] = useState("vllm-local")
|
||||||
const [baseUrl, setBaseUrl] = useState("http://host.docker.internal:8000/v1")
|
const [baseUrl, setBaseUrl] = useState("http://host.docker.internal:8000/v1")
|
||||||
const [credentialKey, setCredentialKey] = useState("OPENAI_API_KEY")
|
const [credentialKey, setCredentialKey] = useState("OPENAI_API_KEY")
|
||||||
const [apiKey, setApiKey] = useState("")
|
const [apiKey, setApiKey] = useState("")
|
||||||
@@ -143,7 +143,7 @@ export default function InferenceEndpointPanel() {
|
|||||||
function useVllmPreset() {
|
function useVllmPreset() {
|
||||||
setName("vllm-local")
|
setName("vllm-local")
|
||||||
setType("openai")
|
setType("openai")
|
||||||
setModel("nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4")
|
setModel("vllm-local")
|
||||||
setBaseUrl("http://host.docker.internal:8000/v1")
|
setBaseUrl("http://host.docker.internal:8000/v1")
|
||||||
setCredentialKey("OPENAI_API_KEY")
|
setCredentialKey("OPENAI_API_KEY")
|
||||||
setApiKey("")
|
setApiKey("")
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ const execFileAsync = promisify(execFile)
|
|||||||
const DOCKER_BIN = process.env.DOCKER_BIN || "docker"
|
const DOCKER_BIN = process.env.DOCKER_BIN || "docker"
|
||||||
const OPENSHELL_CLUSTER_CONTAINER = process.env.OPENSHELL_CLUSTER_CONTAINER || "openshell-cluster-nemoclaw"
|
const OPENSHELL_CLUSTER_CONTAINER = process.env.OPENSHELL_CLUSTER_CONTAINER || "openshell-cluster-nemoclaw"
|
||||||
|
|
||||||
function modelEntry(route: SandboxInferenceRoute, compat: Record<string, unknown> | null) {
|
function modelEntry(modelId: string, modelName: string, compat: Record<string, unknown> | null) {
|
||||||
return {
|
return {
|
||||||
...(compat ? { compat } : {}),
|
...(compat ? { compat } : {}),
|
||||||
id: route.model,
|
id: modelId,
|
||||||
name: route.model,
|
name: modelName,
|
||||||
reasoning: false,
|
reasoning: false,
|
||||||
input: ["text"],
|
input: ["text"],
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||||
@@ -20,11 +20,31 @@ function modelEntry(route: SandboxInferenceRoute, compat: Record<string, unknown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveInferenceModelIdentity(route: SandboxInferenceRoute) {
|
||||||
|
const nvidiaModel = route.model.match(/^nvidia\/(.+)$/i)
|
||||||
|
if (nvidiaModel) {
|
||||||
|
return {
|
||||||
|
providerKey: "nvidia",
|
||||||
|
modelId: nvidiaModel[1],
|
||||||
|
modelName: route.model,
|
||||||
|
modelRef: route.model,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
providerKey: "inference",
|
||||||
|
modelId: route.model,
|
||||||
|
modelName: route.model,
|
||||||
|
modelRef: `inference/${route.model}`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function resolveOpenClawRoute(route: SandboxInferenceRoute) {
|
function resolveOpenClawRoute(route: SandboxInferenceRoute) {
|
||||||
switch (route.provider) {
|
switch (route.provider) {
|
||||||
case "openai-api":
|
case "openai-api":
|
||||||
return {
|
return {
|
||||||
providerKey: "openai",
|
providerKey: "openai",
|
||||||
|
modelId: route.model,
|
||||||
|
modelName: route.model,
|
||||||
modelRef: `openai/${route.model}`,
|
modelRef: `openai/${route.model}`,
|
||||||
baseUrl: "https://inference.local/v1",
|
baseUrl: "https://inference.local/v1",
|
||||||
api: "openai-completions",
|
api: "openai-completions",
|
||||||
@@ -34,6 +54,8 @@ function resolveOpenClawRoute(route: SandboxInferenceRoute) {
|
|||||||
case "compatible-anthropic-endpoint":
|
case "compatible-anthropic-endpoint":
|
||||||
return {
|
return {
|
||||||
providerKey: "anthropic",
|
providerKey: "anthropic",
|
||||||
|
modelId: route.model,
|
||||||
|
modelName: route.model,
|
||||||
modelRef: `anthropic/${route.model}`,
|
modelRef: `anthropic/${route.model}`,
|
||||||
baseUrl: "https://inference.local",
|
baseUrl: "https://inference.local",
|
||||||
api: "anthropic-messages",
|
api: "anthropic-messages",
|
||||||
@@ -41,27 +63,29 @@ function resolveOpenClawRoute(route: SandboxInferenceRoute) {
|
|||||||
}
|
}
|
||||||
case "bedrock":
|
case "bedrock":
|
||||||
case "compatible-endpoint":
|
case "compatible-endpoint":
|
||||||
case "gemini-api":
|
case "gemini-api": {
|
||||||
|
const identity = resolveInferenceModelIdentity(route)
|
||||||
return {
|
return {
|
||||||
providerKey: "inference",
|
...identity,
|
||||||
modelRef: `inference/${route.model}`,
|
|
||||||
baseUrl: "https://inference.local/v1",
|
baseUrl: "https://inference.local/v1",
|
||||||
api: "openai-completions",
|
api: "openai-completions",
|
||||||
compat: { supportsStore: false },
|
compat: { supportsStore: false },
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case "nvidia-prod":
|
case "nvidia-prod":
|
||||||
case "nvidia-nim":
|
case "nvidia-nim":
|
||||||
case "ollama-local":
|
case "ollama-local":
|
||||||
case "vllm-local":
|
case "vllm-local":
|
||||||
default:
|
default: {
|
||||||
|
const identity = resolveInferenceModelIdentity(route)
|
||||||
return {
|
return {
|
||||||
providerKey: "inference",
|
...identity,
|
||||||
modelRef: `inference/${route.model}`,
|
|
||||||
baseUrl: "https://inference.local/v1",
|
baseUrl: "https://inference.local/v1",
|
||||||
api: "openai-completions",
|
api: "openai-completions",
|
||||||
compat: null,
|
compat: null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildOpenClawConfig(current: any, routes: SandboxInferenceRoute[], primary: SandboxInferenceRoute) {
|
function buildOpenClawConfig(current: any, routes: SandboxInferenceRoute[], primary: SandboxInferenceRoute) {
|
||||||
@@ -78,7 +102,7 @@ function buildOpenClawConfig(current: any, routes: SandboxInferenceRoute[], prim
|
|||||||
api: resolved.api,
|
api: resolved.api,
|
||||||
models: [],
|
models: [],
|
||||||
}
|
}
|
||||||
providers[resolved.providerKey].models.push(modelEntry(route, resolved.compat))
|
providers[resolved.providerKey].models.push(modelEntry(resolved.modelId, resolved.modelName, resolved.compat))
|
||||||
if (route.id === primary.id) primaryModelRef = resolved.modelRef
|
if (route.id === primary.id) primaryModelRef = resolved.modelRef
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,12 +79,11 @@ assert.match(hostCommandsSource, /export function hostCommandEnv/, 'host command
|
|||||||
assert.match(hostCommandsSource, /XDG_CONFIG_HOME/, 'shared host command environment must preserve the OpenShell config home')
|
assert.match(hostCommandsSource, /XDG_CONFIG_HOME/, 'shared host command environment must preserve the OpenShell config home')
|
||||||
assert.match(deleteRouteSource, /waitForSandboxDeleted/, 'delete route must poll authoritative inventory until the sandbox is gone')
|
assert.match(deleteRouteSource, /waitForSandboxDeleted/, 'delete route must poll authoritative inventory until the sandbox is gone')
|
||||||
assert.match(deleteRouteSource, /cleanupNemoClawSandbox/, 'delete route must clean up NemoClaw registry state after deleting from OpenShell')
|
assert.match(deleteRouteSource, /cleanupNemoClawSandbox/, 'delete route must clean up NemoClaw registry state after deleting from OpenShell')
|
||||||
assert.match(deleteRouteSource, /\[sandboxName, "destroy", "--yes"\]/, 'delete route must run the non-interactive NemoClaw destroy workflow')
|
assert.doesNotMatch(deleteRouteSource, /\[sandboxName, "destroy", "--yes"\]|gateway", "destroy"|cleanupGatewayAfterLastSandbox/, 'delete route must not run NemoClaw destroy or destroy the shared gateway when deleting the last sandbox')
|
||||||
|
assert.match(deleteRouteSource, /Pruned NemoClaw registry entry without destroying the shared OpenShell gateway/, 'delete route must prune registry state without tearing down the shared gateway')
|
||||||
assert.match(deleteRouteSource, /openShellAlreadyGone/, 'delete route must tolerate sandboxes that OpenShell already deleted while NemoClaw still has registry state')
|
assert.match(deleteRouteSource, /openShellAlreadyGone/, 'delete route must tolerate sandboxes that OpenShell already deleted while NemoClaw still has registry state')
|
||||||
assert.match(deleteRouteSource, /isNemoClawSandboxNotRegistered/, 'delete route must tolerate NemoClaw registry entries that were already cleaned up')
|
|
||||||
assert.match(deleteRouteSource, /isGatewayRecoverable/, 'delete route must detect recoverable OpenShell gateway failures')
|
assert.match(deleteRouteSource, /isGatewayRecoverable/, 'delete route must detect recoverable OpenShell gateway failures')
|
||||||
assert.match(deleteRouteSource, /recoverableGateway/, 'delete failures must tell the UI when gateway repair can recover the operation')
|
assert.match(deleteRouteSource, /recoverableGateway/, 'delete failures must tell the UI when gateway repair can recover the operation')
|
||||||
assert.match(deleteRouteSource, /Skipped NemoClaw registry cleanup/, 'delete route must not pass UUID-style refs into NemoClaw cleanup')
|
|
||||||
assert.match(telemetryRouteSource, /const names = parseOpenShellSandboxNames\(sandboxListStdout\)/, 'telemetry must derive inventory from OpenShell before consulting NemoClaw')
|
assert.match(telemetryRouteSource, /const names = parseOpenShellSandboxNames\(sandboxListStdout\)/, 'telemetry must derive inventory from OpenShell before consulting NemoClaw')
|
||||||
assert.match(telemetryRouteSource, /names\.length > 0[\s\S]*execNemoclaw\(\["list"\]\)[\s\S]*execNemoclaw\(\["status"\]\)/, 'telemetry must skip NemoClaw list/status when OpenShell reports zero live sandboxes')
|
assert.match(telemetryRouteSource, /names\.length > 0[\s\S]*execNemoclaw\(\["list"\]\)[\s\S]*execNemoclaw\(\["status"\]\)/, 'telemetry must skip NemoClaw list/status when OpenShell reports zero live sandboxes')
|
||||||
assert.match(inferenceRouteSource, /\["provider", "create", "--name", name, "--type", type\]/, 'inference route must create OpenShell providers')
|
assert.match(inferenceRouteSource, /\["provider", "create", "--name", name, "--type", type\]/, 'inference route must create OpenShell providers')
|
||||||
@@ -102,6 +101,7 @@ assert.match(inferencePanelSource, /INFERENCE ENDPOINTS/, 'settings UI must expo
|
|||||||
assert.doesNotMatch(inferencePanelSource, /NVIDIA Preset|useNvidiaInferencePreset|aws\/anthropic\/claude-opus-4-5/, 'settings UI must not expose NVIDIA-corp-specific inference presets')
|
assert.doesNotMatch(inferencePanelSource, /NVIDIA Preset|useNvidiaInferencePreset|aws\/anthropic\/claude-opus-4-5/, 'settings UI must not expose NVIDIA-corp-specific inference presets')
|
||||||
assert.match(inferencePanelSource, /useVllmPreset/, 'settings UI must expose a vLLM endpoint preset')
|
assert.match(inferencePanelSource, /useVllmPreset/, 'settings UI must expose a vLLM endpoint preset')
|
||||||
assert.match(inferencePanelSource, /host\.docker\.internal:8000\/v1/, 'vLLM preset must point at the host vLLM OpenAI-compatible endpoint')
|
assert.match(inferencePanelSource, /host\.docker\.internal:8000\/v1/, 'vLLM preset must point at the host vLLM OpenAI-compatible endpoint')
|
||||||
|
assert.doesNotMatch(inferencePanelSource, /nvidia\/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4/, 'settings UI must not default rebuilt inference routes to the NVIDIA Nemotron model')
|
||||||
assert.match(inferencePanelSource, /method: "DELETE"/, 'settings UI must expose provider deletion')
|
assert.match(inferencePanelSource, /method: "DELETE"/, 'settings UI must expose provider deletion')
|
||||||
assert.match(inferencePanelSource, /\/api\/ollama\/models/, 'settings UI must poll local Ollama models')
|
assert.match(inferencePanelSource, /\/api\/ollama\/models/, 'settings UI must poll local Ollama models')
|
||||||
assert.match(inferencePanelSource, /window\.setInterval\(\(\) => loadOllamaModels\(\{ silent: true \}\), 10000\)/, 'settings UI must autopoll Ollama while selected')
|
assert.match(inferencePanelSource, /window\.setInterval\(\(\) => loadOllamaModels\(\{ silent: true \}\), 10000\)/, 'settings UI must autopoll Ollama while selected')
|
||||||
@@ -125,7 +125,8 @@ assert.match(sandboxInferencePanelSource, /Add Route/, 'selected sandbox UI must
|
|||||||
assert.match(sandboxInferenceApplyLibSource, /\/sandbox\/\.openclaw\/openclaw\.json/, 'live apply must patch OpenClaw config inside the running sandbox')
|
assert.match(sandboxInferenceApplyLibSource, /\/sandbox\/\.openclaw\/openclaw\.json/, 'live apply must patch OpenClaw config inside the running sandbox')
|
||||||
assert.match(sandboxInferenceApplyLibSource, /sha256sum \/sandbox\/\.openclaw\/openclaw\.json > \/sandbox\/\.openclaw\/\.config-hash/, 'live apply must refresh the immutable OpenClaw config hash')
|
assert.match(sandboxInferenceApplyLibSource, /sha256sum \/sandbox\/\.openclaw\/openclaw\.json > \/sandbox\/\.openclaw\/\.config-hash/, 'live apply must refresh the immutable OpenClaw config hash')
|
||||||
assert.match(sandboxInferenceApplyLibSource, /\["inference", "set", "--no-verify", "--provider", primary\.provider, "--model", primary\.model\]/, 'live apply must point OpenShell inference at the primary route')
|
assert.match(sandboxInferenceApplyLibSource, /\["inference", "set", "--no-verify", "--provider", primary\.provider, "--model", primary\.model\]/, 'live apply must point OpenShell inference at the primary route')
|
||||||
assert.match(sandboxInferenceApplyLibSource, /name: route\.model/, 'live apply must keep model display names raw while primary refs remain provider-qualified')
|
assert.match(sandboxInferenceApplyLibSource, /resolveInferenceModelIdentity/, 'live apply must normalize provider/model identities for OpenClaw inference routes')
|
||||||
|
assert.match(sandboxInferenceApplyLibSource, /providerKey: "nvidia"[\s\S]*modelRef: route\.model/, 'live apply must preserve nvidia/... model refs without wrapping them as inference/...')
|
||||||
assert.doesNotMatch(sandboxRestartRouteSource, /delete", "pod"|kubectl delete/, 'restart route must not delete the backing sandbox pod')
|
assert.doesNotMatch(sandboxRestartRouteSource, /delete", "pod"|kubectl delete/, 'restart route must not delete the backing sandbox pod')
|
||||||
assert.match(sandboxRestartRouteSource, /restartMode: "openclaw-runtime"/, 'restart route must restart only the in-sandbox OpenClaw runtime')
|
assert.match(sandboxRestartRouteSource, /restartMode: "openclaw-runtime"/, 'restart route must restart only the in-sandbox OpenClaw runtime')
|
||||||
assert.match(sandboxRestartRouteSource, /waitForSandboxReady\(sandboxName, 15000, 1000\)/, 'restart route must verify OpenShell reports the sandbox ready before runtime restart')
|
assert.match(sandboxRestartRouteSource, /waitForSandboxReady\(sandboxName, 15000, 1000\)/, 'restart route must verify OpenShell reports the sandbox ready before runtime restart')
|
||||||
|
|||||||
Reference in New Issue
Block a user