L9 Lotse – KI-Assistent: Transkription, Berichtsentwurf, Vollständigkeitsprüfung, Freigabeprinzip (Services)
- OpenAI-kompatible Transkription + Processor transcription (done/failed/disabled, AiGeneration, Notiz aus Sprachnotiz) - Claude-Lotse (strukturierte Ausgabe, Refusal/Fallback), Datenminimierung, Vorschläge in content.lotse - Vollständigkeitsprüfung (Regeln + KI-Hinweise mit Deep-Link), Einstellungen, KI-Protokoll - Freigabeprinzip: Submit eines Lotse-Entwurfs nur mit Prüfbestätigung (serverseitig) - Migration lotse_address_form (TenantSettings) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { ZodError } from "zod";
|
||||
import { LOTSE_ERROR_CODES, type LotseActionErrorCode, type LotseActionState } from "@/lib/lotse/action-state";
|
||||
import { ServiceError } from "@/server/services/context";
|
||||
import { ForbiddenError } from "@/server/rbac";
|
||||
import { ModuleDisabledError } from "@/server/modules";
|
||||
|
||||
/** Map thrown errors of Lotse actions to a displayable state (plain-language message key, no internals). */
|
||||
export function lotseErrorState(err: unknown): LotseActionState {
|
||||
const at = Date.now();
|
||||
if (err instanceof ServiceError) {
|
||||
const reason = (err.details as { reason?: string } | undefined)?.reason;
|
||||
const code = reason && (LOTSE_ERROR_CODES as readonly string[]).includes(reason) ? (reason as LotseActionErrorCode) : err.code === "blocked" ? "not_editable" : err.code;
|
||||
return { status: "error", code, at };
|
||||
}
|
||||
if (err instanceof ModuleDisabledError) return { status: "error", code: "disabled", at };
|
||||
if (err instanceof ZodError) return { status: "error", code: "invalid", at };
|
||||
if (err instanceof ForbiddenError) return { status: "error", code: "forbidden", at };
|
||||
console.error("[actions/lotse]", err);
|
||||
return { status: "error", code: "generic", at };
|
||||
}
|
||||
|
||||
export const str = (fd: FormData, key: string): string | undefined => {
|
||||
const v = fd.get(key);
|
||||
return typeof v === "string" ? v : undefined;
|
||||
};
|
||||
Reference in New Issue
Block a user