@apotech-os/support-kit 2.6.0 → 2.7.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
@@ -219,6 +219,22 @@ function useRecordList(objectKey, query, mapper) {
219
219
  goToPreviousPage
220
220
  };
221
221
  }
222
+ function PageShell({ className, children }) {
223
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: uiSdk.cn("space-y-6 px-8 py-6", className), children });
224
+ }
225
+ function PageHeader({
226
+ title,
227
+ description,
228
+ actions
229
+ }) {
230
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-start justify-between gap-4", children: [
231
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
232
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-2xl font-semibold", children: title }),
233
+ description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 max-w-3xl text-sm text-muted-foreground", children: description })
234
+ ] }),
235
+ actions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap items-center gap-2", children: actions })
236
+ ] });
237
+ }
222
238
  function useAggregate(objectKey, spec) {
223
239
  const { appSlug } = uiSdk.useAppContext();
224
240
  const api = uiSdk.useAppApi();
@@ -396,23 +412,24 @@ function DashboardPage() {
396
412
  },
397
413
  { key: "decidedAt", header: "Date", cell: (row) => formatDate(row.decidedAt) }
398
414
  ];
399
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
400
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-4", children: [
401
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
402
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", children: "Tableau de bord" }),
403
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Les chiffres cl\xE9s et les graphiques couvrent la fen\xEAtre choisie ; la sant\xE9 annonce la sienne." })
404
- ] }),
405
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
406
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
407
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: "Fen\xEAtre :" }),
408
- WINDOW_OPTIONS.map((days) => /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Button, { size: "sm", variant: windowDays === days ? "default" : "outline", onClick: () => setWindowDays(days), children: [
409
- days,
410
- " j"
411
- ] }, days))
412
- ] }),
413
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: `/espace/${appSlug}/pipeline`, children: "Voir le pipeline complet" })
414
- ] })
415
- ] }),
415
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
416
+ /* @__PURE__ */ jsxRuntime.jsx(
417
+ PageHeader,
418
+ {
419
+ title: "Tableau de bord",
420
+ description: "Les chiffres cl\xE9s et les graphiques couvrent la fen\xEAtre choisie ; la sant\xE9 annonce la sienne.",
421
+ actions: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
422
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
423
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: "Fen\xEAtre :" }),
424
+ WINDOW_OPTIONS.map((days) => /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Button, { size: "sm", variant: windowDays === days ? "default" : "outline", onClick: () => setWindowDays(days), children: [
425
+ days,
426
+ " j"
427
+ ] }, days))
428
+ ] }),
429
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: `/espace/${appSlug}/pipeline`, children: "Voir le pipeline complet" })
430
+ ] }) })
431
+ }
432
+ ),
416
433
  alarming && healthBand,
417
434
  /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-testid": "dashboard-kpis", className: "grid grid-cols-1 gap-4 sm:grid-cols-3", children: [
418
435
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
@@ -879,14 +896,15 @@ function TicketsPage() {
879
896
  ];
880
897
  const isLoading = decisionsLoading || jobsLoading;
881
898
  const combinedError = decisionsError ?? jobsError;
882
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
883
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
884
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
885
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", children: "Demandes" }),
886
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Les tickets trait\xE9s par le graphe, et le parcours de chacun." })
887
- ] }),
888
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: () => void refreshBoth(), children: "Actualiser" })
889
- ] }),
899
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
900
+ /* @__PURE__ */ jsxRuntime.jsx(
901
+ PageHeader,
902
+ {
903
+ title: "Demandes",
904
+ description: "Les tickets trait\xE9s par le graphe, et le parcours de chacun.",
905
+ actions: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: () => void refreshBoth(), children: "Actualiser" }) })
906
+ }
907
+ ),
890
908
  joinWindowMayBeIncomplete && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
891
909
  "La jointure ne lit que les ",
892
910
  JOBS_WINDOW_SIZE,
@@ -1401,20 +1419,21 @@ function PipelinePage() {
1401
1419
  ] })
1402
1420
  }
1403
1421
  ];
1404
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
1405
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
1406
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1407
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", children: "Pipeline" }),
1408
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Cycle de vie des r\xE9ponses g\xE9n\xE9r\xE9es automatiquement." })
1409
- ] }),
1410
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
1411
- settings && /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Badge, { variant: settings.autoSendEnabled ? "success" : "neutral", children: [
1412
- "Envoi auto : ",
1413
- settings.autoSendEnabled ? "ACTIF" : "INACTIF"
1414
- ] }),
1415
- canWrite && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => void runTriageNow(), disabled: isTriaging, children: isTriaging ? "Triage en cours\u2026" : "Lancer le triage maintenant" })
1416
- ] })
1417
- ] }),
1422
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
1423
+ /* @__PURE__ */ jsxRuntime.jsx(
1424
+ PageHeader,
1425
+ {
1426
+ title: "Pipeline",
1427
+ description: "Cycle de vie des r\xE9ponses g\xE9n\xE9r\xE9es automatiquement.",
1428
+ actions: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
1429
+ settings && /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Badge, { variant: settings.autoSendEnabled ? "success" : "neutral", children: [
1430
+ "Envoi auto : ",
1431
+ settings.autoSendEnabled ? "ACTIF" : "INACTIF"
1432
+ ] }),
1433
+ canWrite && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => void runTriageNow(), disabled: isTriaging, children: isTriaging ? "Triage en cours\u2026" : "Lancer le triage maintenant" })
1434
+ ] }) })
1435
+ }
1436
+ ),
1418
1437
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1419
1438
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: "Fen\xEAtre :" }),
1420
1439
  WINDOW_OPTIONS2.map((days) => /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Button, { size: "sm", variant: windowDays === days ? "default" : "outline", onClick: () => setWindowDays(days), children: [
@@ -2094,14 +2113,15 @@ function AgentsPage() {
2094
2113
  ] })
2095
2114
  }
2096
2115
  ];
2097
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
2098
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
2099
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2100
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", children: "Agents" }),
2101
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Agents de r\xE9daction et leurs prompts." })
2102
- ] }),
2103
- canWrite && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => setFormAgent("new"), children: "Nouvel agent" })
2104
- ] }),
2116
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
2117
+ /* @__PURE__ */ jsxRuntime.jsx(
2118
+ PageHeader,
2119
+ {
2120
+ title: "Agents",
2121
+ description: "Agents de r\xE9daction et leurs prompts.",
2122
+ actions: canWrite && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => setFormAgent("new"), children: "Nouvel agent" })
2123
+ }
2124
+ ),
2105
2125
  /* @__PURE__ */ jsxRuntime.jsx(
2106
2126
  uiSdk.DataTable,
2107
2127
  {
@@ -2455,14 +2475,15 @@ function CategoriesPage() {
2455
2475
  const isLoading = groupsLoading || categoriesLoading;
2456
2476
  const loadError = groupsError ?? categoriesError;
2457
2477
  const ungrouped = byGroup.get(UNGROUPED_KEY) ?? [];
2458
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
2459
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
2460
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2461
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", children: "Cat\xE9gories" }),
2462
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "R\xE9f\xE9rentiel de cat\xE9gorisation des tickets." })
2463
- ] }),
2464
- canWrite && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => setNewGroup(true), children: "Nouveau groupe" })
2465
- ] }),
2478
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
2479
+ /* @__PURE__ */ jsxRuntime.jsx(
2480
+ PageHeader,
2481
+ {
2482
+ title: "Cat\xE9gories",
2483
+ description: "R\xE9f\xE9rentiel de cat\xE9gorisation des tickets.",
2484
+ actions: canWrite && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => setNewGroup(true), children: "Nouveau groupe" })
2485
+ }
2486
+ ),
2466
2487
  loadError ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3 py-12", children: [
2467
2488
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du chargement des cat\xE9gories." }),
2468
2489
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: () => void Promise.all([refreshGroups(), refreshCategories()]), children: "R\xE9essayer" })
@@ -2664,14 +2685,15 @@ function EscalationsPage() {
2664
2685
  },
2665
2686
  { key: "decidedAt", header: "D\xE9cid\xE9 le", cell: (row) => formatDate(row.decidedAt) }
2666
2687
  ];
2667
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
2668
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
2669
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2670
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", children: "Escalades" }),
2671
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "D\xE9cisions d\u2019escalade humaine \xE9valu\xE9es lors des runs de triage." })
2672
- ] }),
2673
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: () => void refresh(), children: "Actualiser" })
2674
- ] }),
2688
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
2689
+ /* @__PURE__ */ jsxRuntime.jsx(
2690
+ PageHeader,
2691
+ {
2692
+ title: "Escalades",
2693
+ description: "D\xE9cisions d\u2019escalade humaine \xE9valu\xE9es lors des runs de triage.",
2694
+ actions: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: () => void refresh(), children: "Actualiser" }) })
2695
+ }
2696
+ ),
2675
2697
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
2676
2698
  /* @__PURE__ */ jsxRuntime.jsx(
2677
2699
  uiSdk.Select,
@@ -2997,14 +3019,15 @@ function CorrectionsPage() {
2997
3019
  }
2998
3020
  ] : []
2999
3021
  ];
3000
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
3001
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
3002
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3003
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", children: "Corrections" }),
3004
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Ce que l'IA a propos\xE9, compar\xE9 \xE0 ce que l'agent a r\xE9ellement envoy\xE9." })
3005
- ] }),
3006
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: () => void refresh(), children: "Actualiser" })
3007
- ] }),
3022
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
3023
+ /* @__PURE__ */ jsxRuntime.jsx(
3024
+ PageHeader,
3025
+ {
3026
+ title: "Corrections",
3027
+ description: "Ce que l'IA a propos\xE9, compar\xE9 \xE0 ce que l'agent a r\xE9ellement envoy\xE9.",
3028
+ actions: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: () => void refresh(), children: "Actualiser" }) })
3029
+ }
3030
+ ),
3008
3031
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
3009
3032
  /* @__PURE__ */ jsxRuntime.jsx(
3010
3033
  uiSdk.Select,
@@ -3364,35 +3387,462 @@ function toEvaluateNode(node) {
3364
3387
  escalationEnabled: node.escalationEnabled ?? DEFAULT_ESCALATION_ENABLED
3365
3388
  };
3366
3389
  }
3367
- var WHATSAPP_MODE_LABELS = {
3368
- escalate_only: "Escalade uniquement",
3369
- draft_only: "Brouillon uniquement",
3370
- auto_reply: "R\xE9ponse automatique"
3371
- };
3372
- var WHATSAPP_MODE_OPTIONS = WHATSAPP_MODES.map((value) => ({ value, label: WHATSAPP_MODE_LABELS[value] }));
3373
- function field(value) {
3390
+ function NumberField({ id, label, value, onChange, disabled, min, max, integer, hint }) {
3391
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3392
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: "mb-1 block text-sm font-medium", children: label }),
3393
+ /* @__PURE__ */ jsxRuntime.jsx(
3394
+ uiSdk.Input,
3395
+ {
3396
+ id,
3397
+ type: "number",
3398
+ min,
3399
+ max,
3400
+ value,
3401
+ disabled,
3402
+ step: integer ? 1 : void 0,
3403
+ onChange: (e) => {
3404
+ const parsed = Number(e.target.value);
3405
+ if (e.target.value.trim() === "" || !Number.isFinite(parsed)) return;
3406
+ const rounded = integer ? Math.round(parsed) : parsed;
3407
+ const bounded = Math.min(max ?? Infinity, Math.max(min ?? -Infinity, rounded));
3408
+ onChange(bounded);
3409
+ }
3410
+ }
3411
+ ),
3412
+ hint && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: hint })
3413
+ ] });
3414
+ }
3415
+
3416
+ // src/ui/settings/pipeline-nodes.ts
3417
+ var PIPELINE_STEP_KEYS = ["triage", "escalate", "draft", "evaluate", "revise"];
3418
+ var PIPELINE_STEPS = [
3419
+ {
3420
+ key: "triage",
3421
+ label: "Triage",
3422
+ description: "comprend et classe chaque demande entrante",
3423
+ requires: null,
3424
+ blockedReason: null
3425
+ },
3426
+ {
3427
+ key: "escalate",
3428
+ label: "Escalade",
3429
+ description: "passe la main \xE0 un humain",
3430
+ requires: null,
3431
+ blockedReason: null
3432
+ },
3433
+ {
3434
+ key: "draft",
3435
+ label: "R\xE9daction",
3436
+ description: "pr\xE9pare un projet de r\xE9ponse",
3437
+ requires: null,
3438
+ blockedReason: null
3439
+ },
3440
+ {
3441
+ key: "evaluate",
3442
+ label: "\xC9valuation",
3443
+ description: "relit la r\xE9ponse avant envoi",
3444
+ requires: "draft",
3445
+ blockedReason: "Il n'y a rien \xE0 \xE9valuer sans r\xE9daction."
3446
+ },
3447
+ {
3448
+ key: "revise",
3449
+ label: "R\xE9vision",
3450
+ description: "r\xE9\xE9crit la r\xE9ponse si l'\xE9valuation la juge insuffisante",
3451
+ requires: "evaluate",
3452
+ blockedReason: "Sans \xE9valuation, rien ne d\xE9clenche une r\xE9vision."
3453
+ }
3454
+ ];
3455
+ var TRIAGE_LOCK_REASON = "Sans triage l'app ne traite rien.";
3456
+ var STEP_BY_KEY = new Map(PIPELINE_STEPS.map((step) => [step.key, step]));
3457
+ function pipelineStep(key) {
3458
+ const step = STEP_BY_KEY.get(key);
3459
+ if (!step) throw new Error(`unknown pipeline step: ${key}`);
3460
+ return step;
3461
+ }
3462
+ function readNodes(value) {
3463
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return {};
3464
+ return value;
3465
+ }
3466
+ function readStep(value, key) {
3467
+ const step = readNodes(value)[key];
3468
+ if (typeof step !== "object" || step === null || Array.isArray(step)) return null;
3469
+ return step;
3470
+ }
3471
+ function isStepEnabled(value, key) {
3472
+ return readStep(value, key) !== null;
3473
+ }
3474
+ function stepBlockedReason(value, key) {
3475
+ const { requires, blockedReason } = pipelineStep(key);
3476
+ if (!requires) return null;
3477
+ return isStepActive(value, requires) ? null : blockedReason;
3478
+ }
3479
+ function isStepActive(value, key) {
3480
+ return isStepEnabled(value, key) && stepBlockedReason(value, key) === null;
3481
+ }
3482
+ function withStep(value, key, step) {
3483
+ return { ...readNodes(value), [key]: step };
3484
+ }
3485
+ function withStepFields(value, key, patch) {
3486
+ const step = readStep(value, key);
3487
+ if (!step) return readNodes(value);
3488
+ const next = { ...step };
3489
+ for (const [field2, fieldValue] of Object.entries(patch)) {
3490
+ if (fieldValue === void 0) delete next[field2];
3491
+ else next[field2] = fieldValue;
3492
+ }
3493
+ return withStep(value, key, next);
3494
+ }
3495
+ function stepString(step, field2) {
3496
+ const value = step?.[field2];
3374
3497
  return typeof value === "string" ? value : "";
3375
3498
  }
3376
- function bool(value) {
3377
- return value === true;
3499
+ function stepNumber(step, field2, fallback) {
3500
+ const value = step?.[field2];
3501
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
3378
3502
  }
3379
- function num(value) {
3380
- return typeof value === "number" ? value : 0;
3503
+ function stepBoolean(step, field2, fallback) {
3504
+ const value = step?.[field2];
3505
+ return typeof value === "boolean" ? value : fallback;
3381
3506
  }
3382
- function list(value) {
3383
- return Array.isArray(value) ? value.join(", ") : "";
3507
+ function stepReasoning(step) {
3508
+ const value = step?.reasoning;
3509
+ return REASONING_EFFORTS.some((effort) => effort.value === value) ? value : "off";
3384
3510
  }
3385
- function parseList(value) {
3386
- return value.split(",").map((v) => v.trim()).filter(Boolean);
3511
+ var REASONING_EFFORTS = [
3512
+ { value: "off", label: "Aucun" },
3513
+ { value: "low", label: "L\xE9ger" },
3514
+ { value: "medium", label: "Moyen" },
3515
+ { value: "high", label: "Pouss\xE9" }
3516
+ ];
3517
+ var KNOWN_MODELS = [
3518
+ {
3519
+ provider: "openai",
3520
+ model: "gpt-4o-mini",
3521
+ label: "GPT-4o mini",
3522
+ hint: "Le moins cher, tr\xE8s rapide \u2014 suffisant pour classer"
3523
+ },
3524
+ {
3525
+ provider: "openai",
3526
+ model: "gpt-5-mini",
3527
+ label: "GPT-5 mini",
3528
+ hint: "Rapide, bon march\xE9, meilleur raisonnement"
3529
+ },
3530
+ {
3531
+ provider: "openai",
3532
+ model: "gpt-4.1",
3533
+ label: "GPT-4.1",
3534
+ hint: "Co\xFBt moyen \u2014 r\xE9daction soign\xE9e"
3535
+ },
3536
+ {
3537
+ provider: "openai",
3538
+ model: "gpt-5",
3539
+ label: "GPT-5",
3540
+ hint: "Le plus capable \u2014 le plus lent et le plus cher"
3541
+ },
3542
+ {
3543
+ provider: "anthropic",
3544
+ model: "claude-3-5-haiku-latest",
3545
+ label: "Claude 3.5 Haiku",
3546
+ hint: "Rapide et bon march\xE9"
3547
+ },
3548
+ {
3549
+ provider: "anthropic",
3550
+ model: "claude-3-5-sonnet-latest",
3551
+ label: "Claude 3.5 Sonnet",
3552
+ hint: "Co\xFBt moyen \u2014 r\xE9daction soign\xE9e"
3553
+ }
3554
+ ];
3555
+ var CUSTOM_MODEL_VALUE = "__custom__";
3556
+ function findModelOption(model) {
3557
+ return KNOWN_MODELS.find((option) => option.model === model);
3558
+ }
3559
+ function defaultStep() {
3560
+ const [first] = KNOWN_MODELS;
3561
+ return { model: first.model, provider: first.provider, reasoning: "off" };
3562
+ }
3563
+ var PIPELINE_PRESETS = [
3564
+ {
3565
+ id: "triage-only",
3566
+ label: "D\xE9marrage prudent \u2014 triage seul",
3567
+ description: "Les demandes sont comprises et class\xE9es. Aucune r\xE9ponse n\u2019est pr\xE9par\xE9e.",
3568
+ enabled: ["triage"]
3569
+ },
3570
+ {
3571
+ id: "assisted",
3572
+ label: "R\xE9ponse assist\xE9e",
3573
+ description: "Triage, escalade et r\xE9daction : un projet de r\xE9ponse est pr\xE9par\xE9 pour un humain. L\u2019envoi automatique reste d\xE9sactiv\xE9.",
3574
+ enabled: ["triage", "escalate", "draft"]
3575
+ }
3576
+ ];
3577
+ function applyPreset(value, preset, restore) {
3578
+ let next = readNodes(value);
3579
+ for (const key of PIPELINE_STEP_KEYS) {
3580
+ const on = preset.enabled.includes(key);
3581
+ next = withStep(next, key, on ? readStep(next, key) ?? restore(key) : null);
3582
+ }
3583
+ return next;
3584
+ }
3585
+ var PERCENT = 100;
3586
+ function PipelineNodesForm({ value, onChange, canWrite, issueMessage }) {
3587
+ const [remembered, setRemembered] = react.useState({});
3588
+ react.useEffect(() => {
3589
+ setRemembered((prev) => {
3590
+ let changed = false;
3591
+ const next = { ...prev };
3592
+ for (const key of PIPELINE_STEP_KEYS) {
3593
+ const step = readStep(value, key);
3594
+ if (step && JSON.stringify(step) !== JSON.stringify(prev[key])) {
3595
+ next[key] = step;
3596
+ changed = true;
3597
+ }
3598
+ }
3599
+ return changed ? next : prev;
3600
+ });
3601
+ }, [value]);
3602
+ function restore(key) {
3603
+ return remembered[key] ?? defaultStep();
3604
+ }
3605
+ function toggleStep(key, on) {
3606
+ onChange(withStep(value, key, on ? restore(key) : null));
3607
+ }
3608
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
3609
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Les \xE9tapes ci-dessous s'ex\xE9cutent dans cet ordre pour chaque demande re\xE7ue." }),
3610
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
3611
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: "Pr\xE9r\xE9glages :" }),
3612
+ PIPELINE_PRESETS.map((preset) => /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Tooltip, { label: preset.description, children: /* @__PURE__ */ jsxRuntime.jsx(
3613
+ uiSdk.Button,
3614
+ {
3615
+ variant: "outline",
3616
+ size: "sm",
3617
+ disabled: !canWrite,
3618
+ onClick: () => onChange(applyPreset(value, preset, restore)),
3619
+ children: preset.label
3620
+ }
3621
+ ) }, preset.id))
3622
+ ] }),
3623
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "-mt-2 text-xs text-muted-foreground", children: "Un pr\xE9r\xE9glage remplit ce formulaire \u2014 il n'enregistre rien tant que vous n'avez pas cliqu\xE9 sur Enregistrer." }),
3624
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "divide-y rounded-md border", children: PIPELINE_STEPS.map((step) => /* @__PURE__ */ jsxRuntime.jsx(
3625
+ StepRow,
3626
+ {
3627
+ step,
3628
+ value,
3629
+ canWrite,
3630
+ issueMessage: step.key === "triage" ? issueMessage : null,
3631
+ onToggle: (on) => toggleStep(step.key, on),
3632
+ onPatch: (patch) => onChange(withStepFields(value, step.key, patch))
3633
+ },
3634
+ step.key
3635
+ )) }),
3636
+ /* @__PURE__ */ jsxRuntime.jsxs("details", { children: [
3637
+ /* @__PURE__ */ jsxRuntime.jsx("summary", { className: "cursor-pointer text-sm font-medium", children: "Mode avanc\xE9 (JSON)" }),
3638
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3", children: /* @__PURE__ */ jsxRuntime.jsx(NodesJsonField, { value, onChange, disabled: !canWrite }) })
3639
+ ] })
3640
+ ] });
3641
+ }
3642
+ function StepRow({
3643
+ step,
3644
+ value,
3645
+ canWrite,
3646
+ issueMessage,
3647
+ onToggle,
3648
+ onPatch
3649
+ }) {
3650
+ const enabled = isStepEnabled(value, step.key);
3651
+ const blockedReason = stepBlockedReason(value, step.key);
3652
+ const triageLocked = step.key === "triage" && enabled;
3653
+ const editable = canWrite && !blockedReason && !triageLocked;
3654
+ const toggle = /* @__PURE__ */ jsxRuntime.jsx(
3655
+ uiSdk.Switch,
3656
+ {
3657
+ "aria-label": `${step.label} \u2014 activer l'\xE9tape`,
3658
+ checked: enabled,
3659
+ onCheckedChange: onToggle,
3660
+ disabled: !editable
3661
+ }
3662
+ );
3663
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: blockedReason ? "space-y-2 p-4 opacity-60" : "space-y-2 p-4", children: [
3664
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-3", children: [
3665
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3666
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: step.label }),
3667
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: step.description })
3668
+ ] }),
3669
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex shrink-0 items-center gap-2 text-sm", children: [
3670
+ triageLocked ? /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Tooltip, { label: TRIAGE_LOCK_REASON, children: toggle }) : toggle,
3671
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: enabled ? "Activ\xE9" : "D\xE9sactiv\xE9" })
3672
+ ] })
3673
+ ] }),
3674
+ blockedReason && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: blockedReason }),
3675
+ issueMessage && !enabled && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: issueMessage }),
3676
+ enabled && /* @__PURE__ */ jsxRuntime.jsxs("details", { children: [
3677
+ /* @__PURE__ */ jsxRuntime.jsx("summary", { className: "cursor-pointer text-sm text-muted-foreground", children: "Options" }),
3678
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 grid gap-4 rounded-md bg-muted/40 p-3 sm:grid-cols-2", children: /* @__PURE__ */ jsxRuntime.jsx(
3679
+ StepOptions,
3680
+ {
3681
+ step,
3682
+ settings: readStep(value, step.key),
3683
+ disabled: !canWrite || blockedReason !== null,
3684
+ onPatch
3685
+ }
3686
+ ) })
3687
+ ] })
3688
+ ] });
3387
3689
  }
3388
- function NodesField({ value, onChange }) {
3690
+ function StepOptions({
3691
+ step,
3692
+ settings,
3693
+ disabled,
3694
+ onPatch
3695
+ }) {
3696
+ const model = stepString(settings, "model");
3697
+ const known = findModelOption(model);
3698
+ const [freeText, setFreeText] = react.useState(false);
3699
+ const showFreeText = freeText || model !== "" && !known;
3700
+ const ids = useIds(step.key);
3701
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3702
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3703
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: ids.model, className: "mb-1 block text-sm font-medium", children: "Mod\xE8le" }),
3704
+ /* @__PURE__ */ jsxRuntime.jsx(
3705
+ uiSdk.Select,
3706
+ {
3707
+ "aria-label": `Mod\xE8le \u2014 ${step.label}`,
3708
+ value: showFreeText ? CUSTOM_MODEL_VALUE : known?.model ?? void 0,
3709
+ onValueChange: (next) => {
3710
+ if (next === CUSTOM_MODEL_VALUE) {
3711
+ setFreeText(true);
3712
+ return;
3713
+ }
3714
+ setFreeText(false);
3715
+ const option = findModelOption(next);
3716
+ if (!option) return;
3717
+ onPatch({ model: option.model, provider: option.provider });
3718
+ },
3719
+ items: [
3720
+ ...KNOWN_MODELS.map((option) => ({
3721
+ value: option.model,
3722
+ label: `${option.label} \u2014 ${option.hint}`
3723
+ })),
3724
+ { value: CUSTOM_MODEL_VALUE, label: "Autre \u2014 saisir un identifiant de mod\xE8le" }
3725
+ ],
3726
+ disabled
3727
+ }
3728
+ ),
3729
+ showFreeText && // The provider travels WITH the model: a free-text id typed after a
3730
+ // catalogue pick would otherwise keep the previous entry's provider
3731
+ // (`gpt-5.1` dispatched to Anthropic), and a provider outside the
3732
+ // catalogue would have no control at all — which is the whole point
3733
+ // of the escape hatch.
3734
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 space-y-2", children: [
3735
+ /* @__PURE__ */ jsxRuntime.jsx(
3736
+ uiSdk.Input,
3737
+ {
3738
+ id: ids.model,
3739
+ "aria-label": `Identifiant de mod\xE8le \u2014 ${step.label}`,
3740
+ value: model,
3741
+ disabled,
3742
+ onChange: (e) => onPatch({ model: e.target.value })
3743
+ }
3744
+ ),
3745
+ /* @__PURE__ */ jsxRuntime.jsx(
3746
+ uiSdk.Input,
3747
+ {
3748
+ id: ids.provider,
3749
+ "aria-label": `Fournisseur \u2014 ${step.label}`,
3750
+ value: stepString(settings, "provider") || DEFAULT_LLM_PROVIDER,
3751
+ disabled,
3752
+ onChange: (e) => onPatch({ provider: e.target.value })
3753
+ }
3754
+ ),
3755
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Identifiant du mod\xE8le et fournisseur (\xAB openai \xBB, \xAB anthropic \xBB\u2026), tels que l'API les attend." })
3756
+ ] })
3757
+ ] }),
3758
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3759
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: ids.reasoning, className: "mb-1 block text-sm font-medium", children: "Effort de raisonnement" }),
3760
+ /* @__PURE__ */ jsxRuntime.jsx(
3761
+ uiSdk.Select,
3762
+ {
3763
+ "aria-label": `Effort de raisonnement \u2014 ${step.label}`,
3764
+ value: stepReasoning(settings),
3765
+ onValueChange: (next) => onPatch({ reasoning: next }),
3766
+ items: REASONING_EFFORTS.map((effort) => ({ value: effort.value, label: effort.label })),
3767
+ disabled
3768
+ }
3769
+ )
3770
+ ] }),
3771
+ step.key === "draft" && /* @__PURE__ */ jsxRuntime.jsx(
3772
+ NumberField,
3773
+ {
3774
+ id: ids.maxToolCalls,
3775
+ label: "Nombre d'outils consultables par r\xE9ponse",
3776
+ value: stepNumber(settings, "maxToolCalls", DEFAULT_MAX_TOOL_CALLS),
3777
+ onChange: (next) => onPatch({ maxToolCalls: next }),
3778
+ disabled,
3779
+ min: 0,
3780
+ integer: true,
3781
+ hint: "Chaque consultation (commande, livraison\u2026) co\xFBte un appel suppl\xE9mentaire."
3782
+ }
3783
+ ),
3784
+ step.key === "evaluate" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3785
+ /* @__PURE__ */ jsxRuntime.jsx(
3786
+ NumberField,
3787
+ {
3788
+ id: ids.minConfidence,
3789
+ label: "Seuil de confiance (%)",
3790
+ value: Math.round(stepNumber(settings, "minConfidence", DEFAULT_MIN_CONFIDENCE) * PERCENT),
3791
+ onChange: (next) => onPatch({ minConfidence: next / PERCENT }),
3792
+ disabled,
3793
+ min: 0,
3794
+ max: PERCENT,
3795
+ integer: true,
3796
+ hint: "En dessous de ce seuil, la r\xE9ponse n'est jamais envoy\xE9e automatiquement."
3797
+ }
3798
+ ),
3799
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-sm sm:col-span-2", children: [
3800
+ /* @__PURE__ */ jsxRuntime.jsx(
3801
+ uiSdk.Switch,
3802
+ {
3803
+ "aria-label": "Autoriser l'escalade depuis l'\xE9valuation",
3804
+ checked: stepBoolean(settings, "escalationEnabled", DEFAULT_ESCALATION_ENABLED),
3805
+ onCheckedChange: (next) => onPatch({ escalationEnabled: next }),
3806
+ disabled
3807
+ }
3808
+ ),
3809
+ "Autoriser l'escalade \u2014 une \xE9valuation insuffisante est transmise \xE0 un humain"
3810
+ ] })
3811
+ ] })
3812
+ ] });
3813
+ }
3814
+ function useIds(stepKey) {
3815
+ const base2 = react.useId();
3816
+ return {
3817
+ model: `${base2}-${stepKey}-model`,
3818
+ provider: `${base2}-${stepKey}-provider`,
3819
+ reasoning: `${base2}-${stepKey}-reasoning`,
3820
+ maxToolCalls: `${base2}-${stepKey}-max-tool-calls`,
3821
+ minConfidence: `${base2}-${stepKey}-min-confidence`
3822
+ };
3823
+ }
3824
+ function NodesJsonField({
3825
+ value,
3826
+ onChange,
3827
+ disabled
3828
+ }) {
3389
3829
  const id = react.useId();
3390
- const [text, setText] = react.useState(() => JSON.stringify(value ?? null, null, 2));
3830
+ const serialized = stringify(value);
3831
+ const [text, setText] = react.useState(serialized);
3391
3832
  const [parseError, setParseError] = react.useState(null);
3833
+ const emittedRef = react.useRef(serialized);
3834
+ react.useEffect(() => {
3835
+ if (serialized === emittedRef.current) return;
3836
+ emittedRef.current = serialized;
3837
+ setText(serialized);
3838
+ setParseError(null);
3839
+ }, [serialized]);
3392
3840
  function handleChange(next) {
3393
3841
  setText(next);
3394
3842
  try {
3395
- onChange(JSON.parse(next));
3843
+ const parsed = JSON.parse(next);
3844
+ emittedRef.current = stringify(parsed);
3845
+ onChange(parsed);
3396
3846
  setParseError(null);
3397
3847
  } catch {
3398
3848
  setParseError("JSON invalide \u2014 la derni\xE8re valeur valide est conserv\xE9e tant que ce texte ne parse pas.");
@@ -3407,6 +3857,7 @@ function NodesField({ value, onChange }) {
3407
3857
  className: "font-mono text-xs",
3408
3858
  rows: 10,
3409
3859
  value: text,
3860
+ disabled,
3410
3861
  onChange: (e) => handleChange(e.target.value)
3411
3862
  }
3412
3863
  ),
@@ -3430,27 +3881,51 @@ function NodesField({ value, onChange }) {
3430
3881
  ] })
3431
3882
  ] });
3432
3883
  }
3433
- function NumberField({
3434
- id,
3435
- label,
3436
- value,
3437
- onChange
3438
- }) {
3439
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3440
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: "mb-1 block text-sm font-medium", children: label }),
3441
- /* @__PURE__ */ jsxRuntime.jsx(
3442
- uiSdk.Input,
3443
- {
3444
- id,
3445
- type: "number",
3446
- value,
3447
- onChange: (e) => {
3448
- const parsed = Number(e.target.value);
3449
- if (e.target.value.trim() !== "" && Number.isFinite(parsed)) onChange(parsed);
3450
- }
3451
- }
3452
- )
3453
- ] });
3884
+ function stringify(value) {
3885
+ return JSON.stringify(value ?? null, null, 2);
3886
+ }
3887
+ var WHATSAPP_MODE_LABELS = {
3888
+ escalate_only: "Escalade uniquement",
3889
+ draft_only: "Brouillon uniquement",
3890
+ auto_reply: "R\xE9ponse automatique"
3891
+ };
3892
+ var WHATSAPP_MODE_OPTIONS = WHATSAPP_MODES.map((value) => ({ value, label: WHATSAPP_MODE_LABELS[value] }));
3893
+ function field(value) {
3894
+ return typeof value === "string" ? value : "";
3895
+ }
3896
+ function bool(value) {
3897
+ return value === true;
3898
+ }
3899
+ function num(value) {
3900
+ return typeof value === "number" ? value : 0;
3901
+ }
3902
+ function list(value) {
3903
+ return Array.isArray(value) ? value.join(", ") : "";
3904
+ }
3905
+ function parseList(value) {
3906
+ return value.split(",").map((v) => v.trim()).filter(Boolean);
3907
+ }
3908
+ function describeConnection(connections) {
3909
+ if (connections === void 0) return { text: "Chargement\u2026", tone: "muted" };
3910
+ if (connections === null) {
3911
+ return { text: "Ind\xE9termin\xE9e \u2014 les connexions de l\u2019instance n\u2019ont pas pu \xEAtre lues.", tone: "muted" };
3912
+ }
3913
+ if (connections.length === 0) {
3914
+ return {
3915
+ text: "Aucune connexion Gorgias sur l\u2019instance \u2014 le pipeline ne peut appeler Gorgias tant qu\u2019une connexion n\u2019est pas cr\xE9\xE9e.",
3916
+ tone: "error"
3917
+ };
3918
+ }
3919
+ const [only] = connections;
3920
+ if (connections.length === 1 && only) return { text: only.label, tone: "normal" };
3921
+ const fallback = connections.find((connection) => connection.isDefault);
3922
+ if (!fallback) {
3923
+ return {
3924
+ text: `${connections.length} connexions Gorgias, aucune par d\xE9faut \u2014 chaque appel Gorgias \xE9chouera tant que l\u2019une d\u2019elles n\u2019est pas marqu\xE9e par d\xE9faut.`,
3925
+ tone: "error"
3926
+ };
3927
+ }
3928
+ return { text: `${fallback.label} (par d\xE9faut, parmi ${connections.length} connexions)`, tone: "normal" };
3454
3929
  }
3455
3930
  function SettingsPage() {
3456
3931
  const { appSlug, role } = uiSdk.useAppContext();
@@ -3462,6 +3937,7 @@ function SettingsPage() {
3462
3937
  const [views, setViews] = react.useState([]);
3463
3938
  const [uncheckedAppSlugs, setUncheckedAppSlugs] = react.useState([]);
3464
3939
  const [installedAppsUnavailable, setInstalledAppsUnavailable] = react.useState(false);
3940
+ const [connections, setConnections] = react.useState(void 0);
3465
3941
  const formInitializedRef = react.useRef(false);
3466
3942
  react.useEffect(() => {
3467
3943
  if (settings && !formInitializedRef.current) {
@@ -3496,8 +3972,10 @@ function SettingsPage() {
3496
3972
  if (!cancelled) {
3497
3973
  setViews(result.views);
3498
3974
  setUncheckedAppSlugs(result.uncheckedAppSlugs);
3975
+ setConnections(result.connections);
3499
3976
  }
3500
3977
  } catch {
3978
+ if (!cancelled) setConnections(null);
3501
3979
  }
3502
3980
  })();
3503
3981
  return () => {
@@ -3508,16 +3986,19 @@ function SettingsPage() {
3508
3986
  setForm((prev) => ({ ...prev, [key]: value }));
3509
3987
  }
3510
3988
  if (isLoading) {
3511
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center py-12", children: [
3989
+ return /* @__PURE__ */ jsxRuntime.jsx(PageShell, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center py-12", children: [
3512
3990
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Spinner, {}),
3513
3991
  " ",
3514
3992
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 text-sm text-muted-foreground", children: "Chargement\u2026" })
3515
- ] });
3993
+ ] }) });
3516
3994
  }
3995
+ const connection = describeConnection(connections);
3517
3996
  const sourceViewId = field(form.sourceViewId);
3518
3997
  const claimedView = views.find((v) => v.id === sourceViewId);
3519
3998
  const claimUnverifiable = installedAppsUnavailable || uncheckedAppSlugs.length > 0;
3520
3999
  const issues = validateSettings(form);
4000
+ const nodesIssue = issues.find((issue) => issue.key === "nodes");
4001
+ const summaryIssues = issues.filter((issue) => issue !== nodesIssue);
3521
4002
  const guardrailsActive = Array.isArray(form.guardrailsActive) ? form.guardrailsActive : [];
3522
4003
  function toggleGuardrail(id, checked) {
3523
4004
  set(
@@ -3525,24 +4006,20 @@ function SettingsPage() {
3525
4006
  checked ? [.../* @__PURE__ */ new Set([...guardrailsActive, id])] : guardrailsActive.filter((g) => g !== id)
3526
4007
  );
3527
4008
  }
3528
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-3xl space-y-6", children: [
3529
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3530
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", children: "Param\xE8tres" }),
3531
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Configuration du pipeline de support." })
3532
- ] }),
4009
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { className: "max-w-3xl", children: [
4010
+ /* @__PURE__ */ jsxRuntime.jsx(PageHeader, { title: "Param\xE8tres", description: "Configuration du pipeline de support." }),
3533
4011
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { id: "source", children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-3 p-4", children: [
3534
4012
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-medium", children: "Source" }),
3535
4013
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3536
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "gorgiasConnectionId", className: "mb-1 block text-sm font-medium", children: "Connexion Gorgias" }),
4014
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mb-1 block text-sm font-medium", children: "Connexion Gorgias" }),
3537
4015
  /* @__PURE__ */ jsxRuntime.jsx(
3538
- uiSdk.Input,
4016
+ "p",
3539
4017
  {
3540
- id: "gorgiasConnectionId",
3541
- value: field(form.gorgiasConnectionId),
3542
- onChange: (e) => set("gorgiasConnectionId", e.target.value),
3543
- disabled: !canWrite
4018
+ className: connection.tone === "error" ? "text-sm text-destructive" : connection.tone === "muted" ? "text-sm text-muted-foreground" : "text-sm",
4019
+ children: connection.text
3544
4020
  }
3545
- )
4021
+ ),
4022
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "Cette application utilise la connexion Gorgias de l\u2019instance ; elle se r\xE8gle dans les int\xE9grations de la plateforme, pas ici." })
3546
4023
  ] }),
3547
4024
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3548
4025
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "sourceViewId", className: "mb-1 block text-sm font-medium", children: "Vue Gorgias source" }),
@@ -3605,7 +4082,10 @@ function SettingsPage() {
3605
4082
  id: "batchLimit",
3606
4083
  label: "Taille de lot",
3607
4084
  value: num(form.batchLimit),
3608
- onChange: (v) => set("batchLimit", v)
4085
+ onChange: (v) => set("batchLimit", v),
4086
+ disabled: !canWrite,
4087
+ min: 1,
4088
+ integer: true
3609
4089
  }
3610
4090
  ),
3611
4091
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -3614,7 +4094,10 @@ function SettingsPage() {
3614
4094
  id: "triageIntervalMinutes",
3615
4095
  label: "Intervalle de triage (minutes)",
3616
4096
  value: num(form.triageIntervalMinutes),
3617
- onChange: (v) => set("triageIntervalMinutes", v)
4097
+ onChange: (v) => set("triageIntervalMinutes", v),
4098
+ disabled: !canWrite,
4099
+ min: 1,
4100
+ integer: true
3618
4101
  }
3619
4102
  ),
3620
4103
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -3623,7 +4106,10 @@ function SettingsPage() {
3623
4106
  id: "responseTtlMinutes",
3624
4107
  label: "Dur\xE9e de vie des r\xE9ponses (minutes)",
3625
4108
  value: num(form.responseTtlMinutes),
3626
- onChange: (v) => set("responseTtlMinutes", v)
4109
+ onChange: (v) => set("responseTtlMinutes", v),
4110
+ disabled: !canWrite,
4111
+ min: 1,
4112
+ integer: true
3627
4113
  }
3628
4114
  )
3629
4115
  ] }) }),
@@ -3812,8 +4298,16 @@ function SettingsPage() {
3812
4298
  ] })
3813
4299
  ] }) }),
3814
4300
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { id: "pipeline-avance", children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-3 p-4", children: [
3815
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-medium", children: "Pipeline (avanc\xE9)" }),
3816
- /* @__PURE__ */ jsxRuntime.jsx(NodesField, { value: form.nodes, onChange: (v) => set("nodes", v) }),
4301
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-medium", children: "Traitement automatique" }),
4302
+ /* @__PURE__ */ jsxRuntime.jsx(
4303
+ PipelineNodesForm,
4304
+ {
4305
+ value: form.nodes,
4306
+ onChange: (v) => set("nodes", v),
4307
+ canWrite,
4308
+ issueMessage: nodesIssue ? settingsIssueLabel(nodesIssue.key, nodesIssue.message) : null
4309
+ }
4310
+ ),
3817
4311
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: `/espace/${appSlug}/graph-canvas`, children: "Visualiser dans Graphe" })
3818
4312
  ] }) }),
3819
4313
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-3 p-4", children: [
@@ -3821,7 +4315,7 @@ function SettingsPage() {
3821
4315
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Les agents support sont des utilisateurs plateforme \u2014 donnez-leur acc\xE8s \xE0 cette application depuis la gestion des membres." }),
3822
4316
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: "/parametres/membres", children: "G\xE9rer les acc\xE8s" })
3823
4317
  ] }) }),
3824
- issues.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-status-pending bg-status-pending/10 p-3 text-sm", children: issues.map((issue) => /* @__PURE__ */ jsxRuntime.jsx("p", { children: settingsIssueLabel(issue.key, issue.message) }, issue.key)) }),
4318
+ summaryIssues.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-status-pending bg-status-pending/10 p-3 text-sm", children: summaryIssues.map((issue) => /* @__PURE__ */ jsxRuntime.jsx("p", { children: settingsIssueLabel(issue.key, issue.message) }, issue.key)) }),
3825
4319
  canWrite && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => void save(form), disabled: isSaving || issues.length > 0, children: isSaving ? "Enregistrement\u2026" : "Enregistrer" }) })
3826
4320
  ] })
3827
4321
  ] });
@@ -4141,11 +4635,8 @@ function GraphCanvasPage() {
4141
4635
  );
4142
4636
  const isLoading = settingsLoading || categoriesLoading;
4143
4637
  const isUnavailable = !isLoading && (settingsError !== void 0 || categoriesError !== void 0 || !result);
4144
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
4145
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4146
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", children: "Graphe" }),
4147
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Le parcours d'un ticket \xE0 travers les 9 n\u0153uds du pipeline, et ce qui, dans les r\xE9glages actuels, rend chaque n\u0153ud atteignable ou non." })
4148
- ] }),
4638
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
4639
+ /* @__PURE__ */ jsxRuntime.jsx(PageHeader, { title: "Graphe", description: "Le parcours d'un ticket \xE0 travers les 9 n\u0153uds du pipeline, et ce qui, dans les r\xE9glages actuels, rend chaque n\u0153ud atteignable ou non." }),
4149
4640
  isLoading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center py-12", children: [
4150
4641
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Spinner, {}),
4151
4642
  " ",
@@ -4453,14 +4944,15 @@ function SharedPromptsPage() {
4453
4944
  },
4454
4945
  { key: "latestVersion", header: "Derni\xE8re version", align: "right", cell: (row) => `v${row.latestVersion}` }
4455
4946
  ];
4456
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
4457
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-4", children: [
4458
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4459
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", children: "Prompts partag\xE9s" }),
4460
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "La biblioth\xE8que des prompts \xAB shared/* \xBB et leur composition." })
4461
- ] }),
4462
- canWrite && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => setIsCreateOpen(true), children: "+ Nouveau prompt partag\xE9" })
4463
- ] }),
4947
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
4948
+ /* @__PURE__ */ jsxRuntime.jsx(
4949
+ PageHeader,
4950
+ {
4951
+ title: "Prompts partag\xE9s",
4952
+ description: "La biblioth\xE8que des prompts \xAB shared/* \xBB et leur composition.",
4953
+ actions: canWrite && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => setIsCreateOpen(true), children: "+ Nouveau prompt partag\xE9" })
4954
+ }
4955
+ ),
4464
4956
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-status-warning/40 bg-status-warning/10 p-3 text-sm text-status-warning", children: "Ressource commune \xE0 toute l'entreprise : sous D-LF il n'existe qu'un seul prompt Langfuse par nom \xAB shared/* \xBB, partag\xE9 par toutes les apps support. Modifier ou promouvoir une version ici change ce que TOUTES les apps utilisant ce prompt envoient \u2014 pas seulement celle-ci." }),
4465
4957
  /* @__PURE__ */ jsxRuntime.jsx(
4466
4958
  uiSdk.DataTable,
@@ -4678,7 +5170,7 @@ function DryRunResultView({ result, langfuseConfig, knownTags, tagSettings }) {
4678
5170
  ] }),
4679
5171
  result.guardrailHits.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4680
5172
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Garde-fous d\xE9clench\xE9s" }),
4681
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1", children: result.guardrailHits.map((hit, i) => /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "warning", children: hit }, `${hit}-${i}`)) })
5173
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1", children: result.guardrailHits.map((hit, i) => /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "warning", children: guardrailHitLabel(hit) }, `${hit}-${i}`)) })
4682
5174
  ] }),
4683
5175
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-md border border-dashed p-4", children: [
4684
5176
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Ce qui n'a pas eu lieu" }),
@@ -4706,6 +5198,14 @@ var TRI_STATE_OPTIONS = [
4706
5198
  { value: "on", label: "Forcer actif" },
4707
5199
  { value: "off", label: "Forcer inactif" }
4708
5200
  ];
5201
+ var SOURCE_OPTIONS = [
5202
+ { value: "gorgias", label: "Ticket Gorgias existant" },
5203
+ { value: "inline", label: "Ticket saisi \xE0 la main" }
5204
+ ];
5205
+ var CHANNEL_OPTIONS = [
5206
+ { value: "email", label: "Email" },
5207
+ { value: "whatsapp", label: "WhatsApp" }
5208
+ ];
4709
5209
  function triStateToOverride(value) {
4710
5210
  if (value === "on") return true;
4711
5211
  if (value === "off") return false;
@@ -4735,7 +5235,11 @@ function describeOverrides(overrides) {
4735
5235
  }
4736
5236
  function SingleTicketTab({ langfuseConfig, agents, categories, knownTags, tagSettings }) {
4737
5237
  const api = uiSdk.useAppApi();
5238
+ const [source, setSource] = react.useState("gorgias");
4738
5239
  const [ticketId, setTicketId] = react.useState("");
5240
+ const [body, setBody] = react.useState("");
5241
+ const [subject, setSubject] = react.useState("");
5242
+ const [channel, setChannel] = react.useState("email");
4739
5243
  const [agentId, setAgentId] = react.useState("");
4740
5244
  const [categoryId, setCategoryId] = react.useState("");
4741
5245
  const [evaluateOverride, setEvaluateOverride] = react.useState("");
@@ -4747,6 +5251,10 @@ function SingleTicketTab({ langfuseConfig, agents, categories, knownTags, tagSet
4747
5251
  const [result, setResult] = react.useState(null);
4748
5252
  const [resultOverrides, setResultOverrides] = react.useState(null);
4749
5253
  const ticketIdInputId = react.useId();
5254
+ const bodyInputId = react.useId();
5255
+ const subjectInputId = react.useId();
5256
+ const isInline = source === "inline";
5257
+ const canRun = isInline ? body.trim() !== "" : ticketId.trim() !== "";
4750
5258
  const agentOptions = [{ value: "", label: "Agent du profil (d\xE9faut)" }, ...agents.map((a) => ({ value: a.id, label: a.name }))];
4751
5259
  const categoryOptions = [{ value: "", label: "Cat\xE9gorie du triage (d\xE9faut)" }, ...categories.map((c) => ({ value: c.id, label: c.name }))];
4752
5260
  async function run() {
@@ -4761,7 +5269,7 @@ function SingleTicketTab({ langfuseConfig, agents, categories, knownTags, tagSet
4761
5269
  ...autoSendOverride ? { autoSend: true } : {}
4762
5270
  };
4763
5271
  const payload = {
4764
- ticketId: ticketId.trim(),
5272
+ ...isInline ? { inlineTicket: { body: body.trim(), ...subject.trim() ? { subject: subject.trim() } : {}, channel } } : { ticketId: ticketId.trim() },
4765
5273
  ...agentId.trim() ? { agentId: agentId.trim() } : {},
4766
5274
  ...categoryId.trim() ? { categoryId: categoryId.trim() } : {},
4767
5275
  ...Object.keys(overrides).length > 0 ? { overrides } : {}
@@ -4781,9 +5289,32 @@ function SingleTicketTab({ langfuseConfig, agents, categories, knownTags, tagSet
4781
5289
  }
4782
5290
  }
4783
5291
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
4784
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Rejoue le graphe complet pour UN ticket, sans jamais r\xE9pondre, taguer ni \xE9crire de record (\xA70). Les n\u0153uds forc\xE9s \xAB inactif \xBB ou \xAB actif \xBB ne s'appliquent qu'\xE0 cette ex\xE9cution \u2014 les r\xE9glages de l'app ne changent pas." }),
5292
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Rejoue le graphe complet pour UN ticket, sans jamais r\xE9pondre, taguer ni \xE9crire de record (\xA70). Les n\u0153uds forc\xE9s \xAB inactif \xBB ou \xAB actif \xBB ne s'appliquent qu'\xE0 cette ex\xE9cution \u2014 les r\xE9glages de l'app ne changent pas. Un ticket saisi \xE0 la main ne touche aucun endpoint Gorgias : le graphe tourne en entier (triage, r\xE9daction, garde-fous, appels LLM r\xE9els) sur le texte fourni." }),
4785
5293
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-3", children: [
4786
5294
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5295
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 block text-sm font-medium", children: "Source du ticket" }),
5296
+ /* @__PURE__ */ jsxRuntime.jsx(
5297
+ uiSdk.Select,
5298
+ {
5299
+ "aria-label": "Source du ticket",
5300
+ items: SOURCE_OPTIONS,
5301
+ value: source,
5302
+ onValueChange: (next) => setSource(next)
5303
+ }
5304
+ )
5305
+ ] }),
5306
+ isInline ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5307
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 block text-sm font-medium", children: "Canal" }),
5308
+ /* @__PURE__ */ jsxRuntime.jsx(
5309
+ uiSdk.Select,
5310
+ {
5311
+ "aria-label": "Canal",
5312
+ items: CHANNEL_OPTIONS,
5313
+ value: channel,
5314
+ onValueChange: (next) => setChannel(next)
5315
+ }
5316
+ )
5317
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4787
5318
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: ticketIdInputId, className: "mb-1 block text-sm font-medium", children: "ID du ticket" }),
4788
5319
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Input, { id: ticketIdInputId, value: ticketId, onChange: (e) => setTicketId(e.target.value), placeholder: "12345" })
4789
5320
  ] }),
@@ -4796,6 +5327,25 @@ function SingleTicketTab({ langfuseConfig, agents, categories, knownTags, tagSet
4796
5327
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { "aria-label": "Cat\xE9gorie forc\xE9e (optionnel)", items: categoryOptions, value: categoryId, onValueChange: setCategoryId, placeholder: "Cat\xE9gorie du triage (d\xE9faut)" })
4797
5328
  ] })
4798
5329
  ] }),
5330
+ isInline && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
5331
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5332
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: subjectInputId, className: "mb-1 block text-sm font-medium", children: "Sujet (optionnel)" }),
5333
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Input, { id: subjectInputId, value: subject, onChange: (e) => setSubject(e.target.value), placeholder: "O\xF9 est ma commande ?" })
5334
+ ] }),
5335
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5336
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: bodyInputId, className: "mb-1 block text-sm font-medium", children: "Message du client" }),
5337
+ /* @__PURE__ */ jsxRuntime.jsx(
5338
+ uiSdk.Textarea,
5339
+ {
5340
+ id: bodyInputId,
5341
+ value: body,
5342
+ onChange: (e) => setBody(e.target.value),
5343
+ rows: 6,
5344
+ placeholder: "Bonjour, j'ai command\xE9 il y a dix jours et je n'ai toujours rien re\xE7u\u2026"
5345
+ }
5346
+ )
5347
+ ] })
5348
+ ] }),
4799
5349
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-4", children: [
4800
5350
  /* @__PURE__ */ jsxRuntime.jsx(OverrideSelect, { label: "N\u0153ud \xE9valuation", value: evaluateOverride, onChange: setEvaluateOverride }),
4801
5351
  /* @__PURE__ */ jsxRuntime.jsx(OverrideSelect, { label: "N\u0153ud r\xE9vision", value: reviseOverride, onChange: setReviseOverride }),
@@ -4809,7 +5359,7 @@ function SingleTicketTab({ langfuseConfig, agents, categories, knownTags, tagSet
4809
5359
  }
4810
5360
  ) })
4811
5361
  ] }),
4812
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => void run(), disabled: ticketId.trim() === "" || isRunning, children: isRunning ? "Test en cours\u2026" : "Lancer le test" }),
5362
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => void run(), disabled: !canRun || isRunning, children: isRunning ? "Test en cours\u2026" : "Lancer le test" }),
4813
5363
  error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: error }),
4814
5364
  result && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-md border p-4", children: [
4815
5365
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-3 text-xs font-medium text-muted-foreground", "data-testid": "single-ticket-result-overrides", children: describeOverrides(resultOverrides ?? {}) }),
@@ -4817,117 +5367,21 @@ function SingleTicketTab({ langfuseConfig, agents, categories, knownTags, tagSet
4817
5367
  ] })
4818
5368
  ] });
4819
5369
  }
4820
- function BenchTab({ langfuseConfig, agents, knownTags, tagSettings }) {
4821
- const api = uiSdk.useAppApi();
4822
- const [viewId, setViewId] = react.useState("");
4823
- const [ticketIds, setTicketIds] = react.useState("");
4824
- const [agentId, setAgentId] = react.useState("");
4825
- const [limit, setLimit] = react.useState("");
4826
- const [isRunning, setIsRunning] = react.useState(false);
4827
- const [error, setError] = react.useState(null);
4828
- const [response, setResponse] = react.useState(null);
4829
- const [selected, setSelected] = react.useState(null);
4830
- const viewIdInputId = react.useId();
4831
- const ticketIdsInputId = react.useId();
4832
- const limitInputId = react.useId();
4833
- const agentOptions = [{ value: "", label: "Chaque ticket, agent r\xE9el de sa cat\xE9gorie" }, ...agents.map((a) => ({ value: a.id, label: a.name }))];
4834
- async function run() {
4835
- setIsRunning(true);
4836
- setError(null);
4837
- setResponse(null);
4838
- const parsedIds = ticketIds.split(",").map((id) => id.trim()).filter(Boolean);
4839
- const parsedLimit = Number(limit);
4840
- const payload = {
4841
- ...viewId.trim() ? { viewId: viewId.trim() } : {},
4842
- ...parsedIds.length > 0 ? { ticketIds: parsedIds } : {},
4843
- ...agentId.trim() ? { agentId: agentId.trim() } : {},
4844
- ...limit.trim() !== "" && Number.isFinite(parsedLimit) ? { limit: parsedLimit } : {}
4845
- };
4846
- try {
4847
- const result = await api.invoke(
4848
- "test-agents",
4849
- payload,
4850
- { idempotencyKey: idempotencyKeyFor("test-agents", payload) }
4851
- );
4852
- setResponse(result);
4853
- } catch (err) {
4854
- setError(describeInvokeError(err));
4855
- } finally {
4856
- setIsRunning(false);
4857
- }
4858
- }
4859
- const columns = [
4860
- { key: "ticketId", header: "Ticket", cell: (row) => row.ticketId },
4861
- { key: "outcome", header: "Issue", cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: row.outcome === "sent" ? "success" : "neutral", children: outcomeLabel(row.outcome) }) },
4862
- { key: "guardrails", header: "Garde-fous", cell: (row) => row.guardrailHits.length > 0 ? row.guardrailHits.map(guardrailHitLabel).join(", ") : "\u2014" },
4863
- { key: "completions", header: "Appels LLM", align: "right", cell: (row) => String(row.completions.length) },
4864
- { key: "error", header: "Erreur", cell: (row) => row.error ? /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "danger", children: row.error }) : "\u2014" }
4865
- ];
4866
- const canSubmit = (viewId.trim() !== "" || ticketIds.trim() !== "") && !isRunning;
4867
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
4868
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Rejoue le graphe complet, sans \xE9criture, sur plusieurs tickets d'une vue Gorgias ou d'une liste d'ids \u2014 aucune de leurs cat\xE9gories n'est r\xE9ellement lue pour l'envoi automatique : le banc force \xAB Envoi auto \xBB actif pour chaque ticket afin d'observer le chemin complet (voir le bandeau ci-dessous)." }),
4869
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-4", children: [
4870
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4871
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: viewIdInputId, className: "mb-1 block text-sm font-medium", children: "Vue Gorgias (id)" }),
4872
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Input, { id: viewIdInputId, value: viewId, onChange: (e) => setViewId(e.target.value) })
4873
- ] }),
4874
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4875
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: ticketIdsInputId, className: "mb-1 block text-sm font-medium", children: "Ou ids de tickets (s\xE9par\xE9s par une virgule)" }),
4876
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Input, { id: ticketIdsInputId, value: ticketIds, onChange: (e) => setTicketIds(e.target.value) })
4877
- ] }),
4878
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4879
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 block text-sm font-medium", children: "Agent (optionnel)" }),
4880
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { "aria-label": "Agent (optionnel)", items: agentOptions, value: agentId, onValueChange: setAgentId, placeholder: "Chaque ticket, agent r\xE9el de sa cat\xE9gorie" })
4881
- ] }),
4882
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4883
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: limitInputId, className: "mb-1 block text-sm font-medium", children: "Limite (d\xE9faut 20, max 100)" }),
4884
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Input, { id: limitInputId, type: "number", value: limit, onChange: (e) => setLimit(e.target.value) })
4885
- ] })
4886
- ] }),
4887
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => void run(), disabled: !canSubmit, children: isRunning ? "Banc en cours\u2026" : "Lancer le banc" }),
4888
- error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: error }),
4889
- response && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4890
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-status-warning/40 bg-status-warning/10 p-3 text-sm text-status-warning", children: "Envoi automatique forc\xE9 pour ce banc : chaque ticket est \xE9valu\xE9 comme si sa cat\xE9gorie avait \xAB Envoi auto \xBB activ\xE9, quel que soit son r\xE9glage r\xE9el \u2014 voir la colonne Issue pour ce que le graphe aurait fait dans ce cas." }),
4891
- /* @__PURE__ */ jsxRuntime.jsx(
4892
- uiSdk.DataTable,
4893
- {
4894
- columns,
4895
- rows: response.results,
4896
- rowId: (row) => row.ticketId,
4897
- manual: true,
4898
- onRowClick: (row) => setSelected(row),
4899
- empty: "Aucun ticket dans cette fen\xEAtre."
4900
- }
4901
- )
4902
- ] }),
4903
- selected && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.SidePanel, { open: true, onClose: () => setSelected(null), title: `Ticket ${selected.ticketId}`, children: /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "dry-run-detail", children: /* @__PURE__ */ jsxRuntime.jsx(DryRunResultView, { result: selected, langfuseConfig, knownTags, tagSettings }) }) })
4904
- ] });
4905
- }
4906
- function TestTabs() {
5370
+ function TestControls() {
4907
5371
  const { config: langfuseConfig } = useLangfuseConfig();
4908
5372
  const { settings } = uiSdk.useAppSettings();
4909
5373
  const { rows: allAgents } = useRecordList("agent", { limit: 500 }, toAgent);
4910
5374
  const { rows: categories } = useRecordList("category", { limit: 500 }, toCategory);
4911
5375
  const agents = react.useMemo(() => allAgents.filter((agent) => agent.status !== "archived"), [allAgents]);
4912
5376
  const knownTags = react.useMemo(() => categories.map((category) => category.tagName), [categories]);
4913
- return /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Tabs, { defaultValue: "single", children: [
4914
- /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.TabsList, { children: [
4915
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.TabsTrigger, { value: "single", children: "Test unitaire" }),
4916
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.TabsTrigger, { value: "bench", children: "Banc d'essai" })
4917
- ] }),
4918
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.TabsContent, { value: "single", children: /* @__PURE__ */ jsxRuntime.jsx(SingleTicketTab, { langfuseConfig, agents, categories, knownTags, tagSettings: settings }) }),
4919
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.TabsContent, { value: "bench", children: /* @__PURE__ */ jsxRuntime.jsx(BenchTab, { langfuseConfig, agents, knownTags, tagSettings: settings }) })
4920
- ] });
5377
+ return /* @__PURE__ */ jsxRuntime.jsx(SingleTicketTab, { langfuseConfig, agents, categories, knownTags, tagSettings: settings });
4921
5378
  }
4922
5379
  function TestPage() {
4923
5380
  const { role } = uiSdk.useAppContext();
4924
5381
  const canRun = canWriteForRole(role);
4925
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
4926
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4927
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", children: "Banc de test" }),
4928
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Rejoue le graphe sans jamais agir sur un vrai ticket (\xA70)." })
4929
- ] }),
4930
- !canRun ? /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(TestTabs, {})
5382
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
5383
+ /* @__PURE__ */ jsxRuntime.jsx(PageHeader, { title: "Banc de test", description: "Rejoue le graphe sans jamais agir sur un vrai ticket (\xA70)." }),
5384
+ !canRun ? /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(TestControls, {})
4931
5385
  ] });
4932
5386
  }
4933
5387