[208] Anonymitäts-Tor an allen Export-Einstiegen: Berichte, Bild-/Rendering-Exporte, CLI (--ignore-anonymity), KI-Export; Dateiname nach Wiederherstellen

This commit is contained in:
Claude committed 2026-11-14 08:31:00 +00:00
1 parent 7954ab647f
commit be000985ed
21 files changed
+260 -59

No files matched your search

+1 -1
View File
@@ -81,7 +81,7 @@ export const AI_TOOLS: AiToolDef[] = [
"Exportiert Grundriss als SVG (format=svg) oder PDF (pdf, nur App) bzw. das Modell als IFC (ifc). Liefert den Inhalt " +
"(PDF base64); mit save=true öffnet die App den Speichern-Dialog und die Nutzerin wählt den Ort.",
inputSchema: obj(
{ format: { type: "string", enum: ["svg", "pdf", "ifc"] }, level: { type: "string" }, scale: { type: "number" }, save: { type: "boolean" } },
{ format: { type: "string", enum: ["svg", "pdf", "ifc"] }, level: { type: "string" }, scale: { type: "number" }, save: { type: "boolean" }, ignoreAnonymity: { type: "boolean" } },
["format"],
),
},
+10
View File
@@ -105,6 +105,16 @@ describe("KI-Werkzeuge (gemeinsame Liste)", () => {
expect((await callAiTool(host, "export", { format: "svg", save: true })).isError).toBe(true); // Speichern nur mit Dialog
expect((await callAiTool(host, "gibtsnicht", {})).isError).toBe(true);
});
it("anonyme Abgabe: Export mit Freitext-Treffern wird nicht ausgeliefert, ignoreAnonymity übergeht ([208])", async () => {
const { host } = fakeHost(false);
const real = host.project();
const anon = { ...real, name: "Seeblick Meierhofer", competition: { anonymous: true, keyword: "FALKE 7", identifiers: "" }, rooms: [{ ...real.rooms![0], name: "Büro Seeblick Meierhofer" }, ...real.rooms!.slice(1)] } as Project;
const h: AiHost = { ...host, project: () => anon };
const blocked = await callAiTool(h, "export", { format: "svg" });
expect(blocked.isError).toBe(true);
expect(textOf(blocked)).toContain("Anonyme Abgabe");
expect(textOf(await callAiTool(h, "export", { format: "svg", ignoreAnonymity: true }))).toContain("<svg");
});
});
describe("Brücken-Anmeldung", () => {
+12 -1
View File
@@ -17,6 +17,8 @@ import { computeKennzahlen, checkRoomProgram } from "../analysis/kennzahlen";
import { computeAreaTable, computeIvhb } from "../analysis/areaTable";
import { checkSiteRules } from "../analysis/siteRules";
import { loadFileio } from "../engine/fileioWasm";
import { anonymityFindings } from "../export/competitionCheck";
import { exportProjectName } from "../export/competitionIdentity";
import { documentFor } from "./document";
import { validateProject, projectWarnings, type CoreOp } from "./ops";
import { aiText, aiToolDef, randomHex, type AiToolResult } from "./aiToolDefs";
@@ -174,7 +176,7 @@ const appOnly = (name: string) => err(`${name}: nur mit der laufenden App (dossi
async function exportTool(host: AiHost, project: Project, args: Record<string, unknown>): Promise<AiToolResult> {
const format = String(args.format);
const stem = project.name || "projekt";
const stem = exportProjectName(project) || "projekt";
const scale = Number(args.scale ?? 100);
if (args.save === true && !host.save) return err("save: Speichern nur in der App (Dialog, Ort wählt die Nutzerin)");
let data: string | Uint8Array;
@@ -199,6 +201,15 @@ async function exportTool(host: AiHost, project: Project, args: Record<string, u
}
file = `${stem}-${lvl.name}.${format}`;
} else return err(`export: unbekanntes Format ${format}`);
// [208] Anonyme Abgabe: Ohne `save` gibt das Werkzeug die Daten direkt an die KI zurück — Freitext vorher prüfen.
// (Mit `save` fragt die App selbst im Anonymitäts-Dialog nach.)
if (args.save !== true && args.ignoreAnonymity !== true) {
const found = anonymityFindings(project, { texts: [{ area: "export", place: "fileName", text: file }] });
if (found.length > 0) {
const lines = found.slice(0, 20).map((f) => `${f.area} / ${f.place}: „${f.text}" enthält „${f.term}"`);
return err(`Anonyme Abgabe: ${found.length} Treffer im Freitext, Export nicht ausgeliefert (mit ignoreAnonymity=true übergehen):\n${lines.join("\n")}`);
}
}
if (args.save === true) {
const ok = await host.save!(data, file, mime);
return ok ? aiText(`gespeichert: ${file}`) : err("Speichern abgebrochen");