From bfde8e12134bc6d3f454fdcd55962e4173d2b9ef Mon Sep 17 00:00:00 2001 From: Trevin Chow Date: Thu, 29 Jan 2026 08:59:07 -0800 Subject: [PATCH] feat(hooks): add cleanup and cleanupDelayMinutes to HookMappingConfig --- src/config/types.hooks.test.ts | 45 ++++++++++++++++++++++++++++++++++ src/config/types.hooks.ts | 4 +++ 2 files changed, 49 insertions(+) create mode 100644 src/config/types.hooks.test.ts diff --git a/src/config/types.hooks.test.ts b/src/config/types.hooks.test.ts new file mode 100644 index 000000000..2129ee979 --- /dev/null +++ b/src/config/types.hooks.test.ts @@ -0,0 +1,45 @@ +import { describe, expect, it } from "vitest"; +import type { HookMappingConfig } from "./types.hooks.js"; + +describe("HookMappingConfig", () => { + it("accepts cleanup option with delete value", () => { + const config: HookMappingConfig = { + id: "test", + match: { path: "test" }, + action: "agent", + cleanup: "delete", + }; + expect(config.cleanup).toBe("delete"); + }); + + it("accepts cleanup option with keep value", () => { + const config: HookMappingConfig = { + id: "test", + match: { path: "test" }, + action: "agent", + cleanup: "keep", + }; + expect(config.cleanup).toBe("keep"); + }); + + it("accepts cleanupDelayMinutes option", () => { + const config: HookMappingConfig = { + id: "test", + match: { path: "test" }, + action: "agent", + cleanup: "delete", + cleanupDelayMinutes: 5, + }; + expect(config.cleanupDelayMinutes).toBe(5); + }); + + it("allows cleanup fields to be omitted", () => { + const config: HookMappingConfig = { + id: "test", + match: { path: "test" }, + action: "agent", + }; + expect(config.cleanup).toBeUndefined(); + expect(config.cleanupDelayMinutes).toBeUndefined(); + }); +}); diff --git a/src/config/types.hooks.ts b/src/config/types.hooks.ts index 7ca74605a..f097d2216 100644 --- a/src/config/types.hooks.ts +++ b/src/config/types.hooks.ts @@ -36,6 +36,10 @@ export type HookMappingConfig = { thinking?: string; timeoutSeconds?: number; transform?: HookMappingTransform; + /** Session cleanup after hook completes. "delete" removes session + transcript. Default: "keep" */ + cleanup?: "delete" | "keep"; + /** Minutes to wait before cleanup when cleanup="delete". Default: 0 (immediate) */ + cleanupDelayMinutes?: number; }; export type HooksGmailTailscaleMode = "off" | "serve" | "funnel";