@apotech-os/support-kit 7.0.1 → 8.1.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/README.md +19 -16
- package/dist/{chunk-QCRCRNYE.js → chunk-LXHPPWPM.js} +39 -6
- package/dist/chunk-LXHPPWPM.js.map +1 -0
- package/dist/index.cjs +160 -169
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +145 -168
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +332 -174
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +301 -175
- package/dist/ui/index.js.map +1 -1
- package/package.json +11 -11
- package/dist/chunk-QCRCRNYE.js.map +0 -1
package/dist/ui/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
2
|
-
import { forwardRef, useState, useMemo,
|
|
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';
|
|
1
|
+
import { EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED, toAuditTags, toAgent, toGeneratedResponse, toResponseComparison, toTriageDecision, isGeneratedResponseStatus, isInvalidatableStatus, toCategoryGroup, followupIntegrationName, FOLLOWUP_WEBHOOK_TRIGGER, followupWebhookPath, FOLLOWUP_WEBHOOK_FORM, NODE_NAMES, settingsToProfile, hasNoDraftNode, outcomeTags, DEFAULT_LLM_PROVIDER, computeWordDiff, requiresFollowup, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS } from '../chunk-LXHPPWPM.js';
|
|
2
|
+
import { forwardRef, useState, useMemo, useRef, useEffect, useCallback, useId } from 'react';
|
|
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, useAppRun, 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';
|
|
5
5
|
|
|
6
6
|
function useRecordList(objectKey, query, mapper) {
|
|
@@ -156,6 +156,7 @@ var EMPTY_TOTALS = {
|
|
|
156
156
|
failed: 0
|
|
157
157
|
};
|
|
158
158
|
function outcomeOf(status, autoSendDecision) {
|
|
159
|
+
if (status === "test_draft") return null;
|
|
159
160
|
if (status === "sent") return "auto";
|
|
160
161
|
if (status === "no_reply_needed") return "noReplyNeeded";
|
|
161
162
|
if (status === "failed") return "failed";
|
|
@@ -165,7 +166,8 @@ function outcomeOf(status, autoSendDecision) {
|
|
|
165
166
|
function foldOutcomes(rows) {
|
|
166
167
|
const totals = { ...EMPTY_TOTALS };
|
|
167
168
|
for (const row of rows) {
|
|
168
|
-
|
|
169
|
+
const outcome = outcomeOf(row["status"], row["autoSendDecision"]);
|
|
170
|
+
if (outcome !== null) totals[outcome] += Number(row["count"]) || 0;
|
|
169
171
|
}
|
|
170
172
|
return totals;
|
|
171
173
|
}
|
|
@@ -179,9 +181,11 @@ function autonomyRate(totals) {
|
|
|
179
181
|
function foldDailyOutcomes(rows) {
|
|
180
182
|
const byDay = /* @__PURE__ */ new Map();
|
|
181
183
|
for (const row of rows) {
|
|
184
|
+
const outcome = outcomeOf(row["status"], row["autoSendDecision"]);
|
|
185
|
+
if (outcome === null) continue;
|
|
182
186
|
const day = bucketDay(row);
|
|
183
187
|
const totals = byDay.get(day) ?? { ...EMPTY_TOTALS };
|
|
184
|
-
totals[
|
|
188
|
+
totals[outcome] += Number(row["count"]) || 0;
|
|
185
189
|
byDay.set(day, totals);
|
|
186
190
|
}
|
|
187
191
|
return [...byDay.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([day, totals]) => ({
|
|
@@ -934,6 +938,31 @@ function TicketLink({ ticketId, url, label }) {
|
|
|
934
938
|
}
|
|
935
939
|
);
|
|
936
940
|
}
|
|
941
|
+
function readParam(name) {
|
|
942
|
+
if (typeof window === "undefined") return null;
|
|
943
|
+
return new URLSearchParams(window.location.search).get(name);
|
|
944
|
+
}
|
|
945
|
+
function useQueryParam(name) {
|
|
946
|
+
const [value, setState] = useState(() => readParam(name));
|
|
947
|
+
useEffect(() => {
|
|
948
|
+
const sync = () => setState(readParam(name));
|
|
949
|
+
sync();
|
|
950
|
+
window.addEventListener("popstate", sync);
|
|
951
|
+
return () => window.removeEventListener("popstate", sync);
|
|
952
|
+
}, [name]);
|
|
953
|
+
const setValue = useCallback(
|
|
954
|
+
(next) => {
|
|
955
|
+
const params = new URLSearchParams(window.location.search);
|
|
956
|
+
if (next === null) params.delete(name);
|
|
957
|
+
else params.set(name, next);
|
|
958
|
+
const query = params.toString();
|
|
959
|
+
window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
|
|
960
|
+
setState(next);
|
|
961
|
+
},
|
|
962
|
+
[name]
|
|
963
|
+
);
|
|
964
|
+
return { value, setValue };
|
|
965
|
+
}
|
|
937
966
|
var UNCONFIGURED = { baseUrl: null, projectId: null };
|
|
938
967
|
function useLangfuseConfig() {
|
|
939
968
|
const { appSlug } = useAppContext();
|
|
@@ -1011,7 +1040,8 @@ var GENERATED_RESPONSE_STATUS_LABELS = {
|
|
|
1011
1040
|
failed: "\xC9chec",
|
|
1012
1041
|
no_reply_needed: "Aucune r\xE9ponse n\xE9cessaire",
|
|
1013
1042
|
invalidated: "Invalid\xE9e",
|
|
1014
|
-
expired: "Expir\xE9e"
|
|
1043
|
+
expired: "Expir\xE9e",
|
|
1044
|
+
test_draft: "Brouillon d'essai \u2014 jamais envoy\xE9"
|
|
1015
1045
|
};
|
|
1016
1046
|
var AUTO_SEND_DECISION_LABELS = {
|
|
1017
1047
|
auto: "Autoris\xE9",
|
|
@@ -1241,6 +1271,8 @@ function deliveryReason(input) {
|
|
|
1241
1271
|
}
|
|
1242
1272
|
case "failed":
|
|
1243
1273
|
return job.error ?? "La r\xE9ponse a \xE9chou\xE9 avant son envoi.";
|
|
1274
|
+
case "test_draft":
|
|
1275
|
+
return "Brouillon d'essai \u2014 jamais envoy\xE9.";
|
|
1244
1276
|
default:
|
|
1245
1277
|
return `La r\xE9ponse n'a pas \xE9t\xE9 envoy\xE9e (statut : ${job.status}).`;
|
|
1246
1278
|
}
|
|
@@ -1753,6 +1785,15 @@ function TicketsPage() {
|
|
|
1753
1785
|
return true;
|
|
1754
1786
|
});
|
|
1755
1787
|
}, [decisions, jobByDecisionId, comparisonsByTicketId, outcomeFilter, verdictFilter, promptVersionFilter, correctedFilter]);
|
|
1788
|
+
const requestedTicket = useQueryParam("ticket").value;
|
|
1789
|
+
const deepLinkConsumed = useRef(false);
|
|
1790
|
+
useEffect(() => {
|
|
1791
|
+
if (deepLinkConsumed.current || !requestedTicket) return;
|
|
1792
|
+
const match = rows.find((row) => row.decision.ticketId === requestedTicket);
|
|
1793
|
+
if (!match) return;
|
|
1794
|
+
deepLinkConsumed.current = true;
|
|
1795
|
+
setDetailDecision(match.decision);
|
|
1796
|
+
}, [requestedTicket, rows]);
|
|
1756
1797
|
const categoryOptions = useMemo(
|
|
1757
1798
|
() => [{ value: "", label: "Toutes cat\xE9gories" }, ...categories.map((category) => ({ value: category.id, label: category.name }))],
|
|
1758
1799
|
[categories]
|
|
@@ -4001,156 +4042,85 @@ function SourceViewField({ views, value, onChange, disabled }) {
|
|
|
4001
4042
|
}
|
|
4002
4043
|
);
|
|
4003
4044
|
}
|
|
4004
|
-
var STATUS_BADGE = {
|
|
4005
|
-
passed: { label: "OK", variant: "success" },
|
|
4006
|
-
stopped: { label: "Arr\xEAt", variant: "danger" },
|
|
4007
|
-
// A pre-gate that could not read its field. Never shown by the diagnostic
|
|
4008
|
-
// (it evaluates no payload) but rendered honestly if it ever appears, rather
|
|
4009
|
-
// than falling through to a blank badge.
|
|
4010
|
-
muted: { label: "Muet", variant: "warning" },
|
|
4011
|
-
skipped: { label: "Non \xE9valu\xE9", variant: "neutral" }
|
|
4012
|
-
};
|
|
4013
4045
|
function FollowupWebhookCard({ scopeTag, onScopeTagChange, canWrite }) {
|
|
4014
|
-
const
|
|
4015
|
-
const toast = useToast();
|
|
4046
|
+
const { appSlug } = useAppContext();
|
|
4016
4047
|
const scopeId = useId();
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
}
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
return /* @__PURE__ */ jsxs(Card, { id: "webhook-suite", children: [
|
|
4049
|
-
/* @__PURE__ */ jsxs(CardContent, { className: "space-y-4 p-4", children: [
|
|
4050
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
4051
|
-
/* @__PURE__ */ jsx("h2", { className: "font-medium", children: "R\xE9ponses aux messages suivants" }),
|
|
4052
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Quand un client r\xE9pond sur un ticket d\xE9j\xE0 trait\xE9, l'agent peut g\xE9n\xE9rer une nouvelle r\xE9ponse. Chaque cat\xE9gorie d\xE9cide si elle suit le fil (page Cat\xE9gories)." })
|
|
4053
|
-
] }),
|
|
4054
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
4055
|
-
/* @__PURE__ */ jsx("label", { htmlFor: scopeId, className: "mb-1 block text-sm font-medium", children: "Tag de p\xE9rim\xE8tre webhook" }),
|
|
4056
|
-
/* @__PURE__ */ jsx(
|
|
4057
|
-
Input,
|
|
4058
|
-
{
|
|
4059
|
-
id: scopeId,
|
|
4060
|
-
value: scopeTag,
|
|
4061
|
-
onChange: (e) => onScopeTagChange(e.target.value),
|
|
4062
|
-
placeholder: "wai/triaged",
|
|
4063
|
-
disabled: !canWrite
|
|
4064
|
-
}
|
|
4065
|
-
),
|
|
4066
|
-
/* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs text-muted-foreground", children: [
|
|
4067
|
-
"Le ticket doit d\xE9j\xE0 porter ce tag pour qu'un message suivant soit trait\xE9 \u2014 typiquement le tag \xAB trait\xE9 \xBB pos\xE9 par le premier passage. ",
|
|
4068
|
-
/* @__PURE__ */ jsx("strong", { children: "Vide = aucun message suivant trait\xE9" }),
|
|
4069
|
-
" (c'est aussi le kill-switch). Deux apps sur le m\xEAme compte Gorgias doivent y mettre des valeurs ",
|
|
4070
|
-
/* @__PURE__ */ jsx("strong", { children: "distinctes" }),
|
|
4071
|
-
", sinon chacune r\xE9pondrait sur les tickets de l'autre."
|
|
4072
|
-
] })
|
|
4048
|
+
return /* @__PURE__ */ jsx(Card, { id: "webhook-suite", children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-4 p-4", children: [
|
|
4049
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4050
|
+
/* @__PURE__ */ jsx("h2", { className: "font-medium", children: "R\xE9ponses aux messages suivants" }),
|
|
4051
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Quand un client r\xE9pond sur un ticket d\xE9j\xE0 trait\xE9, l'agent peut g\xE9n\xE9rer une nouvelle r\xE9ponse. Chaque cat\xE9gorie d\xE9cide si elle suit le fil (page Cat\xE9gories)." })
|
|
4052
|
+
] }),
|
|
4053
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4054
|
+
/* @__PURE__ */ jsx("label", { htmlFor: scopeId, className: "mb-1 block text-sm font-medium", children: "Tag de p\xE9rim\xE8tre webhook" }),
|
|
4055
|
+
/* @__PURE__ */ jsx(
|
|
4056
|
+
Input,
|
|
4057
|
+
{
|
|
4058
|
+
id: scopeId,
|
|
4059
|
+
value: scopeTag,
|
|
4060
|
+
onChange: (e) => onScopeTagChange(e.target.value),
|
|
4061
|
+
placeholder: "wai/triaged",
|
|
4062
|
+
disabled: !canWrite
|
|
4063
|
+
}
|
|
4064
|
+
),
|
|
4065
|
+
/* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs text-muted-foreground", children: [
|
|
4066
|
+
"Le ticket doit d\xE9j\xE0 porter ce tag pour qu'un message suivant soit trait\xE9 \u2014 typiquement le tag \xAB trait\xE9 \xBB pos\xE9 par le premier passage. ",
|
|
4067
|
+
/* @__PURE__ */ jsx("strong", { children: "Vide = aucun message suivant trait\xE9" }),
|
|
4068
|
+
" (c'est aussi le kill-switch). Deux apps sur le m\xEAme compte Gorgias doivent y mettre des valeurs ",
|
|
4069
|
+
/* @__PURE__ */ jsx("strong", { children: "distinctes" }),
|
|
4070
|
+
", sinon chacune r\xE9pondrait sur les tickets de l'autre."
|
|
4071
|
+
] })
|
|
4072
|
+
] }),
|
|
4073
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2 border-t pt-4", children: [
|
|
4074
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: "Int\xE9gration Gorgias (installation manuelle)" }),
|
|
4075
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
4076
|
+
"\xC0 cr\xE9er une fois dans Gorgias, sous ",
|
|
4077
|
+
/* @__PURE__ */ jsx("em", { children: "Settings \u203A Integrations \u203A HTTP" }),
|
|
4078
|
+
". Rien n'est install\xE9 depuis cette page : l'app n'\xE9crit rien sur le compte Gorgias."
|
|
4073
4079
|
] }),
|
|
4074
|
-
/* @__PURE__ */ jsxs("
|
|
4075
|
-
/* @__PURE__ */ jsx(
|
|
4076
|
-
/* @__PURE__ */
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
"
|
|
4080
|
-
|
|
4081
|
-
/* @__PURE__ */ jsx("code", { children: "wopilo_app_\u2026" }),
|
|
4082
|
-
"), puis installez l'int\xE9gration. L'op\xE9ration est idempotente : re-cliquer la met \xE0 jour."
|
|
4080
|
+
/* @__PURE__ */ jsxs("dl", { className: "space-y-1 text-xs", children: [
|
|
4081
|
+
/* @__PURE__ */ jsx(RecipeRow, { label: "Nom", children: followupIntegrationName(appSlug) }),
|
|
4082
|
+
/* @__PURE__ */ jsx(RecipeRow, { label: "D\xE9clencheur", children: FOLLOWUP_WEBHOOK_TRIGGER }),
|
|
4083
|
+
/* @__PURE__ */ jsx(RecipeRow, { label: "M\xE9thode", children: "POST" }),
|
|
4084
|
+
/* @__PURE__ */ jsxs(RecipeRow, { label: "URL", children: [
|
|
4085
|
+
"<PUBLIC_BASE_URL>",
|
|
4086
|
+
followupWebhookPath(appSlug)
|
|
4083
4087
|
] }),
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
"
|
|
4088
|
-
" ",
|
|
4089
|
-
/* @__PURE__ */ jsx("code", { children: setup.url }),
|
|
4090
|
-
"."
|
|
4088
|
+
/* @__PURE__ */ jsxs(RecipeRow, { label: "En-t\xEAte", children: [
|
|
4089
|
+
"Authorization: Bearer <cl\xE9 d'application ",
|
|
4090
|
+
/* @__PURE__ */ jsx("code", { children: "wopilo_app_\u2026" }),
|
|
4091
|
+
">"
|
|
4091
4092
|
] })
|
|
4092
4093
|
] }),
|
|
4093
|
-
/* @__PURE__ */ jsxs("
|
|
4094
|
-
/* @__PURE__ */ jsx("
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
/* @__PURE__ */ jsx("
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
] }),
|
|
4114
|
-
|
|
4115
|
-
"Traitement d\xE9clench\xE9. Run \xE0 suivre : ",
|
|
4116
|
-
/* @__PURE__ */ jsx("code", { children: test.runId }),
|
|
4117
|
-
"."
|
|
4118
|
-
] }),
|
|
4119
|
-
test?.mode === "diagnostic" && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
4120
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: test.stoppedAt === null ? `Ticket ${test.ticketId} : il aurait re\xE7u une r\xE9ponse de suite.` : `Ticket ${test.ticketId} : arr\xEAt en ${test.stoppedAt}.` }),
|
|
4121
|
-
/* @__PURE__ */ jsx("ul", { className: "space-y-1", children: test.gates.map((gate) => /* @__PURE__ */ jsxs("li", { className: "flex items-start gap-2 text-xs", children: [
|
|
4122
|
-
/* @__PURE__ */ jsx(Badge, { variant: STATUS_BADGE[gate.status].variant, children: STATUS_BADGE[gate.status].label }),
|
|
4123
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
4124
|
-
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
4125
|
-
gate.gate,
|
|
4126
|
-
" \u2014 ",
|
|
4127
|
-
gate.label
|
|
4128
|
-
] }),
|
|
4129
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
4130
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: gate.detail })
|
|
4131
|
-
] })
|
|
4132
|
-
] }, gate.gate)) })
|
|
4133
|
-
] })
|
|
4094
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
4095
|
+
/* @__PURE__ */ jsx("code", { children: "PUBLIC_BASE_URL" }),
|
|
4096
|
+
" est l'origine publique de l'",
|
|
4097
|
+
/* @__PURE__ */ jsx("strong", { children: "API" }),
|
|
4098
|
+
" \u2014 pas forc\xE9ment celle de cette interface, que l'instance peut servir depuis un autre domaine (",
|
|
4099
|
+
/* @__PURE__ */ jsx("code", { children: "WEB_APP_URL" }),
|
|
4100
|
+
"). En cas de doute, c'est la valeur r\xE9gl\xE9e c\xF4t\xE9 instance qui fait foi : une URL construite sur la mauvaise origine renvoie 404 \xE0 chaque appel Gorgias, sans message d'erreur nulle part."
|
|
4101
|
+
] }),
|
|
4102
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
4103
|
+
"La cl\xE9 est une cl\xE9 d'application de cette app, cr\xE9\xE9e dans la plateforme puis coll\xE9e telle quelle dans l'en-t\xEAte. Elle porte le r\xF4le manifeste complet de l'app (voir",
|
|
4104
|
+
" ",
|
|
4105
|
+
/* @__PURE__ */ jsx("code", { children: "docs/app-platform/gorgias-callback-authentication.md" }),
|
|
4106
|
+
" \xA75)."
|
|
4107
|
+
] }),
|
|
4108
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4109
|
+
/* @__PURE__ */ jsx("p", { className: "mb-1 text-xs font-medium", children: "Champs du corps (onglet \xAB Body \xBB, un par ligne)" }),
|
|
4110
|
+
/* @__PURE__ */ jsx("ul", { className: "space-y-0.5 font-mono text-xs text-muted-foreground", children: Object.entries(FOLLOWUP_WEBHOOK_FORM).map(([key, value]) => /* @__PURE__ */ jsxs("li", { children: [
|
|
4111
|
+
key,
|
|
4112
|
+
" = ",
|
|
4113
|
+
value
|
|
4114
|
+
] }, key)) }),
|
|
4115
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "Les quatre derniers champs ne sont pas document\xE9s par Gorgias : s'ils ne se r\xE9solvent pas, le traitement relit simplement le ticket et continue. Rien ne casse s'ils manquent." })
|
|
4134
4116
|
] })
|
|
4135
|
-
] })
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
ticket.trim(),
|
|
4143
|
-
" va \xEAtre trait\xE9 comme un vrai message suivant : g\xE9n\xE9ration, garde-fous, et",
|
|
4144
|
-
" ",
|
|
4145
|
-
/* @__PURE__ */ jsx("strong", { children: "envoi r\xE9el au client" }),
|
|
4146
|
-
" si sa cat\xE9gorie est en r\xE9ponse automatique. \xC0 r\xE9server \xE0 un ticket de test."
|
|
4147
|
-
] }),
|
|
4148
|
-
confirmLabel: "Lancer",
|
|
4149
|
-
busyLabel: "D\xE9clenchement\u2026",
|
|
4150
|
-
onConfirm: () => runTest("run"),
|
|
4151
|
-
onCancel: () => setConfirmingRealRun(false)
|
|
4152
|
-
}
|
|
4153
|
-
)
|
|
4117
|
+
] })
|
|
4118
|
+
] }) });
|
|
4119
|
+
}
|
|
4120
|
+
function RecipeRow({ label, children }) {
|
|
4121
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
4122
|
+
/* @__PURE__ */ jsx("dt", { className: "w-24 shrink-0 text-muted-foreground", children: label }),
|
|
4123
|
+
/* @__PURE__ */ jsx("dd", { className: "break-all font-mono", children })
|
|
4154
4124
|
] });
|
|
4155
4125
|
}
|
|
4156
4126
|
var WHATSAPP_MODE_LABELS = {
|
|
@@ -4610,31 +4580,6 @@ function SettingsPage() {
|
|
|
4610
4580
|
);
|
|
4611
4581
|
}
|
|
4612
4582
|
var ReglagesPage = SettingsPage;
|
|
4613
|
-
function readParam(name) {
|
|
4614
|
-
if (typeof window === "undefined") return null;
|
|
4615
|
-
return new URLSearchParams(window.location.search).get(name);
|
|
4616
|
-
}
|
|
4617
|
-
function useQueryParam(name) {
|
|
4618
|
-
const [value, setState] = useState(() => readParam(name));
|
|
4619
|
-
useEffect(() => {
|
|
4620
|
-
const sync = () => setState(readParam(name));
|
|
4621
|
-
sync();
|
|
4622
|
-
window.addEventListener("popstate", sync);
|
|
4623
|
-
return () => window.removeEventListener("popstate", sync);
|
|
4624
|
-
}, [name]);
|
|
4625
|
-
const setValue = useCallback(
|
|
4626
|
-
(next) => {
|
|
4627
|
-
const params = new URLSearchParams(window.location.search);
|
|
4628
|
-
if (next === null) params.delete(name);
|
|
4629
|
-
else params.set(name, next);
|
|
4630
|
-
const query = params.toString();
|
|
4631
|
-
window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
|
|
4632
|
-
setState(next);
|
|
4633
|
-
},
|
|
4634
|
-
[name]
|
|
4635
|
-
);
|
|
4636
|
-
return { value, setValue };
|
|
4637
|
-
}
|
|
4638
4583
|
|
|
4639
4584
|
// src/ui/graph-canvas/reachability.ts
|
|
4640
4585
|
var EXIT_TONES = {
|
|
@@ -6208,6 +6153,185 @@ function DryRunResultView({ result, langfuseConfig, knownTags, tagSettings }) {
|
|
|
6208
6153
|
] })
|
|
6209
6154
|
] });
|
|
6210
6155
|
}
|
|
6156
|
+
var STATUS_BADGE = {
|
|
6157
|
+
passed: { label: "OK", variant: "success" },
|
|
6158
|
+
stopped: { label: "Arr\xEAt", variant: "danger" },
|
|
6159
|
+
// A pre-gate that could not read its field. The diagnostic never produces
|
|
6160
|
+
// one (it evaluates no payload), but a run stopped on a pre-gate does —
|
|
6161
|
+
// rendered honestly rather than falling through to a blank badge.
|
|
6162
|
+
muted: { label: "Muet", variant: "warning" },
|
|
6163
|
+
skipped: { label: "Non \xE9valu\xE9", variant: "neutral" }
|
|
6164
|
+
};
|
|
6165
|
+
function GatesTable({ gates }) {
|
|
6166
|
+
return /* @__PURE__ */ jsx("ul", { className: "space-y-1", children: gates.map((gate) => {
|
|
6167
|
+
const badge = STATUS_BADGE[gate.status] ?? STATUS_BADGE.skipped;
|
|
6168
|
+
return /* @__PURE__ */ jsxs("li", { className: "flex items-start gap-2 text-xs", children: [
|
|
6169
|
+
/* @__PURE__ */ jsx(Badge, { variant: badge.variant, children: badge.label }),
|
|
6170
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
6171
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
6172
|
+
gate.gate,
|
|
6173
|
+
" \u2014 ",
|
|
6174
|
+
gate.label
|
|
6175
|
+
] }),
|
|
6176
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
6177
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: gate.detail })
|
|
6178
|
+
] })
|
|
6179
|
+
] }, gate.gate);
|
|
6180
|
+
}) });
|
|
6181
|
+
}
|
|
6182
|
+
function parseRunResult(result) {
|
|
6183
|
+
if (typeof result !== "object" || result === null) return null;
|
|
6184
|
+
const raw = result;
|
|
6185
|
+
if (!Array.isArray(raw.gates)) return null;
|
|
6186
|
+
return {
|
|
6187
|
+
ticketId: typeof raw.ticketId === "string" ? raw.ticketId : null,
|
|
6188
|
+
stoppedAt: typeof raw.stoppedAt === "string" ? raw.stoppedAt : null,
|
|
6189
|
+
reason: typeof raw.reason === "string" ? raw.reason : null,
|
|
6190
|
+
gates: raw.gates,
|
|
6191
|
+
categoryName: typeof raw.categoryName === "string" ? raw.categoryName : null,
|
|
6192
|
+
outcome: typeof raw.outcome === "string" ? raw.outcome : null,
|
|
6193
|
+
responseId: typeof raw.responseId === "string" ? raw.responseId : null
|
|
6194
|
+
};
|
|
6195
|
+
}
|
|
6196
|
+
function describeRunDecision(result, mode) {
|
|
6197
|
+
if (result.stoppedAt !== null) return `Arr\xEAt en ${result.stoppedAt}.`;
|
|
6198
|
+
const category = result.categoryName ? ` (cat\xE9gorie \xAB ${result.categoryName} \xBB)` : "";
|
|
6199
|
+
if (result.outcome === "sent") {
|
|
6200
|
+
return mode === "generate" ? `La r\xE9ponse aurait \xE9t\xE9 envoy\xE9e au client${category} \u2014 g\xE9n\xE9r\xE9e sans envoi.` : `La r\xE9ponse a \xE9t\xE9 envoy\xE9e au client${category}.`;
|
|
6201
|
+
}
|
|
6202
|
+
const label = result.outcome !== null && result.outcome in OUTCOME_LABELS ? OUTCOME_LABELS[result.outcome] : null;
|
|
6203
|
+
return label ? `${label}${category}.` : `Traitement termin\xE9${category}.`;
|
|
6204
|
+
}
|
|
6205
|
+
function FollowupWebhookCard2() {
|
|
6206
|
+
const api = useAppApi();
|
|
6207
|
+
const { appSlug } = useAppContext();
|
|
6208
|
+
const toast = useToast();
|
|
6209
|
+
const ticketId = useId();
|
|
6210
|
+
const [ticket, setTicket] = useState("");
|
|
6211
|
+
const [test, setTest] = useState(null);
|
|
6212
|
+
const [isTesting, setIsTesting] = useState(false);
|
|
6213
|
+
const [confirmingRealRun, setConfirmingRealRun] = useState(false);
|
|
6214
|
+
const followedRunId = test !== null && test.mode !== "diagnostic" ? test.runId : null;
|
|
6215
|
+
const { run, isPolling } = useAppRun(followedRunId);
|
|
6216
|
+
const runResult = run && run.status === "succeeded" ? parseRunResult(run.result) : null;
|
|
6217
|
+
const [draftText, setDraftText] = useState(null);
|
|
6218
|
+
useEffect(() => {
|
|
6219
|
+
setDraftText(null);
|
|
6220
|
+
const responseId = runResult?.responseId;
|
|
6221
|
+
if (!responseId) return;
|
|
6222
|
+
let cancelled = false;
|
|
6223
|
+
void api.get(
|
|
6224
|
+
`/data/apps/${appSlug}/records/generated-response/${encodeURIComponent(responseId)}`
|
|
6225
|
+
).then((record) => {
|
|
6226
|
+
if (!cancelled) setDraftText(record?.data?.responseText ?? null);
|
|
6227
|
+
}).catch(() => {
|
|
6228
|
+
});
|
|
6229
|
+
return () => {
|
|
6230
|
+
cancelled = true;
|
|
6231
|
+
};
|
|
6232
|
+
}, [runResult?.responseId, appSlug]);
|
|
6233
|
+
async function runTest(mode) {
|
|
6234
|
+
setIsTesting(true);
|
|
6235
|
+
setTest(null);
|
|
6236
|
+
try {
|
|
6237
|
+
setTest(await api.invoke("test-gorgias-webhook", { ticketId: ticket.trim(), mode }));
|
|
6238
|
+
} catch (err) {
|
|
6239
|
+
toast({ title: "\xC9chec du test", description: describeInvokeError(err), variant: "error" });
|
|
6240
|
+
} finally {
|
|
6241
|
+
setIsTesting(false);
|
|
6242
|
+
setConfirmingRealRun(false);
|
|
6243
|
+
}
|
|
6244
|
+
}
|
|
6245
|
+
const disabled = !ticket.trim() || isTesting;
|
|
6246
|
+
return /* @__PURE__ */ jsxs(Card, { id: "webhook-suite", children: [
|
|
6247
|
+
/* @__PURE__ */ jsxs(CardContent, { className: "space-y-3 p-4", children: [
|
|
6248
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
6249
|
+
/* @__PURE__ */ jsx("h2", { className: "font-medium", children: "R\xE9ponses aux messages suivants" }),
|
|
6250
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Rejoue sur un ticket r\xE9el ce que ferait le webhook Gorgias quand un client r\xE9pond sur un ticket d\xE9j\xE0 trait\xE9. Le tag de p\xE9rim\xE8tre et les cat\xE9gories se r\xE8glent dans Param\xE8tres." })
|
|
6251
|
+
] }),
|
|
6252
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2 border-t pt-3", children: [
|
|
6253
|
+
/* @__PURE__ */ jsx("label", { htmlFor: ticketId, className: "block text-sm font-medium", children: "Ticket \xE0 tester" }),
|
|
6254
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
6255
|
+
/* @__PURE__ */ jsx(
|
|
6256
|
+
Input,
|
|
6257
|
+
{
|
|
6258
|
+
id: ticketId,
|
|
6259
|
+
value: ticket,
|
|
6260
|
+
onChange: (e) => setTicket(e.target.value),
|
|
6261
|
+
placeholder: "1534712154",
|
|
6262
|
+
className: "max-w-48"
|
|
6263
|
+
}
|
|
6264
|
+
),
|
|
6265
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: () => void runTest("diagnostic"), disabled, children: "Diagnostic" }),
|
|
6266
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: () => void runTest("generate"), disabled, children: "G\xE9n\xE9rer sans envoyer" }),
|
|
6267
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: () => setConfirmingRealRun(true), disabled, children: "Ex\xE9cution r\xE9elle" })
|
|
6268
|
+
] }),
|
|
6269
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
6270
|
+
"Le diagnostic \xE9value les m\xEAmes conditions que le webhook, sans aucun effet de bord.",
|
|
6271
|
+
" ",
|
|
6272
|
+
/* @__PURE__ */ jsx("strong", { children: "G\xE9n\xE9rer sans envoyer" }),
|
|
6273
|
+
" produit la r\xE9ponse compl\xE8te \u2014 m\xEAme si la cat\xE9gorie n'a pas activ\xE9 les r\xE9ponses aux messages suivants \u2014 et ne l'envoie jamais ; elle se lit dans la fiche du ticket. L'ex\xE9cution r\xE9elle d\xE9clenche le vrai traitement."
|
|
6274
|
+
] }),
|
|
6275
|
+
isTesting && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
|
|
6276
|
+
/* @__PURE__ */ jsx(Spinner, {}),
|
|
6277
|
+
" Test en cours\u2026"
|
|
6278
|
+
] }),
|
|
6279
|
+
test?.mode === "generate" && /* @__PURE__ */ jsxs("p", { className: "text-sm", children: [
|
|
6280
|
+
"G\xE9n\xE9ration d\xE9clench\xE9e, sans envoi. Run \xE0 suivre : ",
|
|
6281
|
+
/* @__PURE__ */ jsx("code", { children: test.runId }),
|
|
6282
|
+
"."
|
|
6283
|
+
] }),
|
|
6284
|
+
test?.mode === "run" && /* @__PURE__ */ jsxs("p", { className: "text-sm", children: [
|
|
6285
|
+
"Traitement d\xE9clench\xE9. Run \xE0 suivre : ",
|
|
6286
|
+
/* @__PURE__ */ jsx("code", { children: test.runId }),
|
|
6287
|
+
"."
|
|
6288
|
+
] }),
|
|
6289
|
+
test !== null && test.mode !== "diagnostic" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6290
|
+
isPolling && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
|
|
6291
|
+
/* @__PURE__ */ jsx(Spinner, {}),
|
|
6292
|
+
" Ex\xE9cution en cours\u2026"
|
|
6293
|
+
] }),
|
|
6294
|
+
run?.status === "failed" && /* @__PURE__ */ jsxs("p", { className: "text-sm text-destructive", children: [
|
|
6295
|
+
"L'ex\xE9cution a \xE9chou\xE9 : ",
|
|
6296
|
+
run.error?.message ?? "erreur inconnue."
|
|
6297
|
+
] }),
|
|
6298
|
+
runResult && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
6299
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: describeRunDecision(runResult, test.mode) }),
|
|
6300
|
+
runResult.stoppedAt !== null && runResult.reason !== null && !runResult.gates.some((gate) => gate.status === "stopped") && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: runResult.reason }),
|
|
6301
|
+
/* @__PURE__ */ jsx(GatesTable, { gates: runResult.gates }),
|
|
6302
|
+
draftText !== null && /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
6303
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs font-medium", children: "Brouillon g\xE9n\xE9r\xE9" }),
|
|
6304
|
+
/* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap rounded border bg-muted/30 p-2 text-xs", children: draftText })
|
|
6305
|
+
] }),
|
|
6306
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs", children: /* @__PURE__ */ jsx(Link, { href: `/espace/${appSlug}/tickets?ticket=${encodeURIComponent(runResult.ticketId ?? test.ticketId)}`, children: "Ouvrir la fiche du ticket" }) })
|
|
6307
|
+
] })
|
|
6308
|
+
] }),
|
|
6309
|
+
test?.mode === "diagnostic" && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
6310
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: test.stoppedAt === null ? `Ticket ${test.ticketId} : il aurait re\xE7u une r\xE9ponse de suite.` : `Ticket ${test.ticketId} : arr\xEAt en ${test.stoppedAt}.` }),
|
|
6311
|
+
/* @__PURE__ */ jsx(GatesTable, { gates: test.gates })
|
|
6312
|
+
] })
|
|
6313
|
+
] })
|
|
6314
|
+
] }),
|
|
6315
|
+
confirmingRealRun && /* @__PURE__ */ jsx(
|
|
6316
|
+
ConfirmModal,
|
|
6317
|
+
{
|
|
6318
|
+
title: "Lancer le traitement r\xE9el ?",
|
|
6319
|
+
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6320
|
+
"Le ticket ",
|
|
6321
|
+
ticket.trim(),
|
|
6322
|
+
" va \xEAtre trait\xE9 comme un vrai message suivant : g\xE9n\xE9ration, garde-fous, et",
|
|
6323
|
+
" ",
|
|
6324
|
+
/* @__PURE__ */ jsx("strong", { children: "envoi r\xE9el au client" }),
|
|
6325
|
+
" si sa cat\xE9gorie est en r\xE9ponse automatique. Pour tout voir sans rien envoyer, utilisez \xAB G\xE9n\xE9rer sans envoyer \xBB."
|
|
6326
|
+
] }),
|
|
6327
|
+
confirmLabel: "Lancer",
|
|
6328
|
+
busyLabel: "D\xE9clenchement\u2026",
|
|
6329
|
+
onConfirm: () => runTest("run"),
|
|
6330
|
+
onCancel: () => setConfirmingRealRun(false)
|
|
6331
|
+
}
|
|
6332
|
+
)
|
|
6333
|
+
] });
|
|
6334
|
+
}
|
|
6211
6335
|
var TRI_STATE_OPTIONS = [
|
|
6212
6336
|
{ value: "", label: "R\xE9glages actuels" },
|
|
6213
6337
|
{ value: "on", label: "Forcer actif" },
|
|
@@ -6395,9 +6519,11 @@ function TestControls() {
|
|
|
6395
6519
|
function TestPage() {
|
|
6396
6520
|
const { role } = useAppContext();
|
|
6397
6521
|
const canRun = canWriteForRole(role);
|
|
6522
|
+
const canTestFollowup = role === "ADMIN";
|
|
6398
6523
|
return /* @__PURE__ */ jsxs(PageShell, { children: [
|
|
6399
6524
|
/* @__PURE__ */ jsx(PageHeader, { title: "Banc de test", description: "Rejoue le graphe sans jamais agir sur un vrai ticket (\xA70)." }),
|
|
6400
|
-
!canRun ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Acc\xE8s en lecture seule \u2014 lancer un test n\xE9cessite le r\xF4le EDITOR (chaque ex\xE9cution consomme du budget LLM)." }) : /* @__PURE__ */ jsx(TestControls, {})
|
|
6525
|
+
!canRun ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Acc\xE8s en lecture seule \u2014 lancer un test n\xE9cessite le r\xF4le EDITOR (chaque ex\xE9cution consomme du budget LLM)." }) : /* @__PURE__ */ jsx(TestControls, {}),
|
|
6526
|
+
canTestFollowup && /* @__PURE__ */ jsx(FollowupWebhookCard2, {})
|
|
6401
6527
|
] });
|
|
6402
6528
|
}
|
|
6403
6529
|
function ExperimentStatusBadge({ experiment }) {
|