@apotech-os/support-kit 10.3.0 → 10.4.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
@@ -862,7 +862,7 @@ function dayLabel(day) {
862
862
  return Number.isNaN(parsed.getTime()) ? day : parsed.toLocaleDateString("fr-FR", { day: "2-digit", month: "2-digit", timeZone: "UTC" });
863
863
  }
864
864
  function DashboardPage() {
865
- const { appSlug } = uiSdk.useAppContext();
865
+ const pageHref = uiSdk.useAppPageHref();
866
866
  const [period, setPeriod] = react.useState(() => defaultPeriod());
867
867
  const { settings } = uiSdk.useAppSettings();
868
868
  const timezone = settings?.statsTimezone ?? "UTC";
@@ -964,7 +964,7 @@ function DashboardPage() {
964
964
  align: "end"
965
965
  }
966
966
  ),
967
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: `/espace/${appSlug}/tickets`, children: "Voir tous les tickets" })
967
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: pageHref("tickets"), children: "Voir tous les tickets" })
968
968
  ] })
969
969
  }
970
970
  ),
@@ -3370,13 +3370,13 @@ function applyPreset(value, preset, restore) {
3370
3370
  }
3371
3371
 
3372
3372
  // src/ui/shared/quality-href.ts
3373
- function qualityHref(appSlug, agent) {
3374
- const base2 = `/espace/${appSlug}/quality`;
3375
- if (!agent) return base2;
3376
- const params = new URLSearchParams({ promptName: agent.promptName });
3377
- if (agent.promptVersion !== null) params.set("promptVersion", String(agent.promptVersion));
3378
- params.set("agentId", agent.id);
3379
- return `${base2}?${params.toString()}`;
3373
+ function qualityHref(pageHref, agent) {
3374
+ if (!agent) return pageHref("quality");
3375
+ return pageHref("quality", {
3376
+ promptName: agent.promptName,
3377
+ promptVersion: agent.promptVersion,
3378
+ agentId: agent.id
3379
+ });
3380
3380
  }
3381
3381
  function usePromptCatalogue() {
3382
3382
  const { appSlug } = uiSdk.useAppContext();
@@ -3958,7 +3958,7 @@ function AgentFormPanel({
3958
3958
  );
3959
3959
  }
3960
3960
  function PromptVersionsSection({ agent, canWrite }) {
3961
- const { appSlug } = uiSdk.useAppContext();
3961
+ const pageHref = uiSdk.useAppPageHref();
3962
3962
  const { versions, error, refresh, promote, deleteVersion, createVersion } = usePromptVersions(
3963
3963
  agent.promptName
3964
3964
  );
@@ -4047,7 +4047,7 @@ function PromptVersionsSection({ agent, canWrite }) {
4047
4047
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4048
4048
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
4049
4049
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
4050
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: qualityHref(appSlug, agent), children: "Voir dans Qualit\xE9" }),
4050
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: qualityHref(pageHref, agent), children: "Voir dans Qualit\xE9" }),
4051
4051
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
4052
4052
  versions.length >= 2 && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: openCompare, children: "Comparer" }),
4053
4053
  canWrite && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: () => void suggest(), disabled: isSuggesting, children: isSuggesting ? "Suggestion en cours\u2026" : "Sugg\xE9rer une am\xE9lioration" })
@@ -5543,7 +5543,10 @@ var WHATSAPP_MODE_LABELS = {
5543
5543
  draft_only: "Brouillon uniquement",
5544
5544
  auto_reply: "R\xE9ponse automatique"
5545
5545
  };
5546
- var WHATSAPP_MODE_OPTIONS = WHATSAPP_MODES.map((value) => ({ value, label: WHATSAPP_MODE_LABELS[value] }));
5546
+ var WHATSAPP_MODE_OPTIONS = WHATSAPP_MODES.map((value) => ({
5547
+ value,
5548
+ label: WHATSAPP_MODE_LABELS[value]
5549
+ }));
5547
5550
  function field(value) {
5548
5551
  return typeof value === "string" ? value : "";
5549
5552
  }
@@ -5562,7 +5565,10 @@ function parseList(value) {
5562
5565
  function describeConnection(connections) {
5563
5566
  if (connections === void 0) return { text: "Chargement\u2026", tone: "muted" };
5564
5567
  if (connections === null) {
5565
- return { text: "Ind\xE9termin\xE9e \u2014 les connexions de l\u2019instance n\u2019ont pas pu \xEAtre lues.", tone: "muted" };
5568
+ return {
5569
+ text: "Ind\xE9termin\xE9e \u2014 les connexions de l\u2019instance n\u2019ont pas pu \xEAtre lues.",
5570
+ tone: "muted"
5571
+ };
5566
5572
  }
5567
5573
  if (connections.length === 0) {
5568
5574
  return {
@@ -5579,13 +5585,17 @@ function describeConnection(connections) {
5579
5585
  tone: "error"
5580
5586
  };
5581
5587
  }
5582
- return { text: `${fallback.label} (par d\xE9faut, parmi ${connections.length} connexions)`, tone: "normal" };
5588
+ return {
5589
+ text: `${fallback.label} (par d\xE9faut, parmi ${connections.length} connexions)`,
5590
+ tone: "normal"
5591
+ };
5583
5592
  }
5584
5593
  function SettingsWarnings({ warnings }) {
5585
5594
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: warnings.map((warning) => /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-status-pending", children: warning.message }, warning.key)) });
5586
5595
  }
5587
5596
  function SettingsPage() {
5588
5597
  const { appSlug, role } = uiSdk.useAppContext();
5598
+ const pageHref = uiSdk.useAppPageHref();
5589
5599
  const canWrite = canWriteForRole(role);
5590
5600
  const api = uiSdk.useAppApi();
5591
5601
  const toast = uiSdk.useToast();
@@ -5608,7 +5618,12 @@ function SettingsPage() {
5608
5618
  react.useEffect(() => {
5609
5619
  if (wasSavingRef.current && !isSaving) {
5610
5620
  if (saveError === void 0) toast({ title: "R\xE9glages enregistr\xE9s.", variant: "success" });
5611
- else toast({ title: "\xC9chec de l'enregistrement", description: describeApiError(saveError), variant: "error" });
5621
+ else
5622
+ toast({
5623
+ title: "\xC9chec de l'enregistrement",
5624
+ description: describeApiError(saveError),
5625
+ variant: "error"
5626
+ });
5612
5627
  }
5613
5628
  wasSavingRef.current = isSaving;
5614
5629
  }, [isSaving, saveError, toast]);
@@ -5619,7 +5634,9 @@ function SettingsPage() {
5619
5634
  (async () => {
5620
5635
  let checkAppSlugs = [];
5621
5636
  try {
5622
- const installed = await apiRef.current.get("/platform/apps/installed");
5637
+ const installed = await apiRef.current.get(
5638
+ "/platform/apps/installed"
5639
+ );
5623
5640
  checkAppSlugs = installed.apps.map((a) => a.slug).filter((slug) => slug !== appSlug);
5624
5641
  if (!cancelled) setInstalledAppsUnavailable(false);
5625
5642
  } catch {
@@ -5627,7 +5644,9 @@ function SettingsPage() {
5627
5644
  if (!cancelled) setInstalledAppsUnavailable(true);
5628
5645
  }
5629
5646
  try {
5630
- const result = await apiRef.current.invoke("list-gorgias-views", { checkAppSlugs });
5647
+ const result = await apiRef.current.invoke("list-gorgias-views", {
5648
+ checkAppSlugs
5649
+ });
5631
5650
  if (!cancelled) {
5632
5651
  setViews(result.views);
5633
5652
  setUncheckedAppSlugs(result.uncheckedAppSlugs);
@@ -5858,7 +5877,15 @@ function SettingsPage() {
5858
5877
  ["appScopeTag", "Tag des tickets de l'application"]
5859
5878
  ].map(([key, label]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5860
5879
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: key, className: "mb-1 block text-sm font-medium", children: label }),
5861
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Input, { id: key, value: field(form[key]), onChange: (e) => set(key, e.target.value), disabled: !canWrite })
5880
+ /* @__PURE__ */ jsxRuntime.jsx(
5881
+ uiSdk.Input,
5882
+ {
5883
+ id: key,
5884
+ value: field(form[key]),
5885
+ onChange: (e) => set(key, e.target.value),
5886
+ disabled: !canWrite
5887
+ }
5888
+ )
5862
5889
  ] }, key)),
5863
5890
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Le tag des tickets de l\u2019application est obligatoire. Il est pos\xE9 sur chaque ticket que le triage examine, et c\u2019est lui qui dit qu\u2019un ticket appartient \xE0 cette app : les r\xE9ponses aux messages suivants et l\u2019agent par d\xE9faut propos\xE9 dans l\u2019extension Gorgias s\u2019appuient dessus. Il doit \xEAtre propre \xE0 cette app, distinct de celui d\u2019une autre app install\xE9e sur le m\xEAme compte Gorgias." }),
5864
5891
  /* @__PURE__ */ jsxRuntime.jsx(SettingsWarnings, { warnings: tagWarnings })
@@ -6014,7 +6041,7 @@ function SettingsPage() {
6014
6041
  "Catalogue de prompts indisponible \u2014 ",
6015
6042
  describeApiError(promptCatalogue.error)
6016
6043
  ] }),
6017
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: `/espace/${appSlug}/graph-canvas`, children: "Visualiser dans Graphe" })
6044
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: pageHref("graph-canvas"), children: "Visualiser dans Graphe" })
6018
6045
  ] }) }),
6019
6046
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-3 p-4", children: [
6020
6047
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-medium", children: "Agents support" }),
@@ -7650,7 +7677,8 @@ function parseRunResult(result) {
7650
7677
  };
7651
7678
  }
7652
7679
  function describeRunDecision(result, mode) {
7653
- if (result.stoppedAt === "FC" && result.outcome === "no_reply_needed") return "Conversation finie \u2014 aucune r\xE9ponse.";
7680
+ if (result.stoppedAt === "FC" && result.outcome === "no_reply_needed")
7681
+ return "Conversation finie \u2014 aucune r\xE9ponse.";
7654
7682
  if (result.stoppedAt !== null) return `Arr\xEAt en ${result.stoppedAt}.`;
7655
7683
  const category = result.categoryName ? ` (cat\xE9gorie \xAB ${result.categoryName} \xBB)` : "";
7656
7684
  if (result.outcome === "sent") {
@@ -7662,6 +7690,7 @@ function describeRunDecision(result, mode) {
7662
7690
  function FollowupWebhookCard2() {
7663
7691
  const api = uiSdk.useAppApi();
7664
7692
  const { appSlug } = uiSdk.useAppContext();
7693
+ const pageHref = uiSdk.useAppPageHref();
7665
7694
  const toast = uiSdk.useToast();
7666
7695
  const ticketId = react.useId();
7667
7696
  const [ticket, setTicket] = react.useState("");
@@ -7691,7 +7720,9 @@ function FollowupWebhookCard2() {
7691
7720
  setIsTesting(true);
7692
7721
  setTest(null);
7693
7722
  try {
7694
- setTest(await api.invoke("test-gorgias-webhook", { ticketId: ticket.trim(), mode }));
7723
+ setTest(
7724
+ await api.invoke("test-gorgias-webhook", { ticketId: ticket.trim(), mode })
7725
+ );
7695
7726
  } catch (err) {
7696
7727
  toast({ title: "\xC9chec du test", description: describeInvokeError(err), variant: "error" });
7697
7728
  } finally {
@@ -7719,9 +7750,36 @@ function FollowupWebhookCard2() {
7719
7750
  className: "max-w-48"
7720
7751
  }
7721
7752
  ),
7722
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { type: "button", variant: "outline", onClick: () => void runTest("diagnostic"), disabled, children: "Diagnostic" }),
7723
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { type: "button", variant: "outline", onClick: () => void runTest("generate"), disabled, children: "G\xE9n\xE9rer sans envoyer" }),
7724
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { type: "button", variant: "outline", onClick: () => setConfirmingRealRun(true), disabled, children: "Ex\xE9cution r\xE9elle" })
7753
+ /* @__PURE__ */ jsxRuntime.jsx(
7754
+ uiSdk.Button,
7755
+ {
7756
+ type: "button",
7757
+ variant: "outline",
7758
+ onClick: () => void runTest("diagnostic"),
7759
+ disabled,
7760
+ children: "Diagnostic"
7761
+ }
7762
+ ),
7763
+ /* @__PURE__ */ jsxRuntime.jsx(
7764
+ uiSdk.Button,
7765
+ {
7766
+ type: "button",
7767
+ variant: "outline",
7768
+ onClick: () => void runTest("generate"),
7769
+ disabled,
7770
+ children: "G\xE9n\xE9rer sans envoyer"
7771
+ }
7772
+ ),
7773
+ /* @__PURE__ */ jsxRuntime.jsx(
7774
+ uiSdk.Button,
7775
+ {
7776
+ type: "button",
7777
+ variant: "outline",
7778
+ onClick: () => setConfirmingRealRun(true),
7779
+ disabled,
7780
+ children: "Ex\xE9cution r\xE9elle"
7781
+ }
7782
+ )
7725
7783
  ] }),
7726
7784
  /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
7727
7785
  "Le diagnostic \xE9value les m\xEAmes conditions que le webhook, sans aucun effet de bord.",
@@ -7761,7 +7819,13 @@ function FollowupWebhookCard2() {
7761
7819
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "whitespace-pre-wrap rounded border bg-muted/30 p-2 text-xs", children: draftText })
7762
7820
  ] }),
7763
7821
  /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs", children: [
7764
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: `/espace/${appSlug}/tickets?ticket=${encodeURIComponent(runResult.ticketId ?? test.ticketId)}`, children: "Ouvrir la fiche du ticket" }),
7822
+ /* @__PURE__ */ jsxRuntime.jsx(
7823
+ uiSdk.Link,
7824
+ {
7825
+ href: pageHref("tickets", { ticket: runResult.ticketId ?? test.ticketId }),
7826
+ children: "Ouvrir la fiche du ticket"
7827
+ }
7828
+ ),
7765
7829
  runResult.ticketUrl !== null && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7766
7830
  " \xB7 ",
7767
7831
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: runResult.ticketUrl, target: "_blank", rel: "noopener noreferrer", children: "Ouvrir dans Gorgias" })
@@ -7782,8 +7846,7 @@ function FollowupWebhookCard2() {
7782
7846
  description: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7783
7847
  "Le ticket ",
7784
7848
  ticket.trim(),
7785
- " va \xEAtre trait\xE9 comme un vrai message suivant : g\xE9n\xE9ration, garde-fous, et",
7786
- " ",
7849
+ " va \xEAtre trait\xE9 comme un vrai message suivant : g\xE9n\xE9ration, garde-fous, et ",
7787
7850
  /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "envoi r\xE9el au client" }),
7788
7851
  " si sa cat\xE9gorie est en r\xE9ponse automatique. Pour tout voir sans rien envoyer, utilisez \xAB G\xE9n\xE9rer sans envoyer \xBB."
7789
7852
  ] }),