mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-21 03:54:45 +00:00
feat(wake): expose typed sessionKey on wake protocol + system event CLI
Adds an optional sessionKey to the WakeParamsSchema and threads it through the gateway wake handler, CronService.wake(), and the underlying timer.wake() ops so callers can target a specific session for async-task completion relays instead of always hitting the agent's main session. Also adds --session-key to `openclaw system event`. The schema rejects empty/non-string sessionKey at the gateway boundary; mismatched session keys (a key that does not belong to the resolving agent) fall back to the agent's main session inside resolveCronSessionKey, which is the existing safety path. Refs #52305 (companion to PR #50818, which closes the related cron-run remap slice at internal enqueue sites). Doesn't depend on #50818. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
13bc7037b1
commit
4ddd942f5f
@@ -67,6 +67,38 @@ describe("system-cli", () => {
|
||||
expect(runtimeErrors[0]).toContain("--mode must be now or next-heartbeat");
|
||||
});
|
||||
|
||||
it("forwards --session-key on system event", async () => {
|
||||
await runCli([
|
||||
"system",
|
||||
"event",
|
||||
"--text",
|
||||
"ping",
|
||||
"--session-key",
|
||||
"agent:main:telegram:dm:42",
|
||||
]);
|
||||
|
||||
expect(callGatewayFromCli).toHaveBeenCalledWith(
|
||||
"wake",
|
||||
expect.any(Object),
|
||||
{ mode: "next-heartbeat", text: "ping", sessionKey: "agent:main:telegram:dm:42" },
|
||||
{ expectFinal: false },
|
||||
);
|
||||
});
|
||||
|
||||
it("omits sessionKey from payload when --session-key not provided", async () => {
|
||||
await runCli(["system", "event", "--text", "ping"]);
|
||||
|
||||
const [, , params] = callGatewayFromCli.mock.calls[0]!;
|
||||
expect(params).not.toHaveProperty("sessionKey");
|
||||
});
|
||||
|
||||
it("treats empty --session-key as omitted", async () => {
|
||||
await runCli(["system", "event", "--text", "ping", "--session-key", " "]);
|
||||
|
||||
const [, , params] = callGatewayFromCli.mock.calls[0]!;
|
||||
expect(params).not.toHaveProperty("sessionKey");
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ args: ["system", "heartbeat", "last"], method: "last-heartbeat", params: undefined },
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user