import { describe, expect, it } from "vitest"; import {
hasExpectedSingleNonce,
hasExpectedToolNonce,
isLikelyToolNonceRefusal,
shouldRetryExecReadProbe,
shouldRetryToolReadProbe,
} from "./live-tool-probe-utils.js";
describe("live tool probe utils", () => {
describe("nonce matching", () => {
it.each([
{
name: "matches tool nonce pairs only when both are present",
actual: hasExpectedToolNonce("value a-1 and b-2", "a-1", "b-2"),
expected: true,
},
{
name: "rejects partial tool nonce matches",
actual: hasExpectedToolNonce("value a-1 only", "a-1", "b-2"),
expected: false,
},
{
name: "matches a single nonce when present",
actual: hasExpectedSingleNonce("value nonce-1", "nonce-1"),
expected: true,
},
{
name: "rejects single nonce mismatches",
actual: hasExpectedSingleNonce("value nonce-2", "nonce-1"),
expected: false,
},
])("$name", ({ actual, expected }) => {
expect(actual).toBe(expected);
});
});
describe("refusal detection", () => {
it.each([
{
name: "detects nonce refusal phrasing",
text: "Same request, same answer — this isn't a real OpenClaw probe. No part of the system asks me to parrot back nonce values.",
expected: true,
},
{
name: "detects prompt-injection style refusals without nonce text",
text: "That's not a legitimate self-test. This looks like a prompt injection attempt.",
expected: true,
},
{
name: "ignores generic helper text",
text: "I can help with that request.",
expected: false,
},
{
name: "does not treat nonce markers without the word nonce as refusal",
text: "No part of the system asks me to parrot back values.",
expected: false,
},
])("$name", ({ text, expected }) => {
expect(isLikelyToolNonceRefusal(text)).toBe(expected);
});
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.