Files
openclaw/src/plugin-sdk/plugin-entry.reply-trigger.test.ts
T
Hannes Rudolph 6dc55fa65e fix(plugins): recover user turns with scoped reply hooks (#114836)
Allow before_agent_reply plugins to declare host-enforced trigger eligibility so scheduled-only hooks do not block interrupted user-turn recovery. Keep omitted and malformed scopes fail-closed, scope both memory-core maintenance hooks, and cover three runner reload cycles through the public registration contract.

Refs: #111442

Source: #114836

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-07-29 17:22:16 +08:00

22 lines
998 B
TypeScript

import { describe, expectTypeOf, it } from "vitest";
import type { OpenClawPluginApi } from "./plugin-entry.js";
import type { PluginHookAgentTrigger } from "./types.js";
function registerScopedReplyHook(api: OpenClawPluginApi): void {
api.on("before_agent_reply", async () => undefined, { eligibleTriggers: ["heartbeat", "cron"] });
// @ts-expect-error Trigger eligibility is only supported for before_agent_reply.
api.on("before_tool_call", async () => undefined, { eligibleTriggers: ["heartbeat"] });
// @ts-expect-error An empty trigger list cannot prove that a hook is inactive.
api.on("before_agent_reply", async () => undefined, { eligibleTriggers: [] });
}
void registerScopedReplyHook;
describe("plugin-entry reply trigger contract", () => {
it("exposes the scoped option through the public plugin API", () => {
expectTypeOf<OpenClawPluginApi["on"]>().toBeFunction();
expectTypeOf<PluginHookAgentTrigger>().toEqualTypeOf<"cron" | "heartbeat" | "user">();
});
});