@apotech-os/support-kit 8.0.0 → 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/dist/{chunk-2UHFKGMI.js → chunk-LXHPPWPM.js} +20 -6
- package/dist/chunk-LXHPPWPM.js.map +1 -0
- package/dist/index.cjs +86 -33
- 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 +71 -32
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +144 -46
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +131 -46
- package/dist/ui/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2UHFKGMI.js.map +0 -1
package/dist/ui/index.cjs
CHANGED
|
@@ -340,6 +340,7 @@ var EMPTY_TOTALS = {
|
|
|
340
340
|
failed: 0
|
|
341
341
|
};
|
|
342
342
|
function outcomeOf(status, autoSendDecision) {
|
|
343
|
+
if (status === "test_draft") return null;
|
|
343
344
|
if (status === "sent") return "auto";
|
|
344
345
|
if (status === "no_reply_needed") return "noReplyNeeded";
|
|
345
346
|
if (status === "failed") return "failed";
|
|
@@ -349,7 +350,8 @@ function outcomeOf(status, autoSendDecision) {
|
|
|
349
350
|
function foldOutcomes(rows) {
|
|
350
351
|
const totals = { ...EMPTY_TOTALS };
|
|
351
352
|
for (const row of rows) {
|
|
352
|
-
|
|
353
|
+
const outcome = outcomeOf(row["status"], row["autoSendDecision"]);
|
|
354
|
+
if (outcome !== null) totals[outcome] += Number(row["count"]) || 0;
|
|
353
355
|
}
|
|
354
356
|
return totals;
|
|
355
357
|
}
|
|
@@ -363,9 +365,11 @@ function autonomyRate(totals) {
|
|
|
363
365
|
function foldDailyOutcomes(rows) {
|
|
364
366
|
const byDay = /* @__PURE__ */ new Map();
|
|
365
367
|
for (const row of rows) {
|
|
368
|
+
const outcome = outcomeOf(row["status"], row["autoSendDecision"]);
|
|
369
|
+
if (outcome === null) continue;
|
|
366
370
|
const day = bucketDay(row);
|
|
367
371
|
const totals = byDay.get(day) ?? { ...EMPTY_TOTALS };
|
|
368
|
-
totals[
|
|
372
|
+
totals[outcome] += Number(row["count"]) || 0;
|
|
369
373
|
byDay.set(day, totals);
|
|
370
374
|
}
|
|
371
375
|
return [...byDay.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([day, totals]) => ({
|
|
@@ -1118,6 +1122,31 @@ function TicketLink({ ticketId, url, label }) {
|
|
|
1118
1122
|
}
|
|
1119
1123
|
);
|
|
1120
1124
|
}
|
|
1125
|
+
function readParam(name) {
|
|
1126
|
+
if (typeof window === "undefined") return null;
|
|
1127
|
+
return new URLSearchParams(window.location.search).get(name);
|
|
1128
|
+
}
|
|
1129
|
+
function useQueryParam(name) {
|
|
1130
|
+
const [value, setState] = react.useState(() => readParam(name));
|
|
1131
|
+
react.useEffect(() => {
|
|
1132
|
+
const sync = () => setState(readParam(name));
|
|
1133
|
+
sync();
|
|
1134
|
+
window.addEventListener("popstate", sync);
|
|
1135
|
+
return () => window.removeEventListener("popstate", sync);
|
|
1136
|
+
}, [name]);
|
|
1137
|
+
const setValue = react.useCallback(
|
|
1138
|
+
(next) => {
|
|
1139
|
+
const params = new URLSearchParams(window.location.search);
|
|
1140
|
+
if (next === null) params.delete(name);
|
|
1141
|
+
else params.set(name, next);
|
|
1142
|
+
const query = params.toString();
|
|
1143
|
+
window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
|
|
1144
|
+
setState(next);
|
|
1145
|
+
},
|
|
1146
|
+
[name]
|
|
1147
|
+
);
|
|
1148
|
+
return { value, setValue };
|
|
1149
|
+
}
|
|
1121
1150
|
var UNCONFIGURED = { baseUrl: null, projectId: null };
|
|
1122
1151
|
function useLangfuseConfig() {
|
|
1123
1152
|
const { appSlug } = uiSdk.useAppContext();
|
|
@@ -1195,7 +1224,8 @@ var GENERATED_RESPONSE_STATUS_LABELS = {
|
|
|
1195
1224
|
failed: "\xC9chec",
|
|
1196
1225
|
no_reply_needed: "Aucune r\xE9ponse n\xE9cessaire",
|
|
1197
1226
|
invalidated: "Invalid\xE9e",
|
|
1198
|
-
expired: "Expir\xE9e"
|
|
1227
|
+
expired: "Expir\xE9e",
|
|
1228
|
+
test_draft: "Brouillon d'essai \u2014 jamais envoy\xE9"
|
|
1199
1229
|
};
|
|
1200
1230
|
var AUTO_SEND_DECISION_LABELS = {
|
|
1201
1231
|
auto: "Autoris\xE9",
|
|
@@ -1259,20 +1289,33 @@ var GENERATED_RESPONSE_STATUSES = [
|
|
|
1259
1289
|
"failed",
|
|
1260
1290
|
"no_reply_needed",
|
|
1261
1291
|
"invalidated",
|
|
1262
|
-
"expired"
|
|
1292
|
+
"expired",
|
|
1293
|
+
// 24/09/2026 — where "générer sans envoyer" rests its draft. It used to
|
|
1294
|
+
// finalize as `invalidated`, which the ticket page and the dashboard both
|
|
1295
|
+
// read as "an agent had already answered": the test artefact was stored,
|
|
1296
|
+
// but disguised as a human intervention. Terminal on purpose — nothing may
|
|
1297
|
+
// serve, send or revive a test draft — and terminal is also what frees the
|
|
1298
|
+
// `openTicketKey` (see `openTicketKeyFor`), so an essay can never hold the
|
|
1299
|
+
// real webhook at G9.
|
|
1300
|
+
"test_draft"
|
|
1263
1301
|
];
|
|
1264
1302
|
function isGeneratedResponseStatus(value) {
|
|
1265
1303
|
return typeof value === "string" && GENERATED_RESPONSE_STATUSES.includes(value);
|
|
1266
1304
|
}
|
|
1267
1305
|
var ALLOWED_TRANSITIONS = {
|
|
1268
|
-
pending:
|
|
1306
|
+
// `pending -> test_draft` is the ONLY way in: the test pass finalizes the
|
|
1307
|
+
// very `pending` row it opened, and no other status can become a test
|
|
1308
|
+
// draft after the fact — an operator invalidating a real `ready` draft is
|
|
1309
|
+
// expressing "discard this", not "this was an essay".
|
|
1310
|
+
pending: ["ready", "failed", "no_reply_needed", "sending", "invalidated", "test_draft"],
|
|
1269
1311
|
ready: ["sending", "invalidated", "expired"],
|
|
1270
1312
|
sending: ["sent", "ready"],
|
|
1271
1313
|
sent: [],
|
|
1272
1314
|
failed: [],
|
|
1273
1315
|
no_reply_needed: [],
|
|
1274
1316
|
invalidated: [],
|
|
1275
|
-
expired: []
|
|
1317
|
+
expired: [],
|
|
1318
|
+
test_draft: []
|
|
1276
1319
|
};
|
|
1277
1320
|
function canTransition(from, to) {
|
|
1278
1321
|
if (!isGeneratedResponseStatus(from) || !isGeneratedResponseStatus(to)) return false;
|
|
@@ -1708,6 +1751,8 @@ function deliveryReason(input) {
|
|
|
1708
1751
|
}
|
|
1709
1752
|
case "failed":
|
|
1710
1753
|
return job.error ?? "La r\xE9ponse a \xE9chou\xE9 avant son envoi.";
|
|
1754
|
+
case "test_draft":
|
|
1755
|
+
return "Brouillon d'essai \u2014 jamais envoy\xE9.";
|
|
1711
1756
|
default:
|
|
1712
1757
|
return `La r\xE9ponse n'a pas \xE9t\xE9 envoy\xE9e (statut : ${job.status}).`;
|
|
1713
1758
|
}
|
|
@@ -2245,6 +2290,15 @@ function TicketsPage() {
|
|
|
2245
2290
|
return true;
|
|
2246
2291
|
});
|
|
2247
2292
|
}, [decisions, jobByDecisionId, comparisonsByTicketId, outcomeFilter, verdictFilter, promptVersionFilter, correctedFilter]);
|
|
2293
|
+
const requestedTicket = useQueryParam("ticket").value;
|
|
2294
|
+
const deepLinkConsumed = react.useRef(false);
|
|
2295
|
+
react.useEffect(() => {
|
|
2296
|
+
if (deepLinkConsumed.current || !requestedTicket) return;
|
|
2297
|
+
const match = rows.find((row) => row.decision.ticketId === requestedTicket);
|
|
2298
|
+
if (!match) return;
|
|
2299
|
+
deepLinkConsumed.current = true;
|
|
2300
|
+
setDetailDecision(match.decision);
|
|
2301
|
+
}, [requestedTicket, rows]);
|
|
2248
2302
|
const categoryOptions = react.useMemo(
|
|
2249
2303
|
() => [{ value: "", label: "Toutes cat\xE9gories" }, ...categories.map((category) => ({ value: category.id, label: category.name }))],
|
|
2250
2304
|
[categories]
|
|
@@ -5105,31 +5159,6 @@ function SettingsPage() {
|
|
|
5105
5159
|
);
|
|
5106
5160
|
}
|
|
5107
5161
|
var ReglagesPage = SettingsPage;
|
|
5108
|
-
function readParam(name) {
|
|
5109
|
-
if (typeof window === "undefined") return null;
|
|
5110
|
-
return new URLSearchParams(window.location.search).get(name);
|
|
5111
|
-
}
|
|
5112
|
-
function useQueryParam(name) {
|
|
5113
|
-
const [value, setState] = react.useState(() => readParam(name));
|
|
5114
|
-
react.useEffect(() => {
|
|
5115
|
-
const sync = () => setState(readParam(name));
|
|
5116
|
-
sync();
|
|
5117
|
-
window.addEventListener("popstate", sync);
|
|
5118
|
-
return () => window.removeEventListener("popstate", sync);
|
|
5119
|
-
}, [name]);
|
|
5120
|
-
const setValue = react.useCallback(
|
|
5121
|
-
(next) => {
|
|
5122
|
-
const params = new URLSearchParams(window.location.search);
|
|
5123
|
-
if (next === null) params.delete(name);
|
|
5124
|
-
else params.set(name, next);
|
|
5125
|
-
const query = params.toString();
|
|
5126
|
-
window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
|
|
5127
|
-
setState(next);
|
|
5128
|
-
},
|
|
5129
|
-
[name]
|
|
5130
|
-
);
|
|
5131
|
-
return { value, setValue };
|
|
5132
|
-
}
|
|
5133
5162
|
|
|
5134
5163
|
// src/ui/graph-canvas/reachability.ts
|
|
5135
5164
|
var EXIT_TONES = {
|
|
@@ -6706,20 +6735,80 @@ function DryRunResultView({ result, langfuseConfig, knownTags, tagSettings }) {
|
|
|
6706
6735
|
var STATUS_BADGE = {
|
|
6707
6736
|
passed: { label: "OK", variant: "success" },
|
|
6708
6737
|
stopped: { label: "Arr\xEAt", variant: "danger" },
|
|
6709
|
-
// A pre-gate that could not read its field.
|
|
6710
|
-
// (it evaluates no payload) but
|
|
6711
|
-
// than falling through to a blank badge.
|
|
6738
|
+
// A pre-gate that could not read its field. The diagnostic never produces
|
|
6739
|
+
// one (it evaluates no payload), but a run stopped on a pre-gate does —
|
|
6740
|
+
// rendered honestly rather than falling through to a blank badge.
|
|
6712
6741
|
muted: { label: "Muet", variant: "warning" },
|
|
6713
6742
|
skipped: { label: "Non \xE9valu\xE9", variant: "neutral" }
|
|
6714
6743
|
};
|
|
6744
|
+
function GatesTable({ gates }) {
|
|
6745
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-1", children: gates.map((gate) => {
|
|
6746
|
+
const badge = STATUS_BADGE[gate.status] ?? STATUS_BADGE.skipped;
|
|
6747
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex items-start gap-2 text-xs", children: [
|
|
6748
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: badge.variant, children: badge.label }),
|
|
6749
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
6750
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium", children: [
|
|
6751
|
+
gate.gate,
|
|
6752
|
+
" \u2014 ",
|
|
6753
|
+
gate.label
|
|
6754
|
+
] }),
|
|
6755
|
+
/* @__PURE__ */ jsxRuntime.jsx("br", {}),
|
|
6756
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: gate.detail })
|
|
6757
|
+
] })
|
|
6758
|
+
] }, gate.gate);
|
|
6759
|
+
}) });
|
|
6760
|
+
}
|
|
6761
|
+
function parseRunResult(result) {
|
|
6762
|
+
if (typeof result !== "object" || result === null) return null;
|
|
6763
|
+
const raw = result;
|
|
6764
|
+
if (!Array.isArray(raw.gates)) return null;
|
|
6765
|
+
return {
|
|
6766
|
+
ticketId: typeof raw.ticketId === "string" ? raw.ticketId : null,
|
|
6767
|
+
stoppedAt: typeof raw.stoppedAt === "string" ? raw.stoppedAt : null,
|
|
6768
|
+
reason: typeof raw.reason === "string" ? raw.reason : null,
|
|
6769
|
+
gates: raw.gates,
|
|
6770
|
+
categoryName: typeof raw.categoryName === "string" ? raw.categoryName : null,
|
|
6771
|
+
outcome: typeof raw.outcome === "string" ? raw.outcome : null,
|
|
6772
|
+
responseId: typeof raw.responseId === "string" ? raw.responseId : null
|
|
6773
|
+
};
|
|
6774
|
+
}
|
|
6775
|
+
function describeRunDecision(result, mode) {
|
|
6776
|
+
if (result.stoppedAt !== null) return `Arr\xEAt en ${result.stoppedAt}.`;
|
|
6777
|
+
const category = result.categoryName ? ` (cat\xE9gorie \xAB ${result.categoryName} \xBB)` : "";
|
|
6778
|
+
if (result.outcome === "sent") {
|
|
6779
|
+
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}.`;
|
|
6780
|
+
}
|
|
6781
|
+
const label = result.outcome !== null && result.outcome in OUTCOME_LABELS ? OUTCOME_LABELS[result.outcome] : null;
|
|
6782
|
+
return label ? `${label}${category}.` : `Traitement termin\xE9${category}.`;
|
|
6783
|
+
}
|
|
6715
6784
|
function FollowupWebhookCard2() {
|
|
6716
6785
|
const api = uiSdk.useAppApi();
|
|
6786
|
+
const { appSlug } = uiSdk.useAppContext();
|
|
6717
6787
|
const toast = uiSdk.useToast();
|
|
6718
6788
|
const ticketId = react.useId();
|
|
6719
6789
|
const [ticket, setTicket] = react.useState("");
|
|
6720
6790
|
const [test, setTest] = react.useState(null);
|
|
6721
6791
|
const [isTesting, setIsTesting] = react.useState(false);
|
|
6722
6792
|
const [confirmingRealRun, setConfirmingRealRun] = react.useState(false);
|
|
6793
|
+
const followedRunId = test !== null && test.mode !== "diagnostic" ? test.runId : null;
|
|
6794
|
+
const { run, isPolling } = uiSdk.useAppRun(followedRunId);
|
|
6795
|
+
const runResult = run && run.status === "succeeded" ? parseRunResult(run.result) : null;
|
|
6796
|
+
const [draftText, setDraftText] = react.useState(null);
|
|
6797
|
+
react.useEffect(() => {
|
|
6798
|
+
setDraftText(null);
|
|
6799
|
+
const responseId = runResult?.responseId;
|
|
6800
|
+
if (!responseId) return;
|
|
6801
|
+
let cancelled = false;
|
|
6802
|
+
void api.get(
|
|
6803
|
+
`/data/apps/${appSlug}/records/generated-response/${encodeURIComponent(responseId)}`
|
|
6804
|
+
).then((record) => {
|
|
6805
|
+
if (!cancelled) setDraftText(record?.data?.responseText ?? null);
|
|
6806
|
+
}).catch(() => {
|
|
6807
|
+
});
|
|
6808
|
+
return () => {
|
|
6809
|
+
cancelled = true;
|
|
6810
|
+
};
|
|
6811
|
+
}, [runResult?.responseId, appSlug]);
|
|
6723
6812
|
async function runTest(mode) {
|
|
6724
6813
|
setIsTesting(true);
|
|
6725
6814
|
setTest(null);
|
|
@@ -6776,20 +6865,29 @@ function FollowupWebhookCard2() {
|
|
|
6776
6865
|
/* @__PURE__ */ jsxRuntime.jsx("code", { children: test.runId }),
|
|
6777
6866
|
"."
|
|
6778
6867
|
] }),
|
|
6868
|
+
test !== null && test.mode !== "diagnostic" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6869
|
+
isPolling && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
|
|
6870
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Spinner, {}),
|
|
6871
|
+
" Ex\xE9cution en cours\u2026"
|
|
6872
|
+
] }),
|
|
6873
|
+
run?.status === "failed" && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-destructive", children: [
|
|
6874
|
+
"L'ex\xE9cution a \xE9chou\xE9 : ",
|
|
6875
|
+
run.error?.message ?? "erreur inconnue."
|
|
6876
|
+
] }),
|
|
6877
|
+
runResult && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
6878
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: describeRunDecision(runResult, test.mode) }),
|
|
6879
|
+
runResult.stoppedAt !== null && runResult.reason !== null && !runResult.gates.some((gate) => gate.status === "stopped") && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: runResult.reason }),
|
|
6880
|
+
/* @__PURE__ */ jsxRuntime.jsx(GatesTable, { gates: runResult.gates }),
|
|
6881
|
+
draftText !== null && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
6882
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium", children: "Brouillon g\xE9n\xE9r\xE9" }),
|
|
6883
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "whitespace-pre-wrap rounded border bg-muted/30 p-2 text-xs", children: draftText })
|
|
6884
|
+
] }),
|
|
6885
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: `/espace/${appSlug}/tickets?ticket=${encodeURIComponent(runResult.ticketId ?? test.ticketId)}`, children: "Ouvrir la fiche du ticket" }) })
|
|
6886
|
+
] })
|
|
6887
|
+
] }),
|
|
6779
6888
|
test?.mode === "diagnostic" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
6780
6889
|
/* @__PURE__ */ jsxRuntime.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}.` }),
|
|
6781
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6782
|
-
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: STATUS_BADGE[gate.status].variant, children: STATUS_BADGE[gate.status].label }),
|
|
6783
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
6784
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium", children: [
|
|
6785
|
-
gate.gate,
|
|
6786
|
-
" \u2014 ",
|
|
6787
|
-
gate.label
|
|
6788
|
-
] }),
|
|
6789
|
-
/* @__PURE__ */ jsxRuntime.jsx("br", {}),
|
|
6790
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: gate.detail })
|
|
6791
|
-
] })
|
|
6792
|
-
] }, gate.gate)) })
|
|
6890
|
+
/* @__PURE__ */ jsxRuntime.jsx(GatesTable, { gates: test.gates })
|
|
6793
6891
|
] })
|
|
6794
6892
|
] })
|
|
6795
6893
|
] }),
|