feat: lightweight bootstrap context mode for heartbeat/cron runs (openclaw#26064) thanks @jose-velez

Verified:
- pnpm build
- pnpm check (fails on pre-existing unrelated repo issues in extensions/diffs and src/agents/tools/nodes-tool.test.ts)
- pnpm vitest run src/agents/bootstrap-files.test.ts src/infra/heartbeat-runner.model-override.test.ts src/cli/cron-cli.test.ts
- pnpm test:macmini (fails on pre-existing extensions/diffs import errors; touched suites pass)

Co-authored-by: jose-velez <10926182+jose-velez@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
Jose E Velez
2026-03-01 21:13:24 -05:00
committed by GitHub
parent 0a182bb4d1
commit 0c8fa63b93
17 changed files with 168 additions and 23 deletions

View File

@@ -40,7 +40,13 @@ const { registerCronCli } = await import("./cron-cli.js");
type CronUpdatePatch = {
patch?: {
schedule?: { kind?: string; expr?: string; tz?: string; staggerMs?: number };
payload?: { kind?: string; message?: string; model?: string; thinking?: string };
payload?: {
kind?: string;
message?: string;
model?: string;
thinking?: string;
lightContext?: boolean;
};
delivery?: {
mode?: string;
channel?: string;
@@ -53,7 +59,7 @@ type CronUpdatePatch = {
type CronAddParams = {
schedule?: { kind?: string; staggerMs?: number };
payload?: { model?: string; thinking?: string };
payload?: { model?: string; thinking?: string; lightContext?: boolean };
delivery?: { mode?: string; accountId?: string };
deleteAfterRun?: boolean;
agentId?: string;
@@ -153,15 +159,17 @@ async function expectCronEditWithScheduleLookupExit(
describe("cron cli", () => {
it("exits 0 for cron run when job executes successfully", async () => {
resetGatewayMock();
callGatewayFromCli.mockImplementation(async (method: string) => {
if (method === "cron.status") {
return { enabled: true };
}
if (method === "cron.run") {
return { ok: true, ran: true };
}
return { ok: true };
});
callGatewayFromCli.mockImplementation(
async (method: string, _opts: unknown, params?: unknown) => {
if (method === "cron.status") {
return { enabled: true };
}
if (method === "cron.run") {
return { ok: true, params, ran: true };
}
return { ok: true, params };
},
);
const runtimeModule = await import("../runtime.js");
const runtime = runtimeModule.defaultRuntime as { exit: (code: number) => void };
@@ -179,15 +187,17 @@ describe("cron cli", () => {
it("exits 1 for cron run when job does not execute", async () => {
resetGatewayMock();
callGatewayFromCli.mockImplementation(async (method: string) => {
if (method === "cron.status") {
return { enabled: true };
}
if (method === "cron.run") {
return { ok: true, ran: false };
}
return { ok: true };
});
callGatewayFromCli.mockImplementation(
async (method: string, _opts: unknown, params?: unknown) => {
if (method === "cron.status") {
return { enabled: true };
}
if (method === "cron.run") {
return { ok: true, params, ran: false };
}
return { ok: true, params };
},
);
const runtimeModule = await import("../runtime.js");
const runtime = runtimeModule.defaultRuntime as { exit: (code: number) => void };
@@ -367,6 +377,22 @@ describe("cron cli", () => {
expect(params?.agentId).toBe("ops");
});
it("sets lightContext on cron add when --light-context is passed", async () => {
const params = await runCronAddAndGetParams([
"--name",
"Light context",
"--cron",
"* * * * *",
"--session",
"isolated",
"--message",
"hello",
"--light-context",
]);
expect(params?.payload?.lightContext).toBe(true);
});
it.each([
{
label: "omits empty model and thinking",
@@ -409,6 +435,14 @@ describe("cron cli", () => {
expect(patch?.patch?.payload?.thinking).toBe("low");
});
it("sets and clears lightContext on cron edit", async () => {
const setPatch = await runCronEditAndGetPatch(["--light-context", "--message", "hello"]);
expect(setPatch?.patch?.payload?.lightContext).toBe(true);
const clearPatch = await runCronEditAndGetPatch(["--no-light-context", "--message", "hello"]);
expect(clearPatch?.patch?.payload?.lightContext).toBe(false);
});
it("updates delivery settings without requiring --message", async () => {
await runCronCommand([
"cron",