2026-04-03 17:08:05 +09:00
|
|
|
import { isTaskSystemEnabled } from "../../shared/task-system-enabled";
|
2026-02-08 13:57:26 +09:00
|
|
|
import { BLOCKED_TOOLS, REPLACEMENT_MESSAGE } from "./constants";
|
|
|
|
|
|
|
|
|
|
export interface TasksTodowriteDisablerConfig {
|
|
|
|
|
experimental?: {
|
|
|
|
|
task_system?: boolean;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function createTasksTodowriteDisablerHook(
|
|
|
|
|
config: TasksTodowriteDisablerConfig,
|
|
|
|
|
) {
|
2026-04-03 17:08:05 +09:00
|
|
|
const taskSystemEnabled = isTaskSystemEnabled(config);
|
2026-02-08 13:57:26 +09:00
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
"tool.execute.before": async (
|
|
|
|
|
input: { tool: string; sessionID: string; callID: string },
|
|
|
|
|
_output: { args: Record<string, unknown> },
|
|
|
|
|
) => {
|
2026-04-03 17:08:05 +09:00
|
|
|
if (!taskSystemEnabled) {
|
2026-02-08 13:57:26 +09:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const toolName = input.tool as string;
|
|
|
|
|
if (
|
|
|
|
|
BLOCKED_TOOLS.some(
|
|
|
|
|
(blocked) => blocked.toLowerCase() === toolName.toLowerCase(),
|
|
|
|
|
)
|
|
|
|
|
) {
|
|
|
|
|
throw new Error(REPLACEMENT_MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|