mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-26 08:31:55 +00:00
fix: enrich session_end lifecycle hooks (#59715)
Merged via squash.
Prepared head SHA: b3ef62b973
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
This commit is contained in:
@@ -2482,11 +2482,25 @@ export type PluginHookSessionStartEvent = {
|
||||
};
|
||||
|
||||
// session_end hook
|
||||
export type PluginHookSessionEndReason =
|
||||
| "new"
|
||||
| "reset"
|
||||
| "idle"
|
||||
| "daily"
|
||||
| "compaction"
|
||||
| "deleted"
|
||||
| "unknown";
|
||||
|
||||
export type PluginHookSessionEndEvent = {
|
||||
sessionId: string;
|
||||
sessionKey?: string;
|
||||
messageCount: number;
|
||||
durationMs?: number;
|
||||
reason?: PluginHookSessionEndReason;
|
||||
sessionFile?: string;
|
||||
transcriptArchived?: boolean;
|
||||
nextSessionId?: string;
|
||||
nextSessionKey?: string;
|
||||
};
|
||||
|
||||
// Subagent context
|
||||
|
||||
@@ -40,7 +40,15 @@ describe("session hook runner methods", () => {
|
||||
{
|
||||
name: "runSessionEnd invokes registered session_end hooks",
|
||||
hookName: "session_end" as const,
|
||||
event: { sessionId: "abc-123", sessionKey: "agent:main:abc", messageCount: 42 },
|
||||
event: {
|
||||
sessionId: "abc-123",
|
||||
sessionKey: "agent:main:abc",
|
||||
messageCount: 42,
|
||||
reason: "daily" as const,
|
||||
sessionFile: "/tmp/abc-123.jsonl.reset.2026-04-02T10-00-00.000Z",
|
||||
transcriptArchived: true,
|
||||
nextSessionId: "def-456",
|
||||
},
|
||||
},
|
||||
] as const)("$name", async ({ hookName, event }) => {
|
||||
await expectSessionHookCall({ hookName, event, sessionCtx });
|
||||
|
||||
Reference in New Issue
Block a user