Self-contained sub-project API/: a local support page where Marc pastes a client's mail; a support agent and an analyst agent stay alive for the session and produce a slide PDF that answers the client's question. Tools, detectors, knowledge and Typst brand are copied (API/PROVENANCE.md). First real case: Crissier (LENZSPITZE), workflow validated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
171 lines
8.7 KiB
HTML
171 lines
8.7 KiB
HTML
<!doctype html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Support AIMsight</title>
|
|
<style>
|
|
:root { --fond: #f6f7f9; --carte: #fff; --texte: #1d232b; --doux: #6b7480; --bord: #d9dde3;
|
|
--support: #e8eefc; --analyste: #e7f5ec; --marc: #fdf0e3; --erreur: #b3261e; --accent: #2457c5; }
|
|
* { box-sizing: border-box; }
|
|
body { margin: 0; padding: 16px; font: 14px/1.45 system-ui, sans-serif; background: var(--fond); color: var(--texte); }
|
|
h1 { font-size: 18px; margin: 0 0 12px; }
|
|
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: 8px; padding: 12px; }
|
|
.entree { display: grid; grid-template-columns: 2fr 1fr auto; gap: 12px; align-items: start; }
|
|
label { font-size: 12px; color: var(--doux); display: block; margin-bottom: 4px; }
|
|
textarea { width: 100%; border: 1px solid var(--bord); border-radius: 6px; padding: 8px; font: inherit; resize: vertical; }
|
|
#mail { min-height: 140px; } #contexte { min-height: 140px; }
|
|
button { font: inherit; padding: 8px 16px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; }
|
|
button:disabled { background: var(--bord); color: var(--doux); cursor: default; }
|
|
.cote { display: flex; flex-direction: column; gap: 8px; min-width: 150px; }
|
|
#cout { font-size: 12px; color: var(--doux); white-space: pre; }
|
|
#vignettes img { height: 48px; margin: 4px 4px 0 0; border: 1px solid var(--bord); border-radius: 4px; }
|
|
.fils { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
|
|
.fil { display: flex; flex-direction: column; height: 60vh; }
|
|
.fil h2 { font-size: 14px; margin: 0 0 8px; display: flex; justify-content: space-between; }
|
|
.etat { font-weight: normal; color: var(--doux); font-size: 12px; }
|
|
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; }
|
|
.m { padding: 8px 10px; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
.m.support { background: var(--support); } .m.analyste { background: var(--analyste); }
|
|
.m.marc { background: var(--marc); align-self: flex-end; max-width: 85%; }
|
|
.m.relai { background: var(--support); border-left: 3px solid var(--accent); }
|
|
.m .qui { font-size: 11px; color: var(--doux); display: block; margin-bottom: 2px; }
|
|
.outil { font-size: 12px; color: var(--doux); font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
|
|
.erreur { color: var(--erreur); font-size: 12px; }
|
|
.saisie { display: flex; gap: 8px; margin-top: 8px; }
|
|
.saisie textarea { min-height: 44px; height: 44px; }
|
|
.rapport { display: flex; flex-direction: column; gap: 8px; }
|
|
.rapport .barre { display: flex; justify-content: space-between; align-items: center; }
|
|
iframe { width: 100%; height: 75vh; border: 1px solid var(--bord); border-radius: 6px; background: #fff; }
|
|
.vide { color: var(--doux); padding: 24px; text-align: center; }
|
|
@media (max-width: 900px) { .entree, .fils { grid-template-columns: 1fr; } }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Support AIMsight</h1>
|
|
|
|
<div class="carte entree">
|
|
<div>
|
|
<label for="mail">Mail du client (texte ; colle les captures ici, elles s'ajoutent en vignettes)</label>
|
|
<textarea id="mail" placeholder="Bonjour, …"></textarea>
|
|
<div id="vignettes"></div>
|
|
</div>
|
|
<div>
|
|
<label for="contexte">Ton contexte (station, plage, ce que tu sais du cas)</label>
|
|
<textarea id="contexte"></textarea>
|
|
</div>
|
|
<div class="cote">
|
|
<button id="analyser">Analyser</button>
|
|
<div id="cout"></div>
|
|
<div id="dossier" class="outil"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="fils">
|
|
<div class="carte fil">
|
|
<h2>Support <span class="etat" id="etat-support"></span></h2>
|
|
<div class="messages" id="fil-support"></div>
|
|
<div class="saisie"><textarea id="saisie-support" placeholder="Au support…"></textarea><button data-agent="support">Envoyer</button></div>
|
|
</div>
|
|
<div class="carte fil">
|
|
<h2>Analyste <span class="etat" id="etat-analyste"></span></h2>
|
|
<div class="messages" id="fil-analyste"></div>
|
|
<div class="saisie"><textarea id="saisie-analyste" placeholder="À l'analyste…"></textarea><button data-agent="analyste">Envoyer</button></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="carte rapport">
|
|
<div class="barre"><strong>Rapport <span id="version"></span></strong><a id="telecharger" hidden><button>Télécharger le PDF</button></a></div>
|
|
<div id="pdf" class="vide">Pas encore de PDF.</div>
|
|
</div>
|
|
|
|
<script>
|
|
const images = [];
|
|
let n = 0, version = null, id = null;
|
|
|
|
document.getElementById("mail").addEventListener("paste", ev => {
|
|
for (const item of ev.clipboardData.items) {
|
|
if (!item.type.startsWith("image/")) continue;
|
|
const lecteur = new FileReader();
|
|
lecteur.onload = () => {
|
|
images.push({ nom: `capture-${images.length + 1}`, type: item.type, base64: lecteur.result.split(",")[1] });
|
|
const img = document.createElement("img"); img.src = lecteur.result;
|
|
document.getElementById("vignettes").append(img);
|
|
};
|
|
lecteur.readAsDataURL(item.getAsFile());
|
|
}
|
|
});
|
|
|
|
async function poster(chemin, corps) {
|
|
const r = await fetch(chemin, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(corps) });
|
|
if (!r.ok) alert((await r.json()).erreur);
|
|
return r.ok;
|
|
}
|
|
|
|
document.getElementById("analyser").onclick = async () => {
|
|
const mail = document.getElementById("mail").value, contexte = document.getElementById("contexte").value;
|
|
if (!mail.trim()) return alert("Colle d'abord le mail du client.");
|
|
if (await poster("/analyser", { mail, contexte, images })) {
|
|
images.length = 0; document.getElementById("vignettes").innerHTML = ""; // pas de captures d'un client à l'autre
|
|
}
|
|
};
|
|
|
|
for (const b of document.querySelectorAll(".saisie button")) {
|
|
b.onclick = async () => {
|
|
const agent = b.dataset.agent, zone = document.getElementById(`saisie-${agent}`);
|
|
if (zone.value.trim() && await poster("/message", { agent, texte: zone.value })) zone.value = "";
|
|
};
|
|
}
|
|
|
|
function ajouter(fil, classe, texte, qui) {
|
|
const d = document.createElement("div"); d.className = classe;
|
|
if (qui) { const q = document.createElement("span"); q.className = "qui"; q.textContent = qui; d.append(q); }
|
|
d.append(document.createTextNode(texte));
|
|
const f = document.getElementById(`fil-${fil}`); f.append(d); f.scrollTop = f.scrollHeight;
|
|
}
|
|
|
|
function montrer(e) {
|
|
if (e.type === "cout") return;
|
|
if (e.type === "outil") return ajouter(e.agent, "outil", "→ " + e.texte);
|
|
if (e.type === "erreur") return ajouter(e.agent, "erreur", "Erreur : " + e.texte);
|
|
if (e.type === "entree") {
|
|
if (e.source === "marc") return ajouter(e.agent, "m marc", e.texte.replace(/^<mail>\n?|\n?<\/mail>[\s\S]*$/g, ""), "Toi");
|
|
return ajouter(e.agent, "m relai", e.texte, "Demande du support");
|
|
}
|
|
ajouter(e.agent, `m ${e.agent}`, e.texte, e.agent === "support" ? "Support" : "Analyste");
|
|
}
|
|
|
|
async function interroger() {
|
|
try {
|
|
let r = await (await fetch(`/evenements?depuis=${n}`)).json();
|
|
if (r.id && r.id !== id) { // une nouvelle séance : tout repartir de zéro (l'id ne change pas quand le dossier est renommé)
|
|
id = r.id; version = null;
|
|
for (const id of ["fil-support", "fil-analyste"]) document.getElementById(id).innerHTML = "";
|
|
document.getElementById("pdf").outerHTML = `<div id="pdf" class="vide">Pas encore de PDF.</div>`;
|
|
document.getElementById("version").textContent = ""; document.getElementById("telecharger").hidden = true;
|
|
r = await (await fetch(`/evenements?depuis=0`)).json();
|
|
}
|
|
r.evenements.forEach(montrer); n = r.n;
|
|
if (r.cout) document.getElementById("cout").textContent =
|
|
`Support ${r.cout.support.toFixed(2)} $\nAnalyste ${r.cout.analyste.toFixed(2)} $\nTotal ${r.cout.total.toFixed(2)} $`;
|
|
document.getElementById("dossier").textContent = r.dossier || "";
|
|
for (const a of ["support", "analyste"]) {
|
|
document.getElementById(`etat-${a}`).textContent = r.occupe[a] ? "occupé…" : "";
|
|
document.getElementById(`saisie-${a}`).disabled = r.occupe[a];
|
|
document.querySelector(`button[data-agent=${a}]`).disabled = r.occupe[a] || !r.dossier;
|
|
}
|
|
document.getElementById("analyser").disabled = r.occupe.support || r.occupe.analyste;
|
|
if (r.version && r.version !== version) {
|
|
version = r.version;
|
|
document.getElementById("version").textContent = `(${version.replace(".pdf", "")})`;
|
|
document.getElementById("pdf").outerHTML = `<iframe id="pdf" src="/pdf?v=${version}"></iframe>`;
|
|
const a = document.getElementById("telecharger"); a.href = `/pdf?v=${version}`; a.download = `${r.dossier}_${version}`; a.hidden = false;
|
|
}
|
|
} catch (e) { /* serveur arrêté : on réessaie */ }
|
|
setTimeout(interroger, 1000);
|
|
}
|
|
interroger();
|
|
</script>
|
|
</body>
|
|
</html>
|