mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-18 08:31:49 -06:00
6dc55fa65e
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>
22 lines
998 B
TypeScript
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">();
|
|
});
|
|
});
|