Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions test/e2e/live/skill-agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { approveOpenClawAdminScope } from "./openclaw-admin-scope.ts";
import fs from "node:fs";
import path from "node:path";
import { shellQuote } from "../../../src/lib/core/shell-quote";
import { execTimeout, testTimeout } from "../../helpers/timeouts.ts";
import { buildAvailabilityProbeEnv } from "../fixtures/availability-env.ts";
import { resultText } from "../fixtures/clients/command.ts";
Expand All @@ -18,6 +17,7 @@ import { requireHostedInferenceConfig } from "../fixtures/hosted-inference.ts";
import { CLI_ENTRYPOINT, REPO_ROOT } from "../fixtures/paths.ts";
import {
agentSectionContainsToken,
buildVerifySkillFixtureScript,
isAgentVerificationFailClosed,
isExternalProviderValidationFailure,
shouldSkipExternalAgentVerificationFailure,
Expand Down Expand Up @@ -61,26 +61,15 @@ function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}

function buildVerifySkillFixtureScript(): string {
// Keep this readable as discrete clauses while emitting one atomic `sh -lc`
// expression with consistent error propagation.
const skillPath = `/sandbox/.openclaw/workspace/skills/${SKILL_ID}/SKILL.md`;
return [
`token=${shellQuote(VERIFY_PHRASE)}`,
`path=${shellQuote(skillPath)}`,
'test -f "$path"',
'grep -Fq "$token" "$path"',
'echo "SKILL_TOKEN_PATH=$path"',
].join("; ");
}

async function verifySkillFixturePresent(
sandbox: SandboxClient,
sandboxName: string,
): Promise<boolean> {
const result = await sandbox.execShell(
sandboxName,
trustedSandboxShellScript(buildVerifySkillFixtureScript()),
trustedSandboxShellScript(
buildVerifySkillFixtureScript(`/sandbox/.openclaw/workspace/skills/${SKILL_ID}/SKILL.md`),
),
{
artifactName: "verify-skill-fixture-present",
env: buildAvailabilityProbeEnv(),
Expand Down
40 changes: 40 additions & 0 deletions test/e2e/support/skill-agent-classifiers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { describe, expect, it } from "vitest";

import {
agentSectionContainsToken,
buildVerifySkillFixtureScript,
isAgentVerificationFailClosed,
isExternalProviderValidationFailure,
shouldSkipExternalAgentVerificationFailure,
Expand All @@ -23,6 +24,44 @@ const ADD_SKILL_SCRIPT = path.join(
);

describe("skill-agent live test local classifiers", () => {
it.each([
["missing", "missing/SKILL.md", 1, false],
["tokenless", "tokenless/SKILL.md", 1, false],
["matching", "matching/SKILL.md", 0, true],
] as const)(
"requires the verification token in a %s fixture",
(_name, file, exitCode, present) => {
const fixtureDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-skill-presence-"));
try {
fs.mkdirSync(path.join(fixtureDir, "tokenless"));
fs.mkdirSync(path.join(fixtureDir, "matching"));
fs.writeFileSync(
path.join(fixtureDir, "tokenless/SKILL.md"),
"No verification token here.\n",
);
fs.writeFileSync(path.join(fixtureDir, "matching/SKILL.md"), `${VERIFY_PHRASE}\n`);
const result = spawnSync(
"/bin/sh",
["-lc", buildVerifySkillFixtureScript(path.join(fixtureDir, file))],
{
encoding: "utf8",
env: { PATH: "/usr/bin:/bin", HOME: fixtureDir, TMPDIR: fixtureDir },
},
);

expect(result.status).toBe(exitCode);
expect(result.stdout).toBe(
present ? `SKILL_TOKEN_PATH=${path.join(fixtureDir, file)}\n` : "",
);
expect(
shouldSkipExternalAgentVerificationFailure("LLM idle timeout", result.status === 0),
).toBe(present);
} finally {
fs.rmSync(fixtureDir, { recursive: true, force: true });
}
},
);

it("does not treat helper fail-closed output as a skippable provider flake", () => {
const output = `--- agent stdout/stderr\nSsrFBlockedError\n${VERIFY_PHRASE}\n--- end ---`;

Expand Down Expand Up @@ -71,6 +110,7 @@ describe("skill-agent live test local classifiers", () => {
encoding: "utf8",
env: {
PATH: `${path.dirname(process.execPath)}:/usr/bin:/bin`,
TMPDIR: fixtureDir,
SANDBOX_NAME: "test-sandbox",
SKILL_FILE: skillFile,
SKILL_ID: "expected-skill",
Expand Down
14 changes: 13 additions & 1 deletion test/e2e/support/skill-agent-classifiers.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

// Pure predicate helpers shared by the skill-agent live E2E target and its
import { shellQuote } from "../../../src/lib/core/shell-quote";

// Fixture probe and predicate helpers shared by the skill-agent live E2E target and its
// PR-collected unit tests. Keeping them here lets the fast e2e-support project
// exercise the classification logic without gating on NEMOCLAW_RUN_LIVE_E2E=1.

// Token the injected skill fixture must echo back through the agent transcript.
export const VERIFY_PHRASE = "SKILL_SMOKE_VERIFY_K9X2";

export function buildVerifySkillFixtureScript(skillPath: string): string {
return [
`token=${shellQuote(VERIFY_PHRASE)}`,
`path=${shellQuote(skillPath)}`,
'test -f "$path"',
'grep -Fq "$token" "$path"',
'echo "SKILL_TOKEN_PATH=$path"',
].join(" && ");
}

export function isExternalAgentVerificationFlake(text: string): boolean {
// Only provider/model/transport timeout signatures are skippable, and only
// after the fixture is proven present. OpenClaw tool/runtime errors must fail
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/support/workflow-plan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -863,10 +863,10 @@ describe("E2E workflow plan", () => {
it.each([
"test/e2e/e2e-cloud-experimental/features/skill/add-sandbox-skill.sh",
"test/e2e/e2e-cloud-experimental/features/skill/verify-sandbox-skill-via-agent.sh",
"test/e2e/support/skill-agent-classifiers.ts",
])("selects the skill-agent target when its shared helper %s changes", (changedFile) => {
expect(catalogueTargetsForChangedFiles([changedFile]).map((target) => target.id)).toContain(
"skill-agent",
);
const targets = catalogueTargetsForChangedFiles([changedFile]);
expect(targets).toContainEqual(catalogueTarget("skill-agent"));
});

it.each([
Expand Down
1 change: 1 addition & 0 deletions tools/e2e/target-catalogue.mts
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,7 @@ export const E2E_TARGET_CATALOGUE: readonly E2eCatalogueTarget[] = [
restoreCli: true,
exposeCliBin: true,
owningPaths: [
"test/e2e/support/skill-agent-classifiers.ts",
"test/e2e/e2e-cloud-experimental/features/skill/add-sandbox-skill.sh",
"test/e2e/e2e-cloud-experimental/features/skill/verify-sandbox-skill-via-agent.sh",
],
Expand Down
Loading