cron: infer payload kind for model-only update patches (openclaw#15664) thanks @rodrigouroz

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check (fails on current origin/main in src/memory/embedding-manager.test-harness.ts; unchanged by this PR)

Co-authored-by: rodrigouroz <384037+rodrigouroz@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
Rodrigo Uroz
2026-02-15 12:12:51 -03:00
committed by GitHub
parent 3c97ec70d1
commit 89dccc79a7
6 changed files with 135 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { normalizeCronJobCreate } from "./normalize.js";
import { normalizeCronJobCreate, normalizeCronJobPatch } from "./normalize.js";
describe("normalizeCronJobCreate", () => {
it("maps legacy payload.provider to payload.channel and strips provider", () => {
@@ -293,3 +293,31 @@ describe("normalizeCronJobCreate", () => {
expect(delivery.to).toBe("123");
});
});
describe("normalizeCronJobPatch", () => {
it("infers agentTurn kind for model-only payload patches", () => {
const normalized = normalizeCronJobPatch({
payload: {
model: "anthropic/claude-sonnet-4-5",
},
}) as unknown as Record<string, unknown>;
const payload = normalized.payload as Record<string, unknown>;
expect(payload.kind).toBe("agentTurn");
expect(payload.model).toBe("anthropic/claude-sonnet-4-5");
});
it("does not infer agentTurn kind for delivery-only legacy hints", () => {
const normalized = normalizeCronJobPatch({
payload: {
channel: "telegram",
to: "+15550001111",
},
}) as unknown as Record<string, unknown>;
const payload = normalized.payload as Record<string, unknown>;
expect(payload.kind).toBeUndefined();
expect(payload.channel).toBe("telegram");
expect(payload.to).toBe("+15550001111");
});
});