feat(hooks): add cleanup and cleanupDelayMinutes to HookMappingConfig

This commit is contained in:
Trevin Chow 2026-01-29 08:59:07 -08:00 committed by Trevin Chow
parent 4583f88626
commit bfde8e1213
2 changed files with 49 additions and 0 deletions

View File

@ -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();
});
});

View File

@ -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";