@apotech-os/support-kit 6.2.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-W2QU5367.js → chunk-CQJJZA4F.js} +46 -16
- package/dist/chunk-CQJJZA4F.js.map +1 -0
- package/dist/index.cjs +66 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +23 -2
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +595 -363
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +224 -27
- package/dist/ui/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-W2QU5367.js.map +0 -1
package/dist/ui/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, toAgent, toGeneratedResponse, toResponseComparison, toTriageDecision, isGeneratedResponseStatus, isInvalidatableStatus, toCategoryGroup, NODE_NAMES, settingsToProfile, hasNoDraftNode, DEFAULT_LLM_PROVIDER, computeWordDiff, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS
|
|
1
|
+
import { EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED, toAuditTags, toAgent, toGeneratedResponse, toResponseComparison, toTriageDecision, isGeneratedResponseStatus, isInvalidatableStatus, toCategoryGroup, NODE_NAMES, settingsToProfile, hasNoDraftNode, outcomeTags, DEFAULT_LLM_PROVIDER, computeWordDiff, requiresFollowup, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS } from '../chunk-CQJJZA4F.js';
|
|
2
2
|
import { forwardRef, useState, useMemo, useEffect, useRef, useCallback, useId } from 'react';
|
|
3
3
|
import { Textarea, cn, useAppContext, useAppSettings, DateRangeCompare, Link, Card, CardHeader, CardTitle, CardContent, AreaChart, StackedBarChart, Badge, useAppApi, useToast, Button, Select, DataTable, Spinner, Switch, Input, Checkbox, comparisonRange, SidePanel, Modal, Tooltip, buttonVariants, AppInvokeError, CopyButton, relativeDelta, Table, TableHeader, TableRow, TableHead, TableBody, TableCell, downloadBlob } from '@apotech-os/ui-sdk';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
@@ -1078,6 +1078,28 @@ function responseOutcome(job) {
|
|
|
1078
1078
|
return { label, variant: "neutral" };
|
|
1079
1079
|
}
|
|
1080
1080
|
|
|
1081
|
+
// src/ui/tickets/delivery-policy.ts
|
|
1082
|
+
function evaluateNode(settings) {
|
|
1083
|
+
const node = settings.nodes?.evaluate;
|
|
1084
|
+
return node && typeof node === "object" ? node : null;
|
|
1085
|
+
}
|
|
1086
|
+
function toDeliveryPolicy(raw) {
|
|
1087
|
+
if (!raw || typeof raw !== "object") return null;
|
|
1088
|
+
const settings = raw;
|
|
1089
|
+
const evaluate = evaluateNode(settings);
|
|
1090
|
+
const senderEmail = typeof settings.senderEmail === "string" ? settings.senderEmail : "";
|
|
1091
|
+
return {
|
|
1092
|
+
followupSendable: typeof evaluate?.escalationEnabled === "boolean" ? evaluate.escalationEnabled : DEFAULT_ESCALATION_ENABLED,
|
|
1093
|
+
minConfidence: typeof evaluate?.minConfidence === "number" ? evaluate.minConfidence : DEFAULT_MIN_CONFIDENCE,
|
|
1094
|
+
evaluateConfigured: evaluate !== null,
|
|
1095
|
+
autoSendEnabled: settings.autoSendEnabled === true,
|
|
1096
|
+
senderEmail: senderEmail === "" ? null : senderEmail,
|
|
1097
|
+
whatsappMode: typeof settings.whatsappMode === "string" ? settings.whatsappMode : null,
|
|
1098
|
+
dryRun: settings.dryRun === true,
|
|
1099
|
+
audit: toAuditTags(settings)
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1081
1103
|
// src/ui/tickets/match.ts
|
|
1082
1104
|
function tokensFor(row) {
|
|
1083
1105
|
return row.diff ?? computeWordDiff(row.generatedText, row.sentText);
|
|
@@ -1203,7 +1225,8 @@ function evaluationReason({ job, decision }) {
|
|
|
1203
1225
|
if (job.status === "pending") return "L'\xE9valuation n'a pas encore tourn\xE9.";
|
|
1204
1226
|
return "Aucun verdict : l'\xE9valuation n'a pas \xE9t\xE9 atteinte.";
|
|
1205
1227
|
}
|
|
1206
|
-
function deliveryReason(
|
|
1228
|
+
function deliveryReason(input) {
|
|
1229
|
+
const { job, decision } = input;
|
|
1207
1230
|
if (!job) return noResponseCause(decision);
|
|
1208
1231
|
switch (job.status) {
|
|
1209
1232
|
case "sent":
|
|
@@ -1211,15 +1234,88 @@ function deliveryReason({ job, decision }) {
|
|
|
1211
1234
|
case "pending":
|
|
1212
1235
|
return "La r\xE9ponse est encore en file.";
|
|
1213
1236
|
case "ready":
|
|
1214
|
-
return
|
|
1215
|
-
case "expired":
|
|
1216
|
-
|
|
1237
|
+
return notSentReason(input);
|
|
1238
|
+
case "expired": {
|
|
1239
|
+
const why = notSentReason(input);
|
|
1240
|
+
return why === GENERIC_NOT_SENT ? "La r\xE9ponse a expir\xE9 avant son envoi." : `La r\xE9ponse a expir\xE9 avant son envoi. ${why}`;
|
|
1241
|
+
}
|
|
1217
1242
|
case "failed":
|
|
1218
1243
|
return job.error ?? "La r\xE9ponse a \xE9chou\xE9 avant son envoi.";
|
|
1219
1244
|
default:
|
|
1220
1245
|
return `La r\xE9ponse n'a pas \xE9t\xE9 envoy\xE9e (statut : ${job.status}).`;
|
|
1221
1246
|
}
|
|
1222
1247
|
}
|
|
1248
|
+
var GENERIC_NOT_SENT = "R\xE9dig\xE9e, en attente d'un envoi.";
|
|
1249
|
+
function notSentReason({ job, policy, category }) {
|
|
1250
|
+
if (!job) return GENERIC_NOT_SENT;
|
|
1251
|
+
if (job.autoSendDecision === "hold") {
|
|
1252
|
+
return "Mise en attente d\xE9finitive : cette r\xE9ponse ne repartira pas toute seule (refus d\u2019approbation, contr\xF4le de derni\xE8re minute, ou envoi interrompu puis repris).";
|
|
1253
|
+
}
|
|
1254
|
+
switch (job.outcome) {
|
|
1255
|
+
case "needs_human":
|
|
1256
|
+
return notSendableReason(job, policy);
|
|
1257
|
+
case "guardrail_hold":
|
|
1258
|
+
return guardrailReason(job);
|
|
1259
|
+
case "awaiting_approval":
|
|
1260
|
+
return "En attente d'une approbation humaine avant envoi.";
|
|
1261
|
+
case "ready":
|
|
1262
|
+
return notEligibleReason(job, policy, category);
|
|
1263
|
+
case "sent":
|
|
1264
|
+
return "Mode essai : la r\xE9ponse aurait \xE9t\xE9 envoy\xE9e, mais rien n'a \xE9t\xE9 transmis au client.";
|
|
1265
|
+
case null:
|
|
1266
|
+
return legacyNotSentReason(job, policy, category);
|
|
1267
|
+
default:
|
|
1268
|
+
return GENERIC_NOT_SENT;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
function notSendableReason(job, policy) {
|
|
1272
|
+
const verdict = job.verdict;
|
|
1273
|
+
if (!verdict) return "L'\xE9valuation n'a produit aucun verdict \u2014 par s\xE9curit\xE9, la r\xE9ponse part en revue humaine.";
|
|
1274
|
+
if (verdict.status === "error") return "L'\xE9valuation a \xE9chou\xE9 \u2014 par s\xE9curit\xE9, la r\xE9ponse part en revue humaine.";
|
|
1275
|
+
if (verdict.verdict === "hold") return "Le juge a retenu la r\xE9ponse (verdict \xAB Retenir \xBB) \u2014 elle demande une relecture.";
|
|
1276
|
+
if (!policy) return "Le juge n'a pas autoris\xE9 l'envoi automatique.";
|
|
1277
|
+
if ((verdict.confidence ?? 0) < policy.minConfidence) {
|
|
1278
|
+
return `Confiance de ${asPercent(verdict.confidence ?? 0)} %, sous le seuil de ${asPercent(policy.minConfidence)} % fix\xE9 sur l'\xE9tape \xC9valuation.`;
|
|
1279
|
+
}
|
|
1280
|
+
if (requiresFollowup(verdict.verdict) && !policy.followupSendable) {
|
|
1281
|
+
return "Le juge a valid\xE9 la r\xE9ponse mais demand\xE9 un suivi humain (verdict \xAB Envoyer et escalader \xBB). L'option \xAB Envoyer les r\xE9ponses qui demandent un suivi humain \xBB est d\xE9sactiv\xE9e sur l'\xE9tape \xC9valuation : la r\xE9ponse n'est donc pas envoy\xE9e.";
|
|
1282
|
+
}
|
|
1283
|
+
return "Le juge n'a pas autoris\xE9 l'envoi automatique.";
|
|
1284
|
+
}
|
|
1285
|
+
function notEligibleReason(job, policy, category) {
|
|
1286
|
+
if (!policy) return GENERIC_NOT_SENT;
|
|
1287
|
+
if (!policy.evaluateConfigured) {
|
|
1288
|
+
return "L'\xE9tape \xC9valuation est coup\xE9e : sans verdict, l'envoi automatique est impossible.";
|
|
1289
|
+
}
|
|
1290
|
+
if (!policy.autoSendEnabled) return "L'envoi automatique est d\xE9sactiv\xE9 dans les r\xE9glages.";
|
|
1291
|
+
if (category && !category.autoReplyEnabled) {
|
|
1292
|
+
return `La cat\xE9gorie \xAB ${category.name} \xBB n'a pas l'auto-r\xE9ponse activ\xE9e.`;
|
|
1293
|
+
}
|
|
1294
|
+
const isWhatsapp = job.channel === "whatsapp";
|
|
1295
|
+
if (isWhatsapp && policy.whatsappMode === "draft_only") {
|
|
1296
|
+
return "Mode WhatsApp \xAB brouillon seul \xBB : la r\xE9ponse est r\xE9dig\xE9e, jamais envoy\xE9e automatiquement.";
|
|
1297
|
+
}
|
|
1298
|
+
if (!policy.senderEmail && !(isWhatsapp && policy.whatsappMode === "auto_reply")) {
|
|
1299
|
+
return "Aucune adresse d'exp\xE9dition n'est configur\xE9e dans les r\xE9glages.";
|
|
1300
|
+
}
|
|
1301
|
+
return GENERIC_NOT_SENT;
|
|
1302
|
+
}
|
|
1303
|
+
function guardrailReason(job) {
|
|
1304
|
+
if (job.guardrailHits.length === 0) return "Un garde-fou a bloqu\xE9 l'envoi.";
|
|
1305
|
+
return `Garde-fou d\xE9clench\xE9 : ${job.guardrailHits.map(guardrailHitLabel).join(", ")}.`;
|
|
1306
|
+
}
|
|
1307
|
+
function legacyNotSentReason(job, policy, category) {
|
|
1308
|
+
if (job.guardrailHits.length > 0) return guardrailReason(job);
|
|
1309
|
+
const verdict = job.verdict;
|
|
1310
|
+
if (policy && verdict && verdict.status === "success" && requiresFollowup(verdict.verdict) && !policy.followupSendable) {
|
|
1311
|
+
return "Probablement : le juge a valid\xE9 la r\xE9ponse en demandant un suivi humain, et l'option \xAB Envoyer les r\xE9ponses qui demandent un suivi humain \xBB est d\xE9sactiv\xE9e sur l'\xE9tape \xC9valuation. (R\xE9ponse ant\xE9rieure \xE0 l'enregistrement des sorties de run \u2014 lecture faite avec les r\xE9glages actuels.)";
|
|
1312
|
+
}
|
|
1313
|
+
if (verdict && (verdict.status === "error" || verdict.verdict === "hold")) return notSendableReason(job, policy);
|
|
1314
|
+
return notEligibleReason(job, policy, category);
|
|
1315
|
+
}
|
|
1316
|
+
function asPercent(ratio) {
|
|
1317
|
+
return Math.round(ratio * 100);
|
|
1318
|
+
}
|
|
1223
1319
|
function correctionReason({ comparisons }) {
|
|
1224
1320
|
if (comparisons.length > 0) return null;
|
|
1225
1321
|
return "Aucune correction captur\xE9e : l'agent n'a pas r\xE9\xE9crit de r\xE9ponse sur ce ticket.";
|
|
@@ -1230,16 +1326,59 @@ function noResponseCause(decision) {
|
|
|
1230
1326
|
if (decision.status === "error") return decision.error ?? "Le triage a \xE9chou\xE9.";
|
|
1231
1327
|
return "La cat\xE9gorie n'a pas la r\xE9ponse rapide activ\xE9e, ou n'a pas d'agent r\xE9dacteur.";
|
|
1232
1328
|
}
|
|
1329
|
+
|
|
1330
|
+
// src/ui/tickets/ticket-actions.ts
|
|
1331
|
+
function dedupe(names) {
|
|
1332
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1333
|
+
const out = [];
|
|
1334
|
+
for (const name of names) {
|
|
1335
|
+
const trimmed = (name ?? "").trim();
|
|
1336
|
+
if (!trimmed || seen.has(trimmed)) continue;
|
|
1337
|
+
seen.add(trimmed);
|
|
1338
|
+
out.push(trimmed);
|
|
1339
|
+
}
|
|
1340
|
+
return out;
|
|
1341
|
+
}
|
|
1342
|
+
function triageTagNames(input) {
|
|
1343
|
+
const { decision, category, policy } = input;
|
|
1344
|
+
return [decision.tag, ...category?.extraTags ?? [], policy?.audit.handledTag];
|
|
1345
|
+
}
|
|
1346
|
+
function wasSimulated(job, policy) {
|
|
1347
|
+
if (!job) return false;
|
|
1348
|
+
if (job.outcome === "sent" && job.status !== "sent") return true;
|
|
1349
|
+
return policy?.dryRun === true;
|
|
1350
|
+
}
|
|
1351
|
+
function ticketActions(input) {
|
|
1352
|
+
const { job, policy, notSentReason: notSentReason2 } = input;
|
|
1353
|
+
const simulated = wasSimulated(job, policy);
|
|
1354
|
+
const tags = dedupe([
|
|
1355
|
+
...triageTagNames(input),
|
|
1356
|
+
...policy ? outcomeTags(job?.outcome ?? null, job?.verdict ?? null, policy.audit) : []
|
|
1357
|
+
]);
|
|
1358
|
+
const taken = [];
|
|
1359
|
+
const skipped = [];
|
|
1360
|
+
if (job?.status === "sent") {
|
|
1361
|
+
taken.push("R\xE9ponse envoy\xE9e au client.");
|
|
1362
|
+
} else if (job) {
|
|
1363
|
+
skipped.push(`R\xE9ponse non envoy\xE9e \u2014 ${notSentReason2 ?? "raison inconnue."}`);
|
|
1364
|
+
}
|
|
1365
|
+
if (job?.outcome === "needs_human") taken.push("Alerte lev\xE9e dans la bo\xEEte de r\xE9ception.");
|
|
1366
|
+
if (job?.outcome === "awaiting_approval" && !simulated) taken.push("Demande d'approbation cr\xE9\xE9e.");
|
|
1367
|
+
return { tags, taken, skipped, simulated, unrecorded: job !== void 0 && job.outcome === null };
|
|
1368
|
+
}
|
|
1233
1369
|
function TimelinePanel(props) {
|
|
1234
|
-
const { decision, job, comparisons, conversation, conversationLoading, categoryName, onClose, onInvalidate, isInvalidating } = props;
|
|
1235
|
-
const steps = buildTimeline({ decision, job, comparisons, conversation, conversationLoading });
|
|
1370
|
+
const { decision, job, comparisons, conversation, conversationLoading, categoryName, policy, category, onClose, onInvalidate, isInvalidating } = props;
|
|
1371
|
+
const steps = buildTimeline({ decision, job, comparisons, conversation, conversationLoading, policy, category });
|
|
1372
|
+
const notSentReason2 = steps.find((step2) => step2.key === "delivery")?.reason ?? null;
|
|
1373
|
+
const actions = ticketActions({ decision, job, policy, category, notSentReason: notSentReason2 });
|
|
1236
1374
|
const canInvalidate = job !== void 0 && isGeneratedResponseStatus(job.status) && isInvalidatableStatus(job.status);
|
|
1237
1375
|
return /* @__PURE__ */ jsx(SidePanel, { open: true, onClose, title: `Ticket ${decision.ticketId}`, description: categoryName, children: /* @__PURE__ */ jsxs("div", { className: "min-h-0 flex-1 space-y-1 overflow-y-auto text-sm", children: [
|
|
1238
1376
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 pb-3", children: [
|
|
1239
1377
|
/* @__PURE__ */ jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }),
|
|
1240
1378
|
onInvalidate && canInvalidate && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: onInvalidate, disabled: isInvalidating, children: isInvalidating ? "Invalidation\u2026" : "Invalider la r\xE9ponse" })
|
|
1241
1379
|
] }),
|
|
1242
|
-
steps.map((step2, index) => /* @__PURE__ */ jsx(StepBlock, { step: step2, index, last: index === steps.length - 1, children: step2.reached ? renderStep(step2.key, props) : null }, step2.key))
|
|
1380
|
+
steps.map((step2, index) => /* @__PURE__ */ jsx(StepBlock, { step: step2, index, last: index === steps.length - 1, children: step2.reached ? renderStep(step2.key, props) : null }, step2.key)),
|
|
1381
|
+
/* @__PURE__ */ jsx(ActionsBlock, { actions })
|
|
1243
1382
|
] }) });
|
|
1244
1383
|
}
|
|
1245
1384
|
function StepBlock({
|
|
@@ -1433,6 +1572,21 @@ function PromptAttribution({ name, version }) {
|
|
|
1433
1572
|
version !== null ? ` v${version}` : ""
|
|
1434
1573
|
] });
|
|
1435
1574
|
}
|
|
1575
|
+
function ActionsBlock({ actions }) {
|
|
1576
|
+
const { tags, taken, skipped, simulated, unrecorded } = actions;
|
|
1577
|
+
if (tags.length === 0 && taken.length === 0 && skipped.length === 0) return null;
|
|
1578
|
+
return /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-2 rounded-md border p-3", children: [
|
|
1579
|
+
/* @__PURE__ */ jsx("p", { className: "text-[10px] font-semibold uppercase tracking-wider text-muted-foreground", children: simulated ? "Actions simul\xE9es (mode essai)" : "Actions sur le ticket" }),
|
|
1580
|
+
simulated && /* @__PURE__ */ jsx("p", { className: "text-xs italic text-muted-foreground", children: "Rien n\u2019a \xE9t\xE9 envoy\xE9 \xE0 Gorgias : en mode essai, le graphe tourne en entier mais n\u2019atteint aucune action externe." }),
|
|
1581
|
+
tags.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1582
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: simulated ? "Tags qui auraient \xE9t\xE9 pos\xE9s :" : "Tags pos\xE9s :" }),
|
|
1583
|
+
tags.map((tag) => /* @__PURE__ */ jsx("code", { className: "rounded bg-muted px-1.5 py-0.5 text-xs", children: tag }, tag))
|
|
1584
|
+
] }),
|
|
1585
|
+
taken.map((action) => /* @__PURE__ */ jsx("p", { className: "text-xs", children: action }, action)),
|
|
1586
|
+
skipped.map((action) => /* @__PURE__ */ jsx("p", { className: "text-xs text-status-warning", children: action }, action)),
|
|
1587
|
+
unrecorded && /* @__PURE__ */ jsx("p", { className: "text-xs italic text-muted-foreground", children: "La sortie de ce run n\u2019a pas \xE9t\xE9 enregistr\xE9e : les tags d\u2019issue ne peuvent pas \xEAtre list\xE9s avec certitude." })
|
|
1588
|
+
] });
|
|
1589
|
+
}
|
|
1436
1590
|
var DECISIONS_PAGE_SIZE = 50;
|
|
1437
1591
|
var JOIN_WINDOW_SIZE = 500;
|
|
1438
1592
|
var OUTCOME_BADGE_VARIANT = {
|
|
@@ -1476,6 +1630,7 @@ function TicketsPage() {
|
|
|
1476
1630
|
const api = useAppApi();
|
|
1477
1631
|
const toast = useToast();
|
|
1478
1632
|
const { settings } = useAppSettings();
|
|
1633
|
+
const deliveryPolicy = useMemo(() => toDeliveryPolicy(settings), [settings]);
|
|
1479
1634
|
const [period, setPeriod] = useState(() => defaultPeriod());
|
|
1480
1635
|
const [categoryFilter, setCategoryFilter] = useState("");
|
|
1481
1636
|
const [escalatedFilter, setEscalatedFilter] = useState("");
|
|
@@ -1770,6 +1925,8 @@ function TicketsPage() {
|
|
|
1770
1925
|
}),
|
|
1771
1926
|
conversationLoading: liveConversation.isLoading,
|
|
1772
1927
|
categoryName: detailDecision.categoryId && categoryNames.get(detailDecision.categoryId) || "\u2014",
|
|
1928
|
+
policy: deliveryPolicy,
|
|
1929
|
+
category: categories.find((entry) => entry.id === detailDecision.categoryId) ?? null,
|
|
1773
1930
|
agentName: detailRow?.job?.agentId && agentNames.get(detailRow.job.agentId) || "\u2014",
|
|
1774
1931
|
langfuseConfig,
|
|
1775
1932
|
onClose: () => setDetailDecision(null),
|
|
@@ -3624,18 +3781,14 @@ function StepOptions({
|
|
|
3624
3781
|
hint: "En dessous de ce seuil, la r\xE9ponse n'est jamais envoy\xE9e automatiquement."
|
|
3625
3782
|
}
|
|
3626
3783
|
),
|
|
3627
|
-
/* @__PURE__ */
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
}
|
|
3636
|
-
),
|
|
3637
|
-
"Autoriser l'escalade \u2014 une \xE9valuation insuffisante est transmise \xE0 un humain"
|
|
3638
|
-
] })
|
|
3784
|
+
/* @__PURE__ */ jsx(
|
|
3785
|
+
FollowupSendSwitch,
|
|
3786
|
+
{
|
|
3787
|
+
enabled: stepBoolean(settings, "escalationEnabled", DEFAULT_ESCALATION_ENABLED),
|
|
3788
|
+
onChange: (next) => onPatch({ escalationEnabled: next }),
|
|
3789
|
+
disabled
|
|
3790
|
+
}
|
|
3791
|
+
)
|
|
3639
3792
|
] })
|
|
3640
3793
|
] });
|
|
3641
3794
|
}
|
|
@@ -3707,6 +3860,27 @@ function useIds(stepKey) {
|
|
|
3707
3860
|
minConfidence: `${base2}-${stepKey}-min-confidence`
|
|
3708
3861
|
};
|
|
3709
3862
|
}
|
|
3863
|
+
function FollowupSendSwitch({
|
|
3864
|
+
enabled,
|
|
3865
|
+
onChange,
|
|
3866
|
+
disabled
|
|
3867
|
+
}) {
|
|
3868
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-1 text-sm sm:col-span-2", children: [
|
|
3869
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
3870
|
+
/* @__PURE__ */ jsx(
|
|
3871
|
+
Switch,
|
|
3872
|
+
{
|
|
3873
|
+
"aria-label": "Envoyer les r\xE9ponses qui demandent un suivi humain",
|
|
3874
|
+
checked: enabled,
|
|
3875
|
+
onCheckedChange: onChange,
|
|
3876
|
+
disabled
|
|
3877
|
+
}
|
|
3878
|
+
),
|
|
3879
|
+
"Envoyer les r\xE9ponses qui demandent un suivi humain"
|
|
3880
|
+
] }),
|
|
3881
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: enabled ? "Un verdict \xAB Envoyer et escalader \xBB part au client, et le ticket est tagu\xE9 pour qu\u2019un humain assure le suivi." : "Un verdict \xAB Envoyer et escalader \xBB n\u2019est jamais envoy\xE9 : la r\xE9ponse reste en attente et le ticket part en revue humaine." })
|
|
3882
|
+
] });
|
|
3883
|
+
}
|
|
3710
3884
|
function normalize(text) {
|
|
3711
3885
|
return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
3712
3886
|
}
|
|
@@ -4335,7 +4509,7 @@ var NODE_EXITS = {
|
|
|
4335
4509
|
evaluate: [
|
|
4336
4510
|
{
|
|
4337
4511
|
key: "evaluate-needs-human",
|
|
4338
|
-
condition: "verdict non envoyable
|
|
4512
|
+
condition: "verdict non envoyable ou confiance sous le seuil",
|
|
4339
4513
|
outcome: "needs_human"
|
|
4340
4514
|
},
|
|
4341
4515
|
READY_EXIT
|
|
@@ -4356,12 +4530,24 @@ var NODE_EXITS = {
|
|
|
4356
4530
|
{ key: "act-sent-whatsapp", condition: "note WhatsApp", outcome: "sent" }
|
|
4357
4531
|
]
|
|
4358
4532
|
};
|
|
4359
|
-
|
|
4533
|
+
var FOLLOWUP_BLOCKED_EXIT = {
|
|
4534
|
+
key: "evaluate-followup-blocked",
|
|
4535
|
+
condition: "verdict \xAB Envoyer et escalader \xBB, envoi des r\xE9ponses \xE0 suivre d\xE9sactiv\xE9",
|
|
4536
|
+
outcome: "needs_human"
|
|
4537
|
+
};
|
|
4538
|
+
function exitsFor(node, config) {
|
|
4360
4539
|
const raw = NODE_EXITS[node] ?? [];
|
|
4361
4540
|
const withTone = (exits) => exits.map((exit) => ({ ...exit, tone: EXIT_TONES[exit.outcome] }));
|
|
4362
|
-
if (
|
|
4363
|
-
|
|
4364
|
-
|
|
4541
|
+
if (!config.configured) {
|
|
4542
|
+
if (node === "evaluate") return [];
|
|
4543
|
+
if (node === "draft") return withTone([READY_EXIT]);
|
|
4544
|
+
return withTone(raw);
|
|
4545
|
+
}
|
|
4546
|
+
if (node === "evaluate" && !config.followupSendable) {
|
|
4547
|
+
return withTone(
|
|
4548
|
+
raw.flatMap((exit) => exit.key === "evaluate-needs-human" ? [exit, FOLLOWUP_BLOCKED_EXIT] : [exit])
|
|
4549
|
+
);
|
|
4550
|
+
}
|
|
4365
4551
|
return withTone(raw);
|
|
4366
4552
|
}
|
|
4367
4553
|
function deriveCause(state, reasons) {
|
|
@@ -4400,6 +4586,10 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
4400
4586
|
const settings = rawSettings;
|
|
4401
4587
|
const profile = settingsToProfile(settings, stubPrompts());
|
|
4402
4588
|
const evaluateConfigured = profile.nodes.evaluate !== null;
|
|
4589
|
+
const evaluateConfig = {
|
|
4590
|
+
configured: evaluateConfigured,
|
|
4591
|
+
followupSendable: profile.nodes.evaluate?.escalationEnabled ?? false
|
|
4592
|
+
};
|
|
4403
4593
|
const byNode = /* @__PURE__ */ new Map();
|
|
4404
4594
|
function set(node, state, reasons, notes = []) {
|
|
4405
4595
|
byNode.set(node, {
|
|
@@ -4409,7 +4599,7 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
4409
4599
|
reasons,
|
|
4410
4600
|
notes,
|
|
4411
4601
|
model: nodeModelOf(node, profile),
|
|
4412
|
-
exits: exitsFor(node,
|
|
4602
|
+
exits: exitsFor(node, evaluateConfig),
|
|
4413
4603
|
promptWarning: state === "on" && PROMPT_403_NODES.has(node)
|
|
4414
4604
|
});
|
|
4415
4605
|
}
|
|
@@ -4507,6 +4697,12 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
4507
4697
|
"\xC9tape coup\xE9e dans les r\xE9glages \u2014 aucun verdict, la r\xE9ponse reste \xAB Disponible \xBB.",
|
|
4508
4698
|
"nodes.evaluate est \xE0 null \u2014 la r\xE9ponse conserve l'issue \xAB ready \xBB."
|
|
4509
4699
|
);
|
|
4700
|
+
const followupNote = evaluateConfigured && !evaluateConfig.followupSendable ? [
|
|
4701
|
+
{
|
|
4702
|
+
message: "Les r\xE9ponses jug\xE9es \xAB Envoyer et escalader \xBB ne sont jamais envoy\xE9es : elles sortent en revue humaine, m\xEAme approuv\xE9es par le juge.",
|
|
4703
|
+
detail: "nodes.evaluate.escalationEnabled est \xE0 false \u2014 isSendable refuse tout verdict dont requiresFollowup est vrai (verdict/policy.ts)."
|
|
4704
|
+
}
|
|
4705
|
+
] : [];
|
|
4510
4706
|
set(
|
|
4511
4707
|
"evaluate",
|
|
4512
4708
|
deriveState(draftRuns, [], evaluateDisabled ? [evaluateOff] : []),
|
|
@@ -4520,7 +4716,8 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
4520
4716
|
"La r\xE9daction n'est jamais atteinte.",
|
|
4521
4717
|
"draft est inatteignable."
|
|
4522
4718
|
)
|
|
4523
|
-
]
|
|
4719
|
+
],
|
|
4720
|
+
followupNote
|
|
4524
4721
|
);
|
|
4525
4722
|
const evaluateRuns = passesControlOn("evaluate");
|
|
4526
4723
|
const reviseDisabled = profile.nodes.revise === null;
|