Skip to content
Merged
38 changes: 37 additions & 1 deletion test/e2e-scenario/fixtures/phases/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export interface OnboardingExpectedFailure {
export interface NemoClawInstance {
onboarding: string;
sandboxName: string;
agent: "openclaw" | "hermes";
agent: "openclaw" | "hermes" | "langchain-deepagents-code";
provider: "nvidia" | "ollama";
providerEnv: "cloud" | "local";
platformOs?: "ubuntu" | "macos" | "windows";
Expand Down Expand Up @@ -180,6 +180,9 @@ export class OnboardingPhaseFixture {
case "cloud-openclaw-no-docker":
result = await this.cloudOpenClawNoDocker(environment, options);
break;
case "cloud-langchain-deepagents-code":
result = await this.cloudLangchainDeepAgentsCode(environment, options);
break;
default:
throw new Error(`Unsupported onboarding profile '${environment.onboarding}'.`);
}
Expand Down Expand Up @@ -219,6 +222,39 @@ export class OnboardingPhaseFixture {
};
}

async cloudLangchainDeepAgentsCode(
environment: EnvironmentReady,
options: OnboardingOptions = {},
): Promise<NemoClawInstance> {
if (!environment.docker.available) {
throw new Error(
"cloud-langchain-deepagents-code onboarding requires an available Docker runtime.",
);
}
const sandboxName = sandboxNameFromOptions(environment.onboarding, options);
const apiKey = this.secrets.required("NVIDIA_INFERENCE_API_KEY");
this.registerSandboxCleanup(sandboxName);
const result = await this.host.nemoclaw(ONBOARD_ARGS, {
artifactName: "onboard-cloud-langchain-deepagents-code",
env: commandEnv(sandboxName, {
NEMOCLAW_AGENT: "langchain-deepagents-code",
NVIDIA_INFERENCE_API_KEY: apiKey,
}),
redactionValues: [apiKey],
timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
});
assertExitZero(result, "cloud-langchain-deepagents-code onboarding");
return {
onboarding: environment.onboarding,
sandboxName,
agent: "langchain-deepagents-code",
provider: "nvidia",
providerEnv: "cloud",
gatewayUrl: OPENCLAW_GATEWAY_URL,
result,
};
}

async cloudOpenClawNoDocker(
environment: EnvironmentReady,
options: OnboardingOptions = {},
Expand Down
46 changes: 45 additions & 1 deletion test/e2e-scenario/live/gpu-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,41 @@ import {

const TIMEOUT_MS = 75 * 60_000;

function asRecord(value: unknown): Record<string, unknown> | undefined {
return value && typeof value === "object" && !Array.isArray(value)
? (value as Record<string, unknown>)
: undefined;
}

function assertSmallContextCompactionPolicy(configText: string): void {
const config = asRecord(JSON.parse(configText));
const agents = asRecord(config?.agents);
const defaults = asRecord(agents?.defaults);
const compaction = asRecord(defaults?.compaction);
const modelsRoot = asRecord(config?.models);
const providers = asRecord(modelsRoot?.providers);
const model = Object.values(providers ?? {})
.flatMap((provider) => {
const models = asRecord(provider)?.models;
return Array.isArray(models) ? models : [];
})
.map(asRecord)
.find(Boolean);

expect(typeof model?.contextWindow).toBe("number");
expect(typeof model?.maxTokens).toBe("number");
const contextWindow = model?.contextWindow;
const maxTokens = model?.maxTokens;
if (typeof contextWindow !== "number" || typeof maxTokens !== "number") return;
if (contextWindow > 28_000) return;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

const expectedReserve = Math.min(maxTokens, Math.max(0, contextWindow - 8_000));
expect(compaction).toMatchObject({
reserveTokens: expectedReserve,
reserveTokensFloor: expectedReserve,
});
}

test.skipIf(!shouldRunLiveE2EScenarios())(
"GPU Ollama onboard enables CUDA, auth proxy, and sandbox inference",
{ timeout: TIMEOUT_MS },
Expand All @@ -43,7 +78,7 @@ test.skipIf(!shouldRunLiveE2EScenarios())(
sandboxName: SANDBOX_NAME,
delegatedLegacyContracts: [
"Phase 11 shell retirement decides whether uninstall --delete-models remains a separate cleanup lane",
"The #5468 OpenClaw TUI compaction guard remains in the retained legacy shell until a TUI fixture exists",
"The #5468 interactive TUI first-turn smoke remains waived until a TUI fixture exists; this Vitest asserts the baked compaction budget directly",
],
});

Expand Down Expand Up @@ -75,6 +110,15 @@ test.skipIf(!shouldRunLiveE2EScenarios())(
expect(install.exitCode, resultText(install)).toBe(0);
await artifacts.writeText("install-gpu-ollama.log", resultText(install));

const config = await sandbox.execShell(
SANDBOX_NAME,
trustedSandboxShellScript("cat /sandbox/.openclaw/openclaw.json"),
{ artifactName: "sandbox-openclaw-config", env: env(), timeoutMs: 30_000 },
);
expect(config.exitCode, resultText(config)).toBe(0);
await artifacts.writeText("openclaw-config.json", config.stdout);
assertSmallContextCompactionPolicy(config.stdout);

const status = await host.command("node", [CLI, SANDBOX_NAME, "status"], {
artifactName: "status-gpu-ollama",
env: env(),
Expand Down
67 changes: 65 additions & 2 deletions test/e2e-scenario/live/registry-scenarios.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0

import fs from "node:fs";
import os from "node:os";
import path from "node:path";

import { expect, test } from "../fixtures/e2e-test.ts";
import { expect, test, type E2EScenarioFixtures } from "../fixtures/e2e-test.ts";
import type { LifecycleProfile } from "../fixtures/phases/index.ts";
import { listScenarios } from "../scenarios/registry.ts";
import { liveScenarioSupport, liveScenarioTestName } from "../scenarios/runtime-support.ts";
Expand All @@ -16,8 +17,54 @@ function isLifecycleProfile(value: string | undefined): value is LifecycleProfil
return value !== undefined && LIFECYCLE_PROFILES.has(value as LifecycleProfile);
}

function commandEnv(sandboxName: string, extra: NodeJS.ProcessEnv = {}): NodeJS.ProcessEnv {
return {
...process.env,
PATH: `${os.homedir()}/.local/bin:${os.homedir()}/.npm-global/bin:${process.env.PATH ?? ""}`,
NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE: "1",
NEMOCLAW_NON_INTERACTIVE: "1",
NEMOCLAW_SANDBOX_NAME: sandboxName,
OPENSHELL_GATEWAY: "nemoclaw",
...extra,
};
}

async function runE2eCloudExperimentalChecks(
scenarioId: string,
sandboxName: string,
checkScripts: readonly string[],
context: Pick<E2EScenarioFixtures, "artifacts" | "host" | "secrets">,
): Promise<void> {
const apiKey = context.secrets.required("NVIDIA_INFERENCE_API_KEY");
await context.artifacts.writeJson("e2e-cloud-experimental-checks.json", {
scenarioId,
sandboxName,
checkScripts,
});
for (const scriptPath of checkScripts) {
const result = await context.host.command("bash", [path.join(REPO_ROOT, scriptPath)], {
artifactName: `cloud-experimental-${path.basename(scriptPath, ".sh")}`,
cwd: REPO_ROOT,
env: commandEnv(sandboxName, {
CLOUD_EXPERIMENTAL_MODEL: process.env.NEMOCLAW_MODEL,
COMPATIBLE_API_KEY: apiKey,
NEMOCLAW_E2E_CLOUD_API_KEY_ENV: "COMPATIBLE_API_KEY",
REPO: REPO_ROOT,
SANDBOX_NAME: sandboxName,
}),
redactionValues: [apiKey],
timeoutMs: 180_000,
});
expect(result.exitCode, `${scriptPath}: ${result.stdout}\n${result.stderr}`).toBe(0);
}
}

const REPO_ROOT = path.resolve(import.meta.dirname, "../../..");
const CLI_DIST_ENTRYPOINT = path.join(REPO_ROOT, "dist", "nemoclaw.js");
const E2E_CLOUD_EXPERIMENTAL_CHECKS_DIR = path.join(
REPO_ROOT,
"test/e2e/e2e-cloud-experimental/checks",
);
process.env.NEMOCLAW_CLI_BIN ??= path.join(REPO_ROOT, "bin", "nemoclaw.js");

// The workflow filters by exact scenario id via `-t "^${SCENARIO_ID}$"`.
Expand All @@ -38,7 +85,7 @@ for (const scenario of listScenarios()) {

test(
liveScenarioTestName(scenario),
async ({ artifacts, environment, lifecycle, onboard, secrets, stateValidation }) => {
async ({ artifacts, environment, host, lifecycle, onboard, secrets, stateValidation }) => {
for (const secret of scenario.requiredSecrets ?? []) {
secrets.required(secret);
}
Expand Down Expand Up @@ -92,6 +139,22 @@ for (const scenario of listScenarios()) {

const validation = await stateValidation.from(scenario.expectedStateId, instance);

if (scenario.environment.onboarding === "cloud-langchain-deepagents-code") {
const checkScripts = [
"test/e2e/e2e-cloud-experimental/checks/05-deepagents-code-landlock-readonly.sh",
"test/e2e/e2e-cloud-experimental/checks/06-deepagents-code-python-egress.sh",
];
for (const scriptPath of checkScripts) {
expect(fs.existsSync(path.join(REPO_ROOT, scriptPath))).toBe(true);
}
expect(fs.existsSync(E2E_CLOUD_EXPERIMENTAL_CHECKS_DIR)).toBe(true);
await runE2eCloudExperimentalChecks(scenario.id, instance.sandboxName, checkScripts, {
artifacts,
host,
secrets,
});
}

await artifacts.writeJson("scenario-result.json", {
id: scenario.id,
expectedStateId: validation.state.id,
Expand Down
10 changes: 9 additions & 1 deletion test/e2e-scenario/live/run-plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ export interface LiveScenarioRunPlan {
expectedStateId: string | undefined;
suiteIds: string[];
phases: string[];
e2eCloudExperimentalChecks?: string[];
}

export function buildLiveScenarioRunPlan(scenario: ScenarioDefinition): LiveScenarioRunPlan {
return {
const plan: LiveScenarioRunPlan = {
scenarioId: scenario.id,
manifestPath: scenario.manifestPath ?? null,
expectedStateId: scenario.expectedStateId,
Expand All @@ -24,4 +25,11 @@ export function buildLiveScenarioRunPlan(scenario: ScenarioDefinition): LiveScen
"state-validation",
],
};
if (scenario.environment?.onboarding === "cloud-langchain-deepagents-code") {
plan.e2eCloudExperimentalChecks = [
"test/e2e/e2e-cloud-experimental/checks/05-deepagents-code-landlock-readonly.sh",
"test/e2e/e2e-cloud-experimental/checks/06-deepagents-code-python-egress.sh",
];
}
return plan;
}
2 changes: 1 addition & 1 deletion test/e2e-scenario/scenarios/runtime-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ScenarioDefinition } from "./types.ts";
const SUPPORTED_PLATFORMS = new Set(["ubuntu-local"]);
const SUPPORTED_INSTALLS = new Set(["repo-current"]);
const SUPPORTED_RUNTIMES = new Set(["docker-running"]);
const SUPPORTED_ONBOARDING = new Set(["cloud-openclaw"]);
const SUPPORTED_ONBOARDING = new Set(["cloud-openclaw", "cloud-langchain-deepagents-code"]);
// Lifecycle profiles wired into the live Vitest driver. A profile is
// supported only after both (a) `LifecyclePhaseFixture.simulate(profile)`
// dispatches it, and (b) at least one expected-state declares the post-
Expand Down
2 changes: 1 addition & 1 deletion test/e2e-scenario/scenarios/scenarios/baseline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const canonicalScenarioInputs: CanonicalScenarioInput[] = [
manifestName: "langchain-deepagents-code-nvidia",
environment: ubuntuRepoDocker("cloud-langchain-deepagents-code"),
expectedStateId: "cloud-deepagents-code-ready",
suiteIds: ["smoke", "inference", "terminal-agent"],
suiteIds: ["smoke", "inference", "terminal-agent", "deepagents-code-policy"],
description: "Ubuntu repo checkout with Docker and LangChain Deep Agents Code onboarding.",
requiredSecrets: ["NVIDIA_INFERENCE_API_KEY"],
},
Expand Down
17 changes: 16 additions & 1 deletion test/e2e-scenario/support-tests/e2e-scenario-matrix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,24 @@ describe("live Vitest scenario matrix", () => {

it("builds the default live Vitest matrix from fixture-supported scenarios only", () => {
expect(buildLiveScenarioMatrix().map((entry) => entry.id)).toEqual([
"ubuntu-repo-cloud-langchain-deepagents-code",
"ubuntu-repo-cloud-openclaw",
"ubuntu-repo-docker-post-reboot-recovery",
]);
expect(buildLiveScenarioMatrix()[0]).toMatchObject({
id: "ubuntu-repo-cloud-langchain-deepagents-code",
runner: "ubuntu-latest",
platform: "ubuntu-local",
install: "repo-current",
runtime: "docker-running",
onboarding: "cloud-langchain-deepagents-code",
expectedStateId: "cloud-deepagents-code-ready",
requiredSecrets: ["NVIDIA_INFERENCE_API_KEY"],
supported: true,
supportReasons: [],
pendingRuntimeSuites: ["smoke", "inference", "terminal-agent", "deepagents-code-policy"],
});
expect(buildLiveScenarioMatrix()[1]).toMatchObject({
id: "ubuntu-repo-cloud-openclaw",
runner: "ubuntu-latest",
platform: "ubuntu-local",
Expand All @@ -97,7 +111,7 @@ describe("live Vitest scenario matrix", () => {
// confirm the lifecycle whitelist + post-reboot-recovery scenario
// are wired together; the actual RED/GREEN behavior is exercised
// by the live runner (gates on the fix landing in src/lib/).
expect(buildLiveScenarioMatrix()[1]).toMatchObject({
expect(buildLiveScenarioMatrix()[2]).toMatchObject({
id: "ubuntu-repo-docker-post-reboot-recovery",
runner: "ubuntu-latest",
platform: "ubuntu-local",
Expand Down Expand Up @@ -128,6 +142,7 @@ describe("live Vitest scenario matrix", () => {
expect(lines.length, "live matrix output must be a single line").toBe(1);
const parsed = JSON.parse(lines[0]);
expect(parsed.map((entry: { id: string }) => entry.id)).toEqual([
"ubuntu-repo-cloud-langchain-deepagents-code",
"ubuntu-repo-cloud-openclaw",
"ubuntu-repo-docker-post-reboot-recovery",
]);
Expand Down
Loading