added security checks for journal text box for AI

This commit is contained in:
masongga
2026-05-23 23:55:25 -06:00
parent bffe0f941c
commit 25fb5499c1
9 changed files with 395 additions and 70 deletions

View File

@@ -3,6 +3,7 @@ import {
filterExcludedSimilarTaskLabels,
isPlausibleTaskLabel,
} from "@/lib/ai-task-guardrails";
import { isSafeAiTaskLabel } from "@/lib/ai-output-safety";
import {
MAX_DAILY_AI_TASKS,
type AiTaskGenerationOptions,
@@ -43,6 +44,10 @@ export function sanitizeAiTaskLabels(
.map(normalizeAiTaskLabel)
.filter((label) => label.length > 0)
.filter((label) => {
if (!isSafeAiTaskLabel(label)) {
return false;
}
if (options?.requirePlausible && !isPlausibleTaskLabel(label)) {
return false;
}