mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:50:44 +00:00
test: make live cron probe agent-generic
This commit is contained in:
@@ -4,15 +4,17 @@ import {
|
||||
assertLiveImageProbeReply,
|
||||
buildLiveCronProbeMessage,
|
||||
createLiveCronProbeSpec,
|
||||
normalizeLiveAgentFamily,
|
||||
isClaudeLikeLiveAgent,
|
||||
} from "./live-agent-probes.js";
|
||||
|
||||
describe("live-agent-probes", () => {
|
||||
it("normalizes cli backend ids into live agent families", () => {
|
||||
expect(normalizeLiveAgentFamily("claude-cli")).toBe("claude");
|
||||
expect(normalizeLiveAgentFamily("codex")).toBe("codex");
|
||||
expect(normalizeLiveAgentFamily("google-gemini-cli")).toBe("gemini");
|
||||
expect(normalizeLiveAgentFamily("opencode-ai")).toBe("opencode");
|
||||
it("only special-cases Claude-like retry prompts", () => {
|
||||
expect(isClaudeLikeLiveAgent("claude")).toBe(true);
|
||||
expect(isClaudeLikeLiveAgent("claude-cli")).toBe(true);
|
||||
expect(isClaudeLikeLiveAgent("codex")).toBe(false);
|
||||
expect(isClaudeLikeLiveAgent("google-gemini-cli")).toBe(false);
|
||||
expect(isClaudeLikeLiveAgent("opencode-ai")).toBe(false);
|
||||
expect(isClaudeLikeLiveAgent("future-agent")).toBe(false);
|
||||
});
|
||||
|
||||
it("accepts only cat for the shared image probe reply", () => {
|
||||
@@ -35,7 +37,7 @@ describe("live-agent-probes", () => {
|
||||
).toContain("openclaw-tools/cron");
|
||||
expect(
|
||||
buildLiveCronProbeMessage({
|
||||
agent: "codex",
|
||||
agent: "future-agent",
|
||||
argsJson: spec.argsJson,
|
||||
attempt: 1,
|
||||
exactReply: spec.name,
|
||||
|
||||
@@ -5,8 +5,6 @@ import { normalizeOptionalLowercaseString } from "../shared/string-coerce.js";
|
||||
|
||||
const execFileAsync = promisify(execFile);
|
||||
|
||||
export type LiveAgentFamily = "claude" | "codex" | "gemini" | "opencode";
|
||||
|
||||
export type CronListCliResult = {
|
||||
jobs?: Array<{
|
||||
id?: string;
|
||||
@@ -28,21 +26,9 @@ export type LiveCronProbeSpec = {
|
||||
argsJson: string;
|
||||
};
|
||||
|
||||
export function normalizeLiveAgentFamily(raw: string): LiveAgentFamily {
|
||||
export function isClaudeLikeLiveAgent(raw: string): boolean {
|
||||
const normalized = normalizeOptionalLowercaseString(raw);
|
||||
if (normalized === "claude" || normalized === "claude-cli") {
|
||||
return "claude";
|
||||
}
|
||||
if (normalized === "codex" || normalized === "codex-cli") {
|
||||
return "codex";
|
||||
}
|
||||
if (normalized === "gemini" || normalized === "google-gemini-cli") {
|
||||
return "gemini";
|
||||
}
|
||||
if (normalized === "opencode" || normalized === "opencode-ai") {
|
||||
return "opencode";
|
||||
}
|
||||
throw new Error(`unsupported live agent family: ${raw}`);
|
||||
return normalized === "claude" || normalized === "claude-cli";
|
||||
}
|
||||
|
||||
export function assertLiveImageProbeReply(text: string): void {
|
||||
@@ -84,7 +70,7 @@ export function buildLiveCronProbeMessage(params: {
|
||||
attempt: number;
|
||||
exactReply: string;
|
||||
}): string {
|
||||
const family = normalizeLiveAgentFamily(params.agent);
|
||||
const claudeLike = isClaudeLikeLiveAgent(params.agent);
|
||||
if (params.attempt === 0) {
|
||||
return (
|
||||
"Use the OpenClaw MCP tool `openclaw-tools/cron` (server `openclaw-tools`, tool `cron`). " +
|
||||
@@ -93,7 +79,7 @@ export function buildLiveCronProbeMessage(params: {
|
||||
`After the cron job is created, reply exactly: ${params.exactReply}`
|
||||
);
|
||||
}
|
||||
if (family === "claude") {
|
||||
if (claudeLike) {
|
||||
return (
|
||||
"Retry the OpenClaw MCP tool `openclaw-tools/cron` now. " +
|
||||
`Use these exact JSON arguments: ${params.argsJson}. ` +
|
||||
|
||||
Reference in New Issue
Block a user