@apotech-os/support-kit 2.10.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { GENERATED_RESPONSE_STATUSES, EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, toTriageDecision, toAgent, toGeneratedResponse, isGeneratedResponseStatus, toCategoryGroup, toResponseComparison, toDiffAnalysis, NODE_NAMES, settingsToProfile, hasNoDraftNode, guardrailBucket, DEFAULT_LLM_PROVIDER, computeWordDiff, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-CVYJU4SV.js';
1
+ import { GENERATED_RESPONSE_STATUSES, EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, toTriageDecision, toAgent, toGeneratedResponse, isGeneratedResponseStatus, toCategoryGroup, toResponseComparison, toDiffAnalysis, NODE_NAMES, settingsToProfile, hasNoDraftNode, guardrailBucket, DEFAULT_LLM_PROVIDER, computeWordDiff, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-KCPVWKUY.js';
2
2
  import { useState, useMemo, useRef, useEffect, useCallback, useId } from 'react';
3
3
  import { useAppContext, useAppSettings, Card, CardContent, Button, Link, KpiCard, BarChart, StackedBarChart, DataTable, Select, useAppApi, useToast, Badge, FunnelChart, Spinner, LineChart, Input, Switch, Checkbox, Textarea, cn, SidePanel, CopyButton, Modal, Tooltip, AppInvokeError } from '@apotech-os/ui-sdk';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
@@ -1484,7 +1484,7 @@ function stepBoolean(step, field2, fallback) {
1484
1484
  return typeof value === "boolean" ? value : fallback;
1485
1485
  }
1486
1486
  function stepUsesAgentPrompt(key) {
1487
- return key === "draft";
1487
+ return key === "draft" || key === "revise";
1488
1488
  }
1489
1489
  var DEFAULT_PROMPT_LABEL = "production";
1490
1490
  function stepPromptName(step) {
@@ -1512,51 +1512,11 @@ var REASONING_EFFORTS = [
1512
1512
  { value: "medium", label: "Moyen" },
1513
1513
  { value: "high", label: "Pouss\xE9" }
1514
1514
  ];
1515
- var KNOWN_MODELS = [
1516
- {
1517
- provider: "openai",
1518
- model: "gpt-4o-mini",
1519
- label: "GPT-4o mini",
1520
- hint: "Le moins cher, tr\xE8s rapide \u2014 suffisant pour classer"
1521
- },
1522
- {
1523
- provider: "openai",
1524
- model: "gpt-5-mini",
1525
- label: "GPT-5 mini",
1526
- hint: "Rapide, bon march\xE9, meilleur raisonnement"
1527
- },
1528
- {
1529
- provider: "openai",
1530
- model: "gpt-4.1",
1531
- label: "GPT-4.1",
1532
- hint: "Co\xFBt moyen \u2014 r\xE9daction soign\xE9e"
1533
- },
1534
- {
1535
- provider: "openai",
1536
- model: "gpt-5",
1537
- label: "GPT-5",
1538
- hint: "Le plus capable \u2014 le plus lent et le plus cher"
1539
- },
1540
- {
1541
- provider: "anthropic",
1542
- model: "claude-3-5-haiku-latest",
1543
- label: "Claude 3.5 Haiku",
1544
- hint: "Rapide et bon march\xE9"
1545
- },
1546
- {
1547
- provider: "anthropic",
1548
- model: "claude-3-5-sonnet-latest",
1549
- label: "Claude 3.5 Sonnet",
1550
- hint: "Co\xFBt moyen \u2014 r\xE9daction soign\xE9e"
1551
- }
1552
- ];
1553
1515
  var CUSTOM_MODEL_VALUE = "__custom__";
1554
- function findModelOption(model) {
1555
- return KNOWN_MODELS.find((option) => option.model === model);
1556
- }
1516
+ var DEFAULT_STEP_MODEL = "gpt-4o-mini";
1517
+ var DEFAULT_STEP_PROVIDER = "openai";
1557
1518
  function defaultStep() {
1558
- const [first] = KNOWN_MODELS;
1559
- return { model: first.model, provider: first.provider, reasoning: "off" };
1519
+ return { model: DEFAULT_STEP_MODEL, provider: DEFAULT_STEP_PROVIDER, reasoning: "off" };
1560
1520
  }
1561
1521
  var PIPELINE_PRESETS = [
1562
1522
  {
@@ -1611,6 +1571,36 @@ function usePromptCatalogue() {
1611
1571
  }, [appSlug]);
1612
1572
  return { prompts, isLoading, error };
1613
1573
  }
1574
+ function useModelCatalogue() {
1575
+ const api = useAppApi();
1576
+ const [models, setModels] = useState([]);
1577
+ const [isLoading, setIsLoading] = useState(true);
1578
+ const [error, setError] = useState(void 0);
1579
+ const clientRef = useRef(api);
1580
+ clientRef.current = api;
1581
+ const requestIdRef = useRef(0);
1582
+ const isMountedRef = useRef(true);
1583
+ useEffect(() => {
1584
+ isMountedRef.current = true;
1585
+ const requestId = ++requestIdRef.current;
1586
+ setIsLoading(true);
1587
+ void clientRef.current.get("/data/llm/models").then((catalogue) => {
1588
+ if (requestId !== requestIdRef.current || !isMountedRef.current) return;
1589
+ setModels(catalogue.models);
1590
+ setError(void 0);
1591
+ }).catch((err) => {
1592
+ if (requestId !== requestIdRef.current || !isMountedRef.current) return;
1593
+ setError(err);
1594
+ }).finally(() => {
1595
+ if (requestId !== requestIdRef.current || !isMountedRef.current) return;
1596
+ setIsLoading(false);
1597
+ });
1598
+ return () => {
1599
+ isMountedRef.current = false;
1600
+ };
1601
+ }, []);
1602
+ return { models, isLoading, error };
1603
+ }
1614
1604
  function ConfirmModal({
1615
1605
  title,
1616
1606
  description,
@@ -1822,8 +1812,9 @@ function AgentFormModal({
1822
1812
  const providerInputId = useId();
1823
1813
  const promptInputId = useId();
1824
1814
  const snapshotId = useId();
1825
- const knownModel = findModelOption(form.modelId);
1826
- const showModelFreeText = freeTextModel || form.modelId !== "" && !knownModel;
1815
+ const { models, isLoading: modelsLoading } = useModelCatalogue();
1816
+ const knownModel = models.includes(form.modelId);
1817
+ const showModelFreeText = freeTextModel || form.modelId !== "" && !knownModel && !modelsLoading;
1827
1818
  const knownPrompt = prompts.find((entry) => entry.name === form.promptName);
1828
1819
  const showPromptFreeText = freeTextPrompt || agent !== "new" && form.promptName !== "" && !knownPrompt && !promptsLoading;
1829
1820
  const promptLabels = knownPrompt?.labels ?? [];
@@ -1878,24 +1869,20 @@ function AgentFormModal({
1878
1869
  Select,
1879
1870
  {
1880
1871
  "aria-label": "Mod\xE8le",
1881
- value: showModelFreeText ? CUSTOM_MODEL_VALUE : knownModel?.model ?? void 0,
1872
+ value: showModelFreeText ? CUSTOM_MODEL_VALUE : knownModel ? form.modelId : void 0,
1882
1873
  onValueChange: (next) => {
1883
1874
  if (next === CUSTOM_MODEL_VALUE) {
1884
1875
  setFreeTextModel(true);
1885
1876
  return;
1886
1877
  }
1887
1878
  setFreeTextModel(false);
1888
- const option = findModelOption(next);
1889
- if (!option) return;
1890
- setForm({ ...form, modelId: option.model, provider: option.provider });
1879
+ setForm({ ...form, modelId: next, provider: DEFAULT_STEP_PROVIDER });
1891
1880
  },
1892
1881
  items: [
1893
- ...KNOWN_MODELS.map((option) => ({
1894
- value: option.model,
1895
- label: `${option.label} \u2014 ${option.hint}`
1896
- })),
1882
+ ...models.map((name) => ({ value: name, label: name })),
1897
1883
  { value: CUSTOM_MODEL_VALUE, label: "Autre \u2014 saisir un identifiant de mod\xE8le" }
1898
- ]
1884
+ ],
1885
+ disabled: modelsLoading
1899
1886
  }
1900
1887
  ),
1901
1888
  showModelFreeText && /* @__PURE__ */ jsxs("div", { className: "mt-2 space-y-2", children: [
@@ -3362,7 +3349,9 @@ function PipelineNodesForm({
3362
3349
  canWrite,
3363
3350
  issueMessage,
3364
3351
  prompts,
3365
- promptsLoading = false
3352
+ promptsLoading = false,
3353
+ models,
3354
+ modelsLoading = false
3366
3355
  }) {
3367
3356
  const [remembered, setRemembered] = useState({});
3368
3357
  useEffect(() => {
@@ -3410,6 +3399,8 @@ function PipelineNodesForm({
3410
3399
  issueMessage: step.key === "triage" ? issueMessage : null,
3411
3400
  prompts,
3412
3401
  promptsLoading,
3402
+ models,
3403
+ modelsLoading,
3413
3404
  onToggle: (on) => toggleStep(step.key, on),
3414
3405
  onPatch: (patch) => onChange(withStepFields(value, step.key, patch))
3415
3406
  },
@@ -3424,6 +3415,8 @@ function StepRow({
3424
3415
  issueMessage,
3425
3416
  prompts,
3426
3417
  promptsLoading,
3418
+ models,
3419
+ modelsLoading,
3427
3420
  onToggle,
3428
3421
  onPatch
3429
3422
  }) {
@@ -3477,6 +3470,8 @@ function StepRow({
3477
3470
  step,
3478
3471
  settings: readStep(value, step.key),
3479
3472
  disabled: !canWrite || blockedReason !== null,
3473
+ models,
3474
+ modelsLoading,
3480
3475
  onPatch
3481
3476
  }
3482
3477
  ) })
@@ -3487,12 +3482,14 @@ function StepOptions({
3487
3482
  step,
3488
3483
  settings,
3489
3484
  disabled,
3485
+ models,
3486
+ modelsLoading,
3490
3487
  onPatch
3491
3488
  }) {
3492
3489
  const model = stepString(settings, "model");
3493
- const known = findModelOption(model);
3490
+ const known = models.includes(model);
3494
3491
  const [freeText, setFreeText] = useState(false);
3495
- const showFreeText = freeText || model !== "" && !known;
3492
+ const showFreeText = freeText || model !== "" && !known && !modelsLoading;
3496
3493
  const ids = useIds(step.key);
3497
3494
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3498
3495
  /* @__PURE__ */ jsxs("div", { children: [
@@ -3501,25 +3498,20 @@ function StepOptions({
3501
3498
  Select,
3502
3499
  {
3503
3500
  "aria-label": `Mod\xE8le \u2014 ${step.label}`,
3504
- value: showFreeText ? CUSTOM_MODEL_VALUE : known?.model ?? void 0,
3501
+ value: showFreeText ? CUSTOM_MODEL_VALUE : known ? model : void 0,
3505
3502
  onValueChange: (next) => {
3506
3503
  if (next === CUSTOM_MODEL_VALUE) {
3507
3504
  setFreeText(true);
3508
3505
  return;
3509
3506
  }
3510
3507
  setFreeText(false);
3511
- const option = findModelOption(next);
3512
- if (!option) return;
3513
- onPatch({ model: option.model, provider: option.provider });
3508
+ onPatch({ model: next, provider: DEFAULT_STEP_PROVIDER });
3514
3509
  },
3515
3510
  items: [
3516
- ...KNOWN_MODELS.map((option) => ({
3517
- value: option.model,
3518
- label: `${option.label} \u2014 ${option.hint}`
3519
- })),
3511
+ ...models.map((name) => ({ value: name, label: name })),
3520
3512
  { value: CUSTOM_MODEL_VALUE, label: "Autre \u2014 saisir un identifiant de mod\xE8le" }
3521
3513
  ],
3522
- disabled
3514
+ disabled: disabled || modelsLoading
3523
3515
  }
3524
3516
  ),
3525
3517
  showFreeText && // The provider travels WITH the model: a free-text id typed after a
@@ -3617,7 +3609,7 @@ function StepPromptField({
3617
3609
  onPatch
3618
3610
  }) {
3619
3611
  if (stepUsesAgentPrompt(step.key)) {
3620
- return /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Le prompt de cette \xE9tape est celui de l'agent qui r\xE9dige \u2014 il se choisit sur la page Agents." });
3612
+ return /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: step.key === "revise" ? "Cette \xE9tape relance l'agent qui r\xE9dige avec l'objection du relecteur \u2014 elle n'a pas de prompt \xE0 choisir." : "Le prompt de cette \xE9tape est celui de l'agent qui r\xE9dige \u2014 il se choisit sur la page Agents." });
3621
3613
  }
3622
3614
  const name = stepPromptName(settings);
3623
3615
  const label = stepPromptLabel(settings);
@@ -3729,6 +3721,7 @@ function SettingsPage() {
3729
3721
  const [installedAppsUnavailable, setInstalledAppsUnavailable] = useState(false);
3730
3722
  const [connections, setConnections] = useState(void 0);
3731
3723
  const promptCatalogue = usePromptCatalogue();
3724
+ const modelCatalogue = useModelCatalogue();
3732
3725
  const formInitializedRef = useRef(false);
3733
3726
  useEffect(() => {
3734
3727
  if (settings && !formInitializedRef.current) {
@@ -4105,9 +4098,15 @@ function SettingsPage() {
4105
4098
  canWrite,
4106
4099
  issueMessage: nodesIssue ? settingsIssueLabel(nodesIssue.key, nodesIssue.message) : null,
4107
4100
  prompts: promptCatalogue.prompts,
4108
- promptsLoading: promptCatalogue.isLoading
4101
+ promptsLoading: promptCatalogue.isLoading,
4102
+ models: modelCatalogue.models,
4103
+ modelsLoading: modelCatalogue.isLoading
4109
4104
  }
4110
4105
  ),
4106
+ modelCatalogue.error !== void 0 && /* @__PURE__ */ jsxs("p", { className: "text-sm text-destructive", children: [
4107
+ "Liste des mod\xE8les indisponible \u2014 ",
4108
+ describeApiError(modelCatalogue.error)
4109
+ ] }),
4111
4110
  promptCatalogue.error !== void 0 && /* @__PURE__ */ jsxs("p", { className: "text-sm text-destructive", children: [
4112
4111
  "Catalogue de prompts indisponible \u2014 ",
4113
4112
  describeApiError(promptCatalogue.error)
@@ -4129,7 +4128,7 @@ function SettingsPage() {
4129
4128
  // src/ui/graph-canvas/reachability.ts
4130
4129
  function stubPrompts() {
4131
4130
  const ref = { name: "", label: "production" };
4132
- return { triage: ref, escalate: ref, draft: ref, evaluate: ref, revise: ref };
4131
+ return { triage: ref, escalate: ref, draft: ref, evaluate: ref };
4133
4132
  }
4134
4133
  var PROMPT_403_NODES = /* @__PURE__ */ new Set(["triage", "escalate", "draft", "evaluate", "revise"]);
4135
4134
  var PROMPT_403_NOTE = "promptRef est transmis \xE0 ctx.api.llm.complete, qui r\xE9pond 403 en production tant que manifest.prompts[] reste vide (d\xE9faut D-LF connu, non corrig\xE9 \u2014 voir le journal T24/T25) : ce n\u0153ud peut renvoyer PROMPT_NOT_DECLARED sur un d\xE9ploiement r\xE9el malgr\xE9 un r\xE9glage \xAB Actif \xBB ici.";