mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:30:44 +00:00
feat(plugins): add before agent finalize hook (#71765)
This commit is contained in:
@@ -59,11 +59,25 @@ describe("Codex native hook relay config", () => {
|
||||
],
|
||||
},
|
||||
],
|
||||
"hooks.Stop": [
|
||||
{
|
||||
matcher: null,
|
||||
hooks: [
|
||||
{
|
||||
type: "command",
|
||||
command:
|
||||
"openclaw hooks relay --provider codex --relay-id relay-1 --event before_agent_finalize",
|
||||
timeout: 7,
|
||||
async: false,
|
||||
statusMessage: "OpenClaw native hook relay",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(JSON.stringify(config)).not.toContain("timeoutSec");
|
||||
expect(config).not.toHaveProperty("hooks.SessionStart");
|
||||
expect(config).not.toHaveProperty("hooks.UserPromptSubmit");
|
||||
expect(config).not.toHaveProperty("hooks.Stop");
|
||||
});
|
||||
|
||||
it("includes only requested hook events", () => {
|
||||
@@ -108,6 +122,7 @@ describe("Codex native hook relay config", () => {
|
||||
"hooks.PreToolUse": [],
|
||||
"hooks.PostToolUse": [],
|
||||
"hooks.PermissionRequest": [],
|
||||
"hooks.Stop": [],
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -119,7 +134,7 @@ function createRelay(): NativeHookRelayRegistrationHandle {
|
||||
sessionId: "session-1",
|
||||
sessionKey: "agent:main:session-1",
|
||||
runId: "run-1",
|
||||
allowedEvents: ["pre_tool_use", "post_tool_use", "permission_request"],
|
||||
allowedEvents: ["pre_tool_use", "post_tool_use", "permission_request", "before_agent_finalize"],
|
||||
expiresAtMs: Date.now() + 1000,
|
||||
commandForEvent: (event) =>
|
||||
`openclaw hooks relay --provider codex --relay-id relay-1 --event ${event}`,
|
||||
|
||||
@@ -8,14 +8,16 @@ export const CODEX_NATIVE_HOOK_RELAY_EVENTS = [
|
||||
"pre_tool_use",
|
||||
"post_tool_use",
|
||||
"permission_request",
|
||||
"before_agent_finalize",
|
||||
] as const satisfies readonly NativeHookRelayEvent[];
|
||||
|
||||
type CodexHookEventName = "PreToolUse" | "PostToolUse" | "PermissionRequest";
|
||||
type CodexHookEventName = "PreToolUse" | "PostToolUse" | "PermissionRequest" | "Stop";
|
||||
|
||||
const CODEX_HOOK_EVENT_BY_NATIVE_EVENT: Record<NativeHookRelayEvent, CodexHookEventName> = {
|
||||
pre_tool_use: "PreToolUse",
|
||||
post_tool_use: "PostToolUse",
|
||||
permission_request: "PermissionRequest",
|
||||
before_agent_finalize: "Stop",
|
||||
};
|
||||
|
||||
export function buildCodexNativeHookRelayConfig(params: {
|
||||
@@ -53,6 +55,7 @@ export function buildCodexNativeHookRelayDisabledConfig(): JsonObject {
|
||||
"hooks.PreToolUse": [],
|
||||
"hooks.PostToolUse": [],
|
||||
"hooks.PermissionRequest": [],
|
||||
"hooks.Stop": [],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -570,6 +570,7 @@ describe("runCodexAppServerAttempt", () => {
|
||||
"hooks.PreToolUse": [],
|
||||
"hooks.PostToolUse": [],
|
||||
"hooks.PermissionRequest": [],
|
||||
"hooks.Stop": [],
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user