@apotech-os/support-kit 8.3.0 → 9.0.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/ui/index.cjs CHANGED
@@ -159,9 +159,12 @@ function toGeneratedResponse(record) {
159
159
  sources: Array.isArray(data.sources) ? data.sources : [],
160
160
  verdict: toVerdict(data.verdict),
161
161
  guardrailHits: data.guardrailHits ?? [],
162
+ guardrailHitsReconstructedAt: data.guardrailHitsReconstructedAt ?? null,
162
163
  outcome: isOutcome(data.outcome) ? data.outcome : null,
163
164
  triageDecisionId: data.triageDecisionId ?? null,
164
165
  channel: data.channel ?? null,
166
+ sourceChannel: data.sourceChannel ?? null,
167
+ ineligibleReason: data.ineligibleReason ?? null,
165
168
  autoSendDecision: data.autoSendDecision ?? null,
166
169
  sentAt: data.sentAt ?? null,
167
170
  sentMessageId: data.sentMessageId ?? null,
@@ -329,6 +332,9 @@ function toNameMap(rows) {
329
332
  }
330
333
 
331
334
  // src/ui/dashboard/dashboard-stats.ts
335
+ function sumCounts(rows, countField = "count") {
336
+ return rows.reduce((sum, row) => sum + (Number(row[countField]) || 0), 0);
337
+ }
332
338
  function bucketDay(row) {
333
339
  return String(row["bucket"]).slice(0, 10);
334
340
  }
@@ -336,23 +342,38 @@ var EMPTY_TOTALS = {
336
342
  auto: 0,
337
343
  human: 0,
338
344
  inProgress: 0,
339
- noReplyNeeded: 0,
340
- failed: 0
345
+ noReplyNeeded: 0
341
346
  };
342
- function outcomeOf(status, autoSendDecision) {
343
- if (status === "test_draft") return null;
347
+ function countFailed(rows) {
348
+ return sumCounts(rows.filter((row) => row["status"] === "failed"));
349
+ }
350
+ var HUMAN_OUTCOMES = /* @__PURE__ */ new Set(["needs_human", "guardrail_hold", "escalated", "awaiting_approval"]);
351
+ function isUnautomatedTriage(row) {
352
+ return row["escalated"] === "true" || row["status"] === "error";
353
+ }
354
+ function outcomeOf(row) {
355
+ const status = row["status"];
356
+ const autoSendDecision = row["autoSendDecision"];
357
+ if (status === "test_draft" || status === "superseded") return null;
344
358
  if (status === "sent") return "auto";
345
359
  if (status === "no_reply_needed") return "noReplyNeeded";
346
- if (status === "failed") return "failed";
360
+ if (status === "failed") return "human";
347
361
  if (status === "invalidated" || status === "expired") return "human";
362
+ const outcome = row["outcome"];
363
+ if (typeof outcome === "string" && HUMAN_OUTCOMES.has(outcome)) return "human";
364
+ if (outcome === "no_reply_needed") return "noReplyNeeded";
365
+ if (outcome === "triaged_only") return null;
348
366
  return autoSendDecision === "hold" ? "human" : "inProgress";
349
367
  }
350
- function foldOutcomes(rows) {
368
+ function foldOutcomes(rows, triageRows = []) {
351
369
  const totals = { ...EMPTY_TOTALS };
352
370
  for (const row of rows) {
353
- const outcome = outcomeOf(row["status"], row["autoSendDecision"]);
371
+ const outcome = outcomeOf(row);
354
372
  if (outcome !== null) totals[outcome] += Number(row["count"]) || 0;
355
373
  }
374
+ for (const row of triageRows) {
375
+ if (isUnautomatedTriage(row)) totals.human += Number(row["count"]) || 0;
376
+ }
356
377
  return totals;
357
378
  }
358
379
  function settledCount(totals) {
@@ -362,15 +383,22 @@ function autonomyRate(totals) {
362
383
  const settled = settledCount(totals);
363
384
  return settled > 0 ? totals.auto / settled : Number.NaN;
364
385
  }
365
- function foldDailyOutcomes(rows) {
386
+ function foldDailyOutcomes(rows, triageRows = []) {
366
387
  const byDay = /* @__PURE__ */ new Map();
388
+ const totalsFor = (day) => {
389
+ const existing = byDay.get(day);
390
+ if (existing !== void 0) return existing;
391
+ const fresh = { ...EMPTY_TOTALS };
392
+ byDay.set(day, fresh);
393
+ return fresh;
394
+ };
367
395
  for (const row of rows) {
368
- const outcome = outcomeOf(row["status"], row["autoSendDecision"]);
396
+ const outcome = outcomeOf(row);
369
397
  if (outcome === null) continue;
370
- const day = bucketDay(row);
371
- const totals = byDay.get(day) ?? { ...EMPTY_TOTALS };
372
- totals[outcome] += Number(row["count"]) || 0;
373
- byDay.set(day, totals);
398
+ totalsFor(bucketDay(row))[outcome] += Number(row["count"]) || 0;
399
+ }
400
+ for (const row of triageRows) {
401
+ if (isUnautomatedTriage(row)) totalsFor(bucketDay(row)).human += Number(row["count"]) || 0;
374
402
  }
375
403
  return [...byDay.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([day, totals]) => ({
376
404
  day,
@@ -396,7 +424,7 @@ function ratePoints(rate, compareRate) {
396
424
  }
397
425
  var SIGNAL_MIN_VOLUME = 20;
398
426
  var SIGNAL_MIN_POINTS = 3;
399
- function dashboardSignals(totals, compare) {
427
+ function dashboardSignals(totals, compare, failed = 0) {
400
428
  const signals = [];
401
429
  const settled = settledCount(totals);
402
430
  const rate = autonomyRate(totals);
@@ -410,10 +438,10 @@ function dashboardSignals(totals, compare) {
410
438
  });
411
439
  }
412
440
  }
413
- if (totals.failed > 0) {
441
+ if (failed > 0) {
414
442
  signals.push({
415
443
  level: "creuser",
416
- text: `${totals.failed} g\xE9n\xE9ration${totals.failed > 1 ? "s ont" : " a"} \xE9chou\xE9 techniquement : ${totals.failed > 1 ? "ces demandes n\u2019ont" : "cette demande n\u2019a"} jamais eu de brouillon.`
444
+ text: `${failed} g\xE9n\xE9ration${failed > 1 ? "s ont" : " a"} \xE9chou\xE9 techniquement : ${failed > 1 ? "ces demandes n\u2019ont" : "cette demande n\u2019a"} jamais eu de brouillon et ${failed > 1 ? "sont retomb\xE9es" : "est retomb\xE9e"} sur un humain.`
417
445
  });
418
446
  }
419
447
  if (totals.inProgress > 0) {
@@ -436,15 +464,19 @@ function dashboardSignals(totals, compare) {
436
464
  }
437
465
  return signals;
438
466
  }
439
- function foldHumanReasons(rows) {
440
- const reasons = { blocked: 0, invalidated: 0, expired: 0 };
467
+ function foldHumanReasons(rows, triageRows = []) {
468
+ const reasons = { blocked: 0, invalidated: 0, expired: 0, escalatedNoDraft: 0, failed: 0 };
441
469
  for (const row of rows) {
442
- if (outcomeOf(row["status"], row["autoSendDecision"]) !== "human") continue;
470
+ if (outcomeOf(row) !== "human") continue;
443
471
  const count = Number(row["count"]) || 0;
444
472
  if (row["status"] === "invalidated") reasons.invalidated += count;
445
473
  else if (row["status"] === "expired") reasons.expired += count;
474
+ else if (row["status"] === "failed") reasons.failed += count;
446
475
  else reasons.blocked += count;
447
476
  }
477
+ for (const row of triageRows) {
478
+ if (isUnautomatedTriage(row)) reasons.escalatedNoDraft += Number(row["count"]) || 0;
479
+ }
448
480
  return reasons;
449
481
  }
450
482
  var CATEGORY_TOP_N = 10;
@@ -468,12 +500,15 @@ function foldCategoryOutcomes(triageRows, responseRows, categoryNames, topN = CA
468
500
  };
469
501
  for (const row of triageRows) {
470
502
  const bar = barFor(row["categoryId"]);
471
- if (bar !== null) bar.total += Number(row["count"]) || 0;
503
+ if (bar === null) continue;
504
+ const count = Number(row["count"]) || 0;
505
+ bar.total += count;
506
+ if (isUnautomatedTriage(row)) bar.human += count;
472
507
  }
473
508
  for (const row of responseRows) {
474
509
  const bar = barFor(row["categoryId"]);
475
510
  if (bar === null) continue;
476
- const outcome = outcomeOf(row["status"], row["autoSendDecision"]);
511
+ const outcome = outcomeOf(row);
477
512
  const count = Number(row["count"]) || 0;
478
513
  if (outcome === "auto") bar.auto += count;
479
514
  else if (outcome === "human") bar.human += count;
@@ -661,8 +696,10 @@ function StackedLegend({ segments }) {
661
696
  ] }, segment.key)) });
662
697
  }
663
698
  var OUTCOME_METRICS = [{ op: "count", as: "count" }];
664
- var OUTCOME_GROUP_BY = ["status", "autoSendDecision"];
665
- var CATEGORY_OUTCOME_GROUP_BY = ["categoryId", "status", "autoSendDecision"];
699
+ var OUTCOME_GROUP_BY = ["status", "autoSendDecision", "outcome"];
700
+ var CATEGORY_OUTCOME_GROUP_BY = ["categoryId", "status", "autoSendDecision", "outcome"];
701
+ var TRIAGE_HANDOFF_GROUP_BY = ["escalated", "status"];
702
+ var CATEGORY_TRIAGE_GROUP_BY = ["categoryId", "escalated", "status"];
666
703
  var CATEGORY_COLORS = {
667
704
  auto: "var(--chart-1)",
668
705
  human: "var(--chart-2)",
@@ -706,13 +743,27 @@ function DashboardPage() {
706
743
  groupBy: OUTCOME_GROUP_BY,
707
744
  metrics: OUTCOME_METRICS
708
745
  });
746
+ const { rows: dailyTriageRows, isLoading: triageLoading } = useAggregate("triage-decision", {
747
+ filter: { decidedAt: { gte: bounds.current.fromIso, lte: bounds.current.toIso } },
748
+ groupBy: TRIAGE_HANDOFF_GROUP_BY,
749
+ bucket: { field: "decidedAt", interval: bounds.interval, tz: timezone },
750
+ metrics: OUTCOME_METRICS
751
+ });
752
+ const { rows: previousTriageRows, isLoading: previousTriageLoading } = useAggregate(
753
+ "triage-decision",
754
+ {
755
+ filter: { decidedAt: { gte: previousBounds.fromIso, lte: previousBounds.toIso } },
756
+ groupBy: TRIAGE_HANDOFF_GROUP_BY,
757
+ metrics: OUTCOME_METRICS
758
+ }
759
+ );
709
760
  const {
710
761
  rows: categoryCounts,
711
762
  isLoading: categoryLoading,
712
763
  error: categoryError
713
764
  } = useAggregate("triage-decision", {
714
765
  filter: { decidedAt: { gte: bounds.current.fromIso, lte: bounds.current.toIso } },
715
- groupBy: ["categoryId"],
766
+ groupBy: CATEGORY_TRIAGE_GROUP_BY,
716
767
  metrics: OUTCOME_METRICS
717
768
  });
718
769
  const { rows: categoryOutcomes } = useAggregate("generated-response", {
@@ -722,26 +773,36 @@ function DashboardPage() {
722
773
  });
723
774
  const { rows: categories } = useRecordList("category", { limit: 500 }, toCategory);
724
775
  const categoryNames = react.useMemo(() => toNameMap(categories), [categories]);
725
- const totals = react.useMemo(() => foldOutcomes(dailyRows), [dailyRows]);
776
+ const totals = react.useMemo(
777
+ () => foldOutcomes(dailyRows, dailyTriageRows),
778
+ [dailyRows, dailyTriageRows]
779
+ );
726
780
  const compareTotals = react.useMemo(
727
- () => bounds.previous === null ? null : foldOutcomes(previousRows),
728
- [bounds.previous, previousRows]
781
+ () => bounds.previous === null ? null : foldOutcomes(previousRows, previousTriageRows),
782
+ [bounds.previous, previousRows, previousTriageRows]
729
783
  );
730
784
  const daily = react.useMemo(() => {
731
- const folded = foldDailyOutcomes(dailyRows);
785
+ const folded = foldDailyOutcomes(dailyRows, dailyTriageRows);
732
786
  return bounds.interval === "day" ? fillMissingDays(folded, bounds.current.fromIso, bounds.current.toIso) : folded;
733
- }, [dailyRows, bounds]);
787
+ }, [dailyRows, dailyTriageRows, bounds]);
734
788
  const rate = autonomyRate(totals);
735
789
  const compareRate = compareTotals === null ? Number.NaN : autonomyRate(compareTotals);
736
790
  const settled = settledCount(totals);
737
- const signals = react.useMemo(() => dashboardSignals(totals, compareTotals), [totals, compareTotals]);
738
- const reasons = react.useMemo(() => foldHumanReasons(dailyRows), [dailyRows]);
791
+ const failed = react.useMemo(() => countFailed(dailyRows), [dailyRows]);
792
+ const signals = react.useMemo(
793
+ () => dashboardSignals(totals, compareTotals, failed),
794
+ [totals, compareTotals, failed]
795
+ );
796
+ const reasons = react.useMemo(
797
+ () => foldHumanReasons(dailyRows, dailyTriageRows),
798
+ [dailyRows, dailyTriageRows]
799
+ );
739
800
  const categoryBars = react.useMemo(
740
801
  () => foldCategoryOutcomes(categoryCounts, categoryOutcomes, categoryNames),
741
802
  [categoryCounts, categoryOutcomes, categoryNames]
742
803
  );
743
804
  const categoryScale = categoryBars.reduce((max, bar) => Math.max(max, bar.total), 0);
744
- const loading = dailyLoading || previousLoading;
805
+ const loading = dailyLoading || previousLoading || triageLoading || previousTriageLoading;
745
806
  const chartData = daily.map((point) => ({ ...point, jour: dayLabel(point.day) }));
746
807
  const bucketWord = bounds.interval === "day" ? "jour" : "semaine";
747
808
  return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
@@ -924,6 +985,18 @@ function DashboardPage() {
924
985
  label: "Brouillon expir\xE9",
925
986
  value: reasons.expired,
926
987
  color: "var(--chart-5)"
988
+ },
989
+ {
990
+ key: "escalatedNoDraft",
991
+ label: "Escalad\xE9 sans brouillon",
992
+ value: reasons.escalatedNoDraft,
993
+ color: "var(--chart-4)"
994
+ },
995
+ {
996
+ key: "failed",
997
+ label: "\xC9chec technique",
998
+ value: reasons.failed,
999
+ color: "var(--destructive)"
927
1000
  }
928
1001
  ]
929
1002
  }
@@ -946,16 +1019,26 @@ function DashboardPage() {
946
1019
  key: "expired",
947
1020
  label: `Brouillon expir\xE9 (${formatCount(reasons.expired)})`,
948
1021
  color: "var(--chart-5)"
1022
+ },
1023
+ {
1024
+ key: "escalatedNoDraft",
1025
+ label: `Escalad\xE9 sans brouillon (${formatCount(reasons.escalatedNoDraft)})`,
1026
+ color: "var(--chart-4)"
1027
+ },
1028
+ {
1029
+ key: "failed",
1030
+ label: `\xC9chec technique (${formatCount(reasons.failed)})`,
1031
+ color: "var(--destructive)"
949
1032
  }
950
1033
  ]
951
1034
  }
952
1035
  ),
953
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs leading-relaxed text-muted-foreground", children: "Les escalades sont dans \xAB\xA0bloqu\xE9\xA0\xBB : un ticket escalad\xE9 voit son brouillon retenu par le garde-fou, c\u2019est un motif de blocage et non un camp de plus. Le d\xE9tail ticket par ticket est sur la page Escalades." })
1036
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs leading-relaxed text-muted-foreground", children: "\xAB\xA0Bloqu\xE9\xA0\xBB veut dire qu\u2019un brouillon existe et qu\u2019on ne l\u2019a pas envoy\xE9 \u2014 chantier de prompt ou de garde-fou. \xAB\xA0Escalad\xE9 sans brouillon\xA0\xBB veut dire qu\u2019on n\u2019a m\xEAme pas essay\xE9 de r\xE9diger\xA0: le tri a pass\xE9 la main. Le d\xE9tail ticket par ticket est sur la page Escalades." })
954
1037
  ] }) })
955
1038
  ] }),
956
1039
  /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
957
1040
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardTitle, { className: "text-sm", children: "Signaux \xE0 surveiller" }) }),
958
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { children: signals.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Rien de notable sur cette p\xE9riode \u2014 ou pas assez de demandes r\xE9gl\xE9es pour qu\u2019une comparaison veuille dire quelque chose." }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-3", children: signals.map((signal) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
1041
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { "data-testid": "dashboard-signals", children: loading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Calcul en cours\u2026" }) : signals.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Rien de notable sur cette p\xE9riode \u2014 ou pas assez de demandes r\xE9gl\xE9es pour qu\u2019une comparaison veuille dire quelque chose." }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-3", children: signals.map((signal) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
959
1042
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: signal.level === "creuser" ? "warning" : "neutral", children: signal.level === "creuser" ? "\xC0 creuser" : "Info" }),
960
1043
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm leading-relaxed", children: signal.text })
961
1044
  ] }, signal.text)) }) })
@@ -1226,7 +1309,8 @@ var GENERATED_RESPONSE_STATUS_LABELS = {
1226
1309
  no_reply_needed: "Aucune r\xE9ponse n\xE9cessaire",
1227
1310
  invalidated: "Invalid\xE9e",
1228
1311
  expired: "Expir\xE9e",
1229
- test_draft: "Brouillon d'essai \u2014 jamais envoy\xE9"
1312
+ test_draft: "Brouillon d'essai \u2014 jamais envoy\xE9",
1313
+ superseded: "Remplac\xE9e par une r\xE9ponse plus r\xE9cente"
1230
1314
  };
1231
1315
  var AUTO_SEND_DECISION_LABELS = {
1232
1316
  auto: "Autoris\xE9",
@@ -1366,7 +1450,19 @@ var GENERATED_RESPONSE_STATUSES = [
1366
1450
  // serve, send or revive a test draft — and terminal is also what frees the
1367
1451
  // `openTicketKey` (see `openTicketKeyFor`), so an essay can never hold the
1368
1452
  // real webhook at G9.
1369
- "test_draft"
1453
+ "test_draft",
1454
+ // 24/09/2026 — where a draft goes when a newer customer message arrives
1455
+ // before it was sent. The follow-up webhook used to refuse the new message
1456
+ // instead (G9 stopped on "une réponse est déjà ouverte"), which lost it
1457
+ // outright: Gorgias never replays a webhook it acked. The row is closed and
1458
+ // the pass drafts again, so the customer's latest message always wins.
1459
+ //
1460
+ // NOT `invalidated`, for the reason `test_draft` was split off it: the ticket
1461
+ // page and the dashboard read `invalidated` as "a human intervened", and a
1462
+ // draft replaced by a fresher one is nobody's intervention. Terminal, which
1463
+ // is also what releases `openTicketKey` (see `openTicketKeyFor`) — without
1464
+ // that release the replacement draft could not be created at all.
1465
+ "superseded"
1370
1466
  ];
1371
1467
  function isGeneratedResponseStatus(value) {
1372
1468
  return typeof value === "string" && GENERATED_RESPONSE_STATUSES.includes(value);
@@ -1376,15 +1472,21 @@ var ALLOWED_TRANSITIONS = {
1376
1472
  // very `pending` row it opened, and no other status can become a test
1377
1473
  // draft after the fact — an operator invalidating a real `ready` draft is
1378
1474
  // expressing "discard this", not "this was an essay".
1379
- pending: ["ready", "failed", "no_reply_needed", "sending", "invalidated", "test_draft"],
1380
- ready: ["sending", "invalidated", "expired"],
1475
+ pending: ["ready", "failed", "no_reply_needed", "sending", "invalidated", "test_draft", "superseded"],
1476
+ ready: ["sending", "invalidated", "expired", "superseded"],
1477
+ // `sending` reaches neither `invalidated` nor `superseded`, and for the same
1478
+ // reason: a worker holds the send lock, so nobody yet knows whether the
1479
+ // customer received anything. Closing that row would strand the send — the
1480
+ // sweep could no longer reclaim it, and `sentMessageId` would never be
1481
+ // written. A follow-up pass that meets one waits for it instead.
1381
1482
  sending: ["sent", "ready"],
1382
1483
  sent: [],
1383
1484
  failed: [],
1384
1485
  no_reply_needed: [],
1385
1486
  invalidated: [],
1386
1487
  expired: [],
1387
- test_draft: []
1488
+ test_draft: [],
1489
+ superseded: []
1388
1490
  };
1389
1491
  function canTransition(from, to) {
1390
1492
  if (!isGeneratedResponseStatus(from) || !isGeneratedResponseStatus(to)) return false;
@@ -1409,6 +1511,28 @@ function responseOutcome(job) {
1409
1511
  // src/domain/profile.ts
1410
1512
  var DEFAULT_PROFILE_KEY = "customer";
1411
1513
  var WHATSAPP_MODES = ["escalate_only", "draft_only", "auto_reply"];
1514
+ var SUPPORT_CHANNELS = [
1515
+ "email",
1516
+ "whatsapp",
1517
+ "phone",
1518
+ "chat",
1519
+ "sms",
1520
+ "contact-form",
1521
+ "instagram-direct-message",
1522
+ "instagram-comment",
1523
+ "instagram-mention",
1524
+ "instagram-ad-comment",
1525
+ "facebook",
1526
+ "facebook-messenger"
1527
+ ];
1528
+ var DEFAULT_AUTO_SEND_CHANNELS = [
1529
+ "email",
1530
+ "whatsapp",
1531
+ "phone",
1532
+ "chat",
1533
+ "sms",
1534
+ "contact-form"
1535
+ ];
1412
1536
  var AGENT_FIELD_NAME_UID = "e9cfec6f-15c6-4d02-8f79-0667f64b9eb5";
1413
1537
  var AGENT_FIELD_PROVIDER_UID = "e522b809-e8a7-4439-a2df-936158d04389";
1414
1538
  var AGENT_FIELD_MODEL_ID_UID = "d95977ba-362c-44d6-a2f0-24156c76cf8a";
@@ -1594,7 +1718,11 @@ function settingsToProfile(settings, prompts) {
1594
1718
  // The auto-send floor is the evaluation floor: a second, independent
1595
1719
  // threshold would be a silent way to send below the one an operator set.
1596
1720
  minConfidence: evaluate?.minConfidence ?? DEFAULT_MIN_CONFIDENCE,
1597
- requireHighTriage: settings.requireHighTriageConfidence
1721
+ requireHighTriage: settings.requireHighTriageConfidence,
1722
+ // Defaulted rather than required: `SupportKitSettings` describes what a
1723
+ // SettingsPage writes, and an app deployed before this field existed
1724
+ // has no value stored for it.
1725
+ channels: [...settings.autoSendChannels ?? DEFAULT_AUTO_SEND_CHANNELS]
1598
1726
  },
1599
1727
  rename: settings.renameEnabled ? { enabled: true, from: settings.renameFrom, to: settings.renameTo } : null,
1600
1728
  // Locks and run stamps are per-run state: they live in the
@@ -1641,6 +1769,7 @@ function toDeliveryPolicy(raw) {
1641
1769
  autoSendEnabled: settings.autoSendEnabled === true,
1642
1770
  senderEmail: senderEmail === "" ? null : senderEmail,
1643
1771
  whatsappMode: typeof settings.whatsappMode === "string" ? settings.whatsappMode : null,
1772
+ autoSendChannels: Array.isArray(settings.autoSendChannels) ? settings.autoSendChannels : [...DEFAULT_AUTO_SEND_CHANNELS],
1644
1773
  dryRun: settings.dryRun === true,
1645
1774
  audit: toAuditTags(settings)
1646
1775
  };
@@ -1733,24 +1862,113 @@ function WordDiffView({ title, tokens, keep, hideEqual = false }) {
1733
1862
 
1734
1863
  // src/ui/tickets/guardrail-labels.ts
1735
1864
  var NO_GUARDRAIL_REASON = "no_guardrail";
1736
- var GUARDRAIL_LABELS = {
1737
- whatsapp: "conversation WhatsApp",
1738
- whatsapp_stop: "le client a demand\xE9 \xE0 ne plus \xEAtre contact\xE9 (STOP)",
1739
- not_customer_turn: "le dernier message du fil est de nous",
1740
- judgeme: "avis Judge.me",
1741
- noreply_sender: "exp\xE9diteur automatique",
1742
- triage_not_high: "triage pas en confiance haute",
1743
- escalated: "ticket d\xE9j\xE0 escalad\xE9",
1744
- blocklist: "terme de la liste de blocage",
1745
- attachment: "pi\xE8ce jointe c\xF4t\xE9 client",
1746
- short_answer: "r\xE9ponse trop courte",
1747
- uncertainty_marker: "marqueur d\u2019incertitude dans la r\xE9ponse",
1748
- evaluation_missing: "aucune \xE9valuation produite"
1865
+ var GUARDRAIL_COPY = {
1866
+ whatsapp: {
1867
+ label: "conversation WhatsApp",
1868
+ explanation: "Le mode WhatsApp est r\xE9gl\xE9 sur \xAB escalade seule \xBB : sur ce canal la r\xE9ponse est r\xE9dig\xE9e puis confi\xE9e \xE0 un humain, jamais envoy\xE9e automatiquement."
1869
+ },
1870
+ whatsapp_stop: {
1871
+ label: "le client a demand\xE9 \xE0 ne plus \xEAtre contact\xE9 (STOP)",
1872
+ explanation: "Le client a \xE9crit \xAB STOP \xBB : il demande \xE0 ne plus \xEAtre contact\xE9. Rien ne part automatiquement, et le ticket est escalad\xE9 pour qu\u2019un humain acte la demande."
1873
+ },
1874
+ not_customer_turn: {
1875
+ label: "le dernier message du fil est de nous",
1876
+ explanation: "Le dernier message du fil vient de nous, pas du client : envoyer reviendrait \xE0 nous r\xE9pondre \xE0 nous-m\xEAmes."
1877
+ },
1878
+ judgeme: {
1879
+ label: "avis Judge.me",
1880
+ explanation: "Ce ticket est une notification d\u2019avis Judge.me, pas un message de client : il n\u2019appelle aucune r\xE9ponse automatique."
1881
+ },
1882
+ noreply_sender: {
1883
+ label: "exp\xE9diteur automatique",
1884
+ explanation: "L\u2019adresse de l\u2019exp\xE9diteur figure dans la liste des exp\xE9diteurs automatiques : la r\xE9ponse n\u2019atteindrait aucun humain."
1885
+ },
1886
+ triage_not_high: {
1887
+ label: "triage pas en confiance haute",
1888
+ explanation: "Le triage n\u2019a pas class\xE9 ce ticket avec une confiance haute, et les r\xE9glages exigent une confiance haute avant tout envoi automatique."
1889
+ },
1890
+ escalated: {
1891
+ label: "ticket d\xE9j\xE0 escalad\xE9",
1892
+ explanation: "Le ticket \xE9tait d\xE9j\xE0 escalad\xE9 vers un humain : l\u2019envoi automatique n\u2019a pas lieu d\u2019\xEAtre."
1893
+ },
1894
+ blocklist: {
1895
+ label: "terme de la liste de blocage",
1896
+ explanation: "Le premier message du client contient un terme de la liste de blocage : ces sujets passent obligatoirement par un humain."
1897
+ },
1898
+ attachment: {
1899
+ label: "pi\xE8ce jointe c\xF4t\xE9 client",
1900
+ explanation: "Le client a joint un ou plusieurs fichiers, que l\u2019agent ne sait pas lire : la r\xE9ponse part en revue humaine plut\xF4t que de r\xE9pondre \xE0 c\xF4t\xE9."
1901
+ },
1902
+ short_answer: {
1903
+ label: "r\xE9ponse trop courte",
1904
+ explanation: "Le brouillon fait moins de 20 caract\xE8res : trop court pour \xEAtre une vraie r\xE9ponse, il est retenu."
1905
+ },
1906
+ uncertainty_marker: {
1907
+ label: "marqueur d\u2019incertitude dans la r\xE9ponse",
1908
+ explanation: "Le brouillon contient une formule d\u2019incertitude (\xAB je ne suis pas s\xFBr \xBB, \xAB je ne peux pas \xBB\u2026) : une r\xE9ponse qui doute ne part pas seule."
1909
+ },
1910
+ evaluation_missing: {
1911
+ label: "aucune \xE9valuation produite",
1912
+ explanation: "Aucun verdict d\u2019\xE9valuation n\u2019a \xE9t\xE9 produit : sans jugement sur la r\xE9ponse, l\u2019envoi automatique est impossible."
1913
+ },
1914
+ customer_email_missing: {
1915
+ label: "client sans adresse e-mail",
1916
+ explanation: "Ce ticket n\u2019est pas un ticket WhatsApp, l\u2019envoi se ferait donc par e-mail \u2014 mais le client n\u2019a pas d\u2019adresse, ce qui est le cas des messages Instagram, Facebook ou SMS. Il n\u2019y a nulle part o\xF9 envoyer la r\xE9ponse."
1917
+ },
1918
+ ticket_closed: {
1919
+ label: "ticket ferm\xE9 entre-temps",
1920
+ explanation: "Le ticket a \xE9t\xE9 ferm\xE9 pendant que la r\xE9ponse se r\xE9digeait : l\u2019envoyer rouvrirait une conversation que quelqu\u2019un a close."
1921
+ },
1922
+ agent_replied: {
1923
+ label: "r\xE9ponse d\u2019un agent en cours de route",
1924
+ explanation: "Un agent a r\xE9pondu au client entre le lancement du run et l\u2019envoi : la r\xE9ponse automatique a \xE9t\xE9 annul\xE9e pour ne pas doubler la r\xE9ponse humaine."
1925
+ },
1926
+ diverged: {
1927
+ label: "la conversation a boug\xE9",
1928
+ explanation: "Le fil a chang\xE9 depuis la r\xE9daction \u2014 nouveau message, ou message modifi\xE9 : la r\xE9ponse pr\xE9par\xE9e ne correspond plus \xE0 ce que le client a \xE9crit."
1929
+ },
1930
+ run_deadline: {
1931
+ label: "d\xE9lai du run d\xE9pass\xE9",
1932
+ explanation: "Le run a d\xE9pass\xE9 son temps imparti avant de poster : la r\xE9ponse n\u2019est plus sous la responsabilit\xE9 de ce passage, elle n\u2019est pas envoy\xE9e."
1933
+ }
1934
+ };
1935
+ var NO_GUARDRAIL_COPY = {
1936
+ label: "bloqu\xE9e par le verdict ou le seuil, sans garde-fou",
1937
+ explanation: "Aucun garde-fou n\u2019a \xE9t\xE9 d\xE9clench\xE9 : c\u2019est le verdict du juge ou le seuil de confiance qui a retenu la r\xE9ponse."
1749
1938
  };
1939
+ function blockedTerm(hit) {
1940
+ return hit.startsWith("blocklist:") ? hit.slice("blocklist:".length) : null;
1941
+ }
1750
1942
  function guardrailHitLabel(hit) {
1751
- if (hit === NO_GUARDRAIL_REASON) return "bloqu\xE9e par le verdict ou le seuil, sans garde-fou";
1752
- if (hit.startsWith("blocklist:")) return `terme bloqu\xE9 \xAB ${hit.slice("blocklist:".length)} \xBB`;
1753
- return GUARDRAIL_LABELS[hit] ?? hit;
1943
+ if (hit === NO_GUARDRAIL_REASON) return NO_GUARDRAIL_COPY.label;
1944
+ const term = blockedTerm(hit);
1945
+ if (term !== null) return `terme bloqu\xE9 \xAB ${term} \xBB`;
1946
+ return GUARDRAIL_COPY[hit]?.label ?? hit;
1947
+ }
1948
+ function guardrailExplanation(hit) {
1949
+ if (hit === NO_GUARDRAIL_REASON) return NO_GUARDRAIL_COPY.explanation;
1950
+ const term = blockedTerm(hit);
1951
+ if (term !== null) {
1952
+ return `Le premier message du client contient \xAB ${term} \xBB, inscrit dans la liste de blocage : ces sujets passent obligatoirement par un humain.`;
1953
+ }
1954
+ return GUARDRAIL_COPY[hit]?.explanation ?? null;
1955
+ }
1956
+ var CHANNEL_LABELS = {
1957
+ email: "E-mail",
1958
+ whatsapp: "WhatsApp",
1959
+ chat: "Chat",
1960
+ phone: "T\xE9l\xE9phone",
1961
+ "contact-form": "Formulaire de contact",
1962
+ sms: "SMS",
1963
+ "instagram-direct-message": "Instagram (message priv\xE9)",
1964
+ "instagram-comment": "Instagram (commentaire)",
1965
+ "instagram-mention": "Instagram (mention)",
1966
+ "instagram-ad-comment": "Instagram (commentaire sous publicit\xE9)",
1967
+ facebook: "Facebook",
1968
+ "facebook-messenger": "Facebook Messenger"
1969
+ };
1970
+ function channelLabel(channel) {
1971
+ return CHANNEL_LABELS[channel] ?? channel;
1754
1972
  }
1755
1973
 
1756
1974
  // src/ui/tickets/timeline.ts
@@ -1821,6 +2039,8 @@ function deliveryReason(input) {
1821
2039
  }
1822
2040
  case "failed":
1823
2041
  return job.error ?? "La r\xE9ponse a \xE9chou\xE9 avant son envoi.";
2042
+ case "superseded":
2043
+ return "Le client a \xE9crit \xE0 nouveau avant l\u2019envoi : une r\xE9ponse plus r\xE9cente a remplac\xE9 celle-ci.";
1824
2044
  case "test_draft":
1825
2045
  return "Brouillon d'essai \u2014 jamais envoy\xE9.";
1826
2046
  default:
@@ -1830,9 +2050,10 @@ function deliveryReason(input) {
1830
2050
  var GENERIC_NOT_SENT = "R\xE9dig\xE9e, en attente d'un envoi.";
1831
2051
  function notSentReason({ job, policy, category }) {
1832
2052
  if (!job) return GENERIC_NOT_SENT;
1833
- if (job.autoSendDecision === "hold") {
2053
+ if (job.autoSendDecision === "hold" && job.guardrailHits.length === 0) {
1834
2054
  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).";
1835
2055
  }
2056
+ if (job.autoSendDecision === "hold") return guardrailReason(job);
1836
2057
  switch (job.outcome) {
1837
2058
  case "needs_human":
1838
2059
  return notSendableReason(job, policy);
@@ -1877,14 +2098,36 @@ function notEligibleReason(job, policy, category) {
1877
2098
  if (isWhatsapp && policy.whatsappMode === "draft_only") {
1878
2099
  return "Mode WhatsApp \xAB brouillon seul \xBB : la r\xE9ponse est r\xE9dig\xE9e, jamais envoy\xE9e automatiquement.";
1879
2100
  }
1880
- if (!policy.senderEmail && !(isWhatsapp && policy.whatsappMode === "auto_reply")) {
2101
+ if (job.ineligibleReason === "no_publication_path") {
2102
+ const channel = job.sourceChannel ? ` ${channelLabel(job.sourceChannel)}` : "";
2103
+ return `Aucun moyen de publier une r\xE9ponse sur ce ticket : Gorgias ne d\xE9clare pas le canal${channel} r\xE9pondable, ou le contact n'a pas l'adresse que ce canal exige. Le brouillon reste disponible pour un agent.`;
2104
+ }
2105
+ if (isRestrictedChannel(job.sourceChannel, policy.autoSendChannels)) {
2106
+ return `L'envoi automatique n'est pas activ\xE9 pour le canal ${channelLabel(job.sourceChannel ?? "")}. Le brouillon reste disponible pour un agent.`;
2107
+ }
2108
+ if (!policy.senderEmail && !isWhatsapp) {
1881
2109
  return "Aucune adresse d'exp\xE9dition n'est configur\xE9e dans les r\xE9glages.";
1882
2110
  }
1883
2111
  return GENERIC_NOT_SENT;
1884
2112
  }
2113
+ function isRestrictedChannel(sourceChannel, allowed) {
2114
+ if (!sourceChannel) return false;
2115
+ if (!SUPPORT_CHANNELS.includes(sourceChannel)) return false;
2116
+ return !allowed.includes(sourceChannel);
2117
+ }
1885
2118
  function guardrailReason(job) {
1886
- if (job.guardrailHits.length === 0) return "Un garde-fou a bloqu\xE9 l'envoi.";
1887
- return `Garde-fou d\xE9clench\xE9 : ${job.guardrailHits.map(guardrailHitLabel).join(", ")}.`;
2119
+ const [first, ...rest] = job.guardrailHits;
2120
+ if (first === void 0) {
2121
+ return "Un garde-fou a bloqu\xE9 l\u2019envoi (r\xE9ponse ant\xE9rieure \xE0 l\u2019enregistrement du motif).";
2122
+ }
2123
+ const explanation = guardrailExplanation(first);
2124
+ const head = `Garde-fou d\xE9clench\xE9 : ${guardrailHitLabel(first)}.`;
2125
+ const others = rest.length > 0 ? ` \xC9galement d\xE9clench\xE9 : ${rest.map(guardrailHitLabel).join(", ")}.` : "";
2126
+ return `${head}${explanation ? ` ${explanation}` : ""}${others}${reconstructionCaveat(job)}`;
2127
+ }
2128
+ function reconstructionCaveat(job) {
2129
+ if (!job.guardrailHitsReconstructedAt) return "";
2130
+ return " (Motif reconstitu\xE9 a posteriori depuis Gorgias \u2014 lecture faite avec les r\xE9glages actuels.)";
1888
2131
  }
1889
2132
  function legacyNotSentReason(job, policy, category) {
1890
2133
  if (job.guardrailHits.length > 0) return guardrailReason(job);
@@ -1922,6 +2165,13 @@ var AGENT_GUARDRAILS = [
1922
2165
  "uncertainty_marker",
1923
2166
  "evaluation_missing"
1924
2167
  ];
2168
+ var COLLISION_GUARDRAILS = [
2169
+ "customer_email_missing",
2170
+ "ticket_closed",
2171
+ "agent_replied",
2172
+ "diverged",
2173
+ "run_deadline"
2174
+ ];
1925
2175
 
1926
2176
  // src/graph/run-ticket.ts
1927
2177
  function outcomeTags(outcome, verdict, audit) {
@@ -4352,6 +4602,12 @@ function settingsWarnings(settings) {
4352
4602
  message: "Le tag d\u2019appartenance est l\u2019un des autres tags d\u2019audit, que toutes les apps posent avec la m\xEAme valeur par d\xE9faut : il ne distingue donc pas cette app d\u2019une autre install\xE9e sur le m\xEAme compte Gorgias."
4353
4603
  });
4354
4604
  }
4605
+ if (settings.autoSendEnabled === true && Array.isArray(settings.autoSendChannels) && settings.autoSendChannels.length === 0) {
4606
+ warnings.push({
4607
+ key: "noAutoSendChannels",
4608
+ message: "L\u2019envoi automatique est actif mais aucun canal n\u2019est coch\xE9 : aucune r\xE9ponse ne peut partir. Cochez au moins un canal, ou coupez l\u2019envoi automatique."
4609
+ });
4610
+ }
4355
4611
  if (appScopeTag && webhookScopeTag && appScopeTag !== webhookScopeTag) {
4356
4612
  warnings.push({
4357
4613
  key: "scopeTagMismatch",
@@ -4954,6 +5210,9 @@ function describeConnection(connections) {
4954
5210
  }
4955
5211
  return { text: `${fallback.label} (par d\xE9faut, parmi ${connections.length} connexions)`, tone: "normal" };
4956
5212
  }
5213
+ function SettingsWarnings({ warnings }) {
5214
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: warnings.map((warning) => /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-status-pending", children: warning.message }, warning.key)) });
5215
+ }
4957
5216
  function SettingsPage() {
4958
5217
  const { appSlug, role } = uiSdk.useAppContext();
4959
5218
  const canWrite = canWriteForRole(role);
@@ -5027,9 +5286,18 @@ function SettingsPage() {
5027
5286
  const claimUnverifiable = installedAppsUnavailable || uncheckedAppSlugs.length > 0;
5028
5287
  const issues = validateSettings(form);
5029
5288
  const warnings = settingsWarnings(form);
5289
+ const sendWarnings = warnings.filter((warning) => warning.key === "noAutoSendChannels");
5290
+ const tagWarnings = warnings.filter((warning) => warning.key !== "noAutoSendChannels");
5030
5291
  const nodesIssue = issues.find((issue) => issue.key === "nodes");
5031
5292
  const summaryIssues = issues.filter((issue) => issue !== nodesIssue);
5032
5293
  const guardrailsActive = Array.isArray(form.guardrailsActive) ? form.guardrailsActive : [];
5294
+ const autoSendChannels = Array.isArray(form.autoSendChannels) ? form.autoSendChannels : [];
5295
+ function toggleAutoSendChannel(channel, checked) {
5296
+ set(
5297
+ "autoSendChannels",
5298
+ checked ? [.../* @__PURE__ */ new Set([...autoSendChannels, channel])] : autoSendChannels.filter((c) => c !== channel)
5299
+ );
5300
+ }
5033
5301
  function toggleGuardrail(id, checked) {
5034
5302
  set(
5035
5303
  "guardrailsActive",
@@ -5155,6 +5423,20 @@ function SettingsPage() {
5155
5423
  ),
5156
5424
  "Envoi automatique"
5157
5425
  ] }),
5426
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5427
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-sm font-medium", children: "Canaux o\xF9 l'envoi automatique s'applique" }),
5428
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 gap-1", children: SUPPORT_CHANNELS.map((channel) => /* @__PURE__ */ jsxRuntime.jsx(
5429
+ uiSdk.Checkbox,
5430
+ {
5431
+ label: channelLabel(channel),
5432
+ checked: autoSendChannels.includes(channel),
5433
+ onCheckedChange: (checked) => toggleAutoSendChannel(channel, checked),
5434
+ disabled: !canWrite
5435
+ },
5436
+ channel
5437
+ )) }),
5438
+ /* @__PURE__ */ jsxRuntime.jsx(SettingsWarnings, { warnings: sendWarnings })
5439
+ ] }),
5158
5440
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5159
5441
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "senderEmail", className: "mb-1 block text-sm font-medium", children: "Adresse d'envoi" }),
5160
5442
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -5208,7 +5490,7 @@ function SettingsPage() {
5208
5490
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Input, { id: key, value: field(form[key]), onChange: (e) => set(key, e.target.value), disabled: !canWrite })
5209
5491
  ] }, key)),
5210
5492
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Le tag d\u2019appartenance est pos\xE9 sur chaque ticket que le triage examine, dans le m\xEAme appel que les tags ci-dessus. Il doit \xEAtre propre \xE0 cette app : c\u2019est lui qui distingue ses tickets de ceux d\u2019une autre app install\xE9e sur le m\xEAme compte Gorgias." }),
5211
- warnings.map((warning) => /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-status-pending", children: warning.message }, warning.key))
5493
+ /* @__PURE__ */ jsxRuntime.jsx(SettingsWarnings, { warnings: tagWarnings })
5212
5494
  ] }) }),
5213
5495
  /* @__PURE__ */ jsxRuntime.jsx(
5214
5496
  FollowupWebhookCard,
@@ -6754,7 +7036,6 @@ function tagOrigin(tag, settings) {
6754
7036
  }
6755
7037
 
6756
7038
  // src/ui/test/verdict-summary.ts
6757
- var COLLISION_GUARDRAILS = ["ticket_closed", "agent_replied", "diverged", "customer_email_missing", "run_deadline"];
6758
7039
  function base(result) {
6759
7040
  return { label: outcomeLabel(result.outcome), collisionHits: [], contentHits: [] };
6760
7041
  }
@@ -6770,17 +7051,29 @@ function needsHumanSentence(result) {
6770
7051
  const confidencePct = verdict.confidence !== null ? `${Math.round(verdict.confidence * 100)} %` : "une confiance inconnue";
6771
7052
  return `Le juge a r\xE9pondu \xAB ${verdict.verdict} \xBB avec ${confidencePct} de confiance${verdict.reason ? ` : ${verdict.reason}` : "."}`;
6772
7053
  }
7054
+ function isCollisionHit(hit) {
7055
+ return COLLISION_GUARDRAILS.includes(hit);
7056
+ }
6773
7057
  function guardrailHoldSummary(result) {
6774
- const collisionHits = result.guardrailHits.filter((hit) => COLLISION_GUARDRAILS.includes(hit));
6775
- const contentHits = result.guardrailHits.filter((hit) => !COLLISION_GUARDRAILS.includes(hit));
7058
+ const collisionHits = result.guardrailHits.filter((hit) => isCollisionHit(hit));
7059
+ const contentHits = result.guardrailHits.filter((hit) => !isCollisionHit(hit));
6776
7060
  const sentence = collisionHits.length > 0 ? "Le contr\xF4le anti-collision, juste avant de poster, a bloqu\xE9 la r\xE9ponse : la conversation avait boug\xE9." : `${contentHits.length} garde-fou${contentHits.length > 1 ? "s" : ""} de contenu ${contentHits.length > 1 ? "ont" : "a"} bloqu\xE9 la r\xE9ponse avant l'envoi.`;
6777
7061
  return { sentence, collisionHits, contentHits };
6778
7062
  }
6779
- function readySentence(result) {
7063
+ function readySummary(result) {
7064
+ if (result.ineligibleReason === "no_publication_path") {
7065
+ return {
7066
+ tone: "warning",
7067
+ sentence: "La r\xE9ponse est pr\xEAte pour l'extension, mais rien ne permet de la publier : Gorgias ne d\xE9clare pas ce canal r\xE9pondable, ou le contact n'a pas l'adresse que ce canal exige."
7068
+ };
7069
+ }
6780
7070
  if (!result.verdict) {
6781
- return "La r\xE9ponse est pr\xEAte pour l'extension. L'envoi n'a pas \xE9t\xE9 tent\xE9 : sans \xE9valuation, aucun verdict n'a \xE9t\xE9 produit, et l'envoi auto est impossible par construction.";
7071
+ return {
7072
+ tone: "success",
7073
+ sentence: "La r\xE9ponse est pr\xEAte pour l'extension. L'envoi n'a pas \xE9t\xE9 tent\xE9 : sans \xE9valuation, aucun verdict n'a \xE9t\xE9 produit, et l'envoi auto est impossible par construction."
7074
+ };
6782
7075
  }
6783
- return "La r\xE9ponse est pr\xEAte pour l'extension. L'envoi automatique n'\xE9tait pas \xE9ligible.";
7076
+ return { tone: "success", sentence: "La r\xE9ponse est pr\xEAte pour l'extension. L'envoi automatique n'\xE9tait pas \xE9ligible." };
6784
7077
  }
6785
7078
  function describeVerdict(result) {
6786
7079
  if (result.error) {
@@ -6805,7 +7098,7 @@ function describeVerdict(result) {
6805
7098
  case "guardrail_hold":
6806
7099
  return { ...base(result), tone: "warning", ...guardrailHoldSummary(result) };
6807
7100
  case "ready":
6808
- return { ...base(result), tone: "success", sentence: readySentence(result) };
7101
+ return { ...base(result), ...readySummary(result) };
6809
7102
  case "escalated":
6810
7103
  return { ...base(result), tone: "warning", sentence: "Le n\u0153ud d'escalade a pass\xE9 la main \xE0 un humain \u2014 aucune r\xE9ponse n'a \xE9t\xE9 r\xE9dig\xE9e." };
6811
7104
  case "triaged_only":