@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.cjs CHANGED
@@ -1766,7 +1766,7 @@ function stepBoolean(step, field2, fallback) {
1766
1766
  return typeof value === "boolean" ? value : fallback;
1767
1767
  }
1768
1768
  function stepUsesAgentPrompt(key) {
1769
- return key === "draft";
1769
+ return key === "draft" || key === "revise";
1770
1770
  }
1771
1771
  var DEFAULT_PROMPT_LABEL = "production";
1772
1772
  function stepPromptName(step) {
@@ -1794,51 +1794,11 @@ var REASONING_EFFORTS = [
1794
1794
  { value: "medium", label: "Moyen" },
1795
1795
  { value: "high", label: "Pouss\xE9" }
1796
1796
  ];
1797
- var KNOWN_MODELS = [
1798
- {
1799
- provider: "openai",
1800
- model: "gpt-4o-mini",
1801
- label: "GPT-4o mini",
1802
- hint: "Le moins cher, tr\xE8s rapide \u2014 suffisant pour classer"
1803
- },
1804
- {
1805
- provider: "openai",
1806
- model: "gpt-5-mini",
1807
- label: "GPT-5 mini",
1808
- hint: "Rapide, bon march\xE9, meilleur raisonnement"
1809
- },
1810
- {
1811
- provider: "openai",
1812
- model: "gpt-4.1",
1813
- label: "GPT-4.1",
1814
- hint: "Co\xFBt moyen \u2014 r\xE9daction soign\xE9e"
1815
- },
1816
- {
1817
- provider: "openai",
1818
- model: "gpt-5",
1819
- label: "GPT-5",
1820
- hint: "Le plus capable \u2014 le plus lent et le plus cher"
1821
- },
1822
- {
1823
- provider: "anthropic",
1824
- model: "claude-3-5-haiku-latest",
1825
- label: "Claude 3.5 Haiku",
1826
- hint: "Rapide et bon march\xE9"
1827
- },
1828
- {
1829
- provider: "anthropic",
1830
- model: "claude-3-5-sonnet-latest",
1831
- label: "Claude 3.5 Sonnet",
1832
- hint: "Co\xFBt moyen \u2014 r\xE9daction soign\xE9e"
1833
- }
1834
- ];
1835
1797
  var CUSTOM_MODEL_VALUE = "__custom__";
1836
- function findModelOption(model) {
1837
- return KNOWN_MODELS.find((option) => option.model === model);
1838
- }
1798
+ var DEFAULT_STEP_MODEL = "gpt-4o-mini";
1799
+ var DEFAULT_STEP_PROVIDER = "openai";
1839
1800
  function defaultStep() {
1840
- const [first] = KNOWN_MODELS;
1841
- return { model: first.model, provider: first.provider, reasoning: "off" };
1801
+ return { model: DEFAULT_STEP_MODEL, provider: DEFAULT_STEP_PROVIDER, reasoning: "off" };
1842
1802
  }
1843
1803
  var PIPELINE_PRESETS = [
1844
1804
  {
@@ -1893,6 +1853,36 @@ function usePromptCatalogue() {
1893
1853
  }, [appSlug]);
1894
1854
  return { prompts, isLoading, error };
1895
1855
  }
1856
+ function useModelCatalogue() {
1857
+ const api = uiSdk.useAppApi();
1858
+ const [models, setModels] = react.useState([]);
1859
+ const [isLoading, setIsLoading] = react.useState(true);
1860
+ const [error, setError] = react.useState(void 0);
1861
+ const clientRef = react.useRef(api);
1862
+ clientRef.current = api;
1863
+ const requestIdRef = react.useRef(0);
1864
+ const isMountedRef = react.useRef(true);
1865
+ react.useEffect(() => {
1866
+ isMountedRef.current = true;
1867
+ const requestId = ++requestIdRef.current;
1868
+ setIsLoading(true);
1869
+ void clientRef.current.get("/data/llm/models").then((catalogue) => {
1870
+ if (requestId !== requestIdRef.current || !isMountedRef.current) return;
1871
+ setModels(catalogue.models);
1872
+ setError(void 0);
1873
+ }).catch((err) => {
1874
+ if (requestId !== requestIdRef.current || !isMountedRef.current) return;
1875
+ setError(err);
1876
+ }).finally(() => {
1877
+ if (requestId !== requestIdRef.current || !isMountedRef.current) return;
1878
+ setIsLoading(false);
1879
+ });
1880
+ return () => {
1881
+ isMountedRef.current = false;
1882
+ };
1883
+ }, []);
1884
+ return { models, isLoading, error };
1885
+ }
1896
1886
  function ConfirmModal({
1897
1887
  title,
1898
1888
  description,
@@ -2138,8 +2128,9 @@ function AgentFormModal({
2138
2128
  const providerInputId = react.useId();
2139
2129
  const promptInputId = react.useId();
2140
2130
  const snapshotId = react.useId();
2141
- const knownModel = findModelOption(form.modelId);
2142
- const showModelFreeText = freeTextModel || form.modelId !== "" && !knownModel;
2131
+ const { models, isLoading: modelsLoading } = useModelCatalogue();
2132
+ const knownModel = models.includes(form.modelId);
2133
+ const showModelFreeText = freeTextModel || form.modelId !== "" && !knownModel && !modelsLoading;
2143
2134
  const knownPrompt = prompts.find((entry) => entry.name === form.promptName);
2144
2135
  const showPromptFreeText = freeTextPrompt || agent !== "new" && form.promptName !== "" && !knownPrompt && !promptsLoading;
2145
2136
  const promptLabels = knownPrompt?.labels ?? [];
@@ -2194,24 +2185,20 @@ function AgentFormModal({
2194
2185
  uiSdk.Select,
2195
2186
  {
2196
2187
  "aria-label": "Mod\xE8le",
2197
- value: showModelFreeText ? CUSTOM_MODEL_VALUE : knownModel?.model ?? void 0,
2188
+ value: showModelFreeText ? CUSTOM_MODEL_VALUE : knownModel ? form.modelId : void 0,
2198
2189
  onValueChange: (next) => {
2199
2190
  if (next === CUSTOM_MODEL_VALUE) {
2200
2191
  setFreeTextModel(true);
2201
2192
  return;
2202
2193
  }
2203
2194
  setFreeTextModel(false);
2204
- const option = findModelOption(next);
2205
- if (!option) return;
2206
- setForm({ ...form, modelId: option.model, provider: option.provider });
2195
+ setForm({ ...form, modelId: next, provider: DEFAULT_STEP_PROVIDER });
2207
2196
  },
2208
2197
  items: [
2209
- ...KNOWN_MODELS.map((option) => ({
2210
- value: option.model,
2211
- label: `${option.label} \u2014 ${option.hint}`
2212
- })),
2198
+ ...models.map((name) => ({ value: name, label: name })),
2213
2199
  { value: CUSTOM_MODEL_VALUE, label: "Autre \u2014 saisir un identifiant de mod\xE8le" }
2214
- ]
2200
+ ],
2201
+ disabled: modelsLoading
2215
2202
  }
2216
2203
  ),
2217
2204
  showModelFreeText && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 space-y-2", children: [
@@ -3682,7 +3669,7 @@ function validateSettings(settings) {
3682
3669
  function isNonEmptyString(value) {
3683
3670
  return typeof value === "string" && value.length > 0;
3684
3671
  }
3685
- var STEPS_REQUIRING_PROMPT = ["triage", "escalate", "evaluate", "revise"];
3672
+ var STEPS_REQUIRING_PROMPT = ["triage", "escalate", "evaluate"];
3686
3673
  function stepsMissingPrompt(nodes) {
3687
3674
  if (typeof nodes !== "object" || nodes === null) return [];
3688
3675
  const byStep = nodes;
@@ -3838,7 +3825,9 @@ function PipelineNodesForm({
3838
3825
  canWrite,
3839
3826
  issueMessage,
3840
3827
  prompts,
3841
- promptsLoading = false
3828
+ promptsLoading = false,
3829
+ models,
3830
+ modelsLoading = false
3842
3831
  }) {
3843
3832
  const [remembered, setRemembered] = react.useState({});
3844
3833
  react.useEffect(() => {
@@ -3886,6 +3875,8 @@ function PipelineNodesForm({
3886
3875
  issueMessage: step.key === "triage" ? issueMessage : null,
3887
3876
  prompts,
3888
3877
  promptsLoading,
3878
+ models,
3879
+ modelsLoading,
3889
3880
  onToggle: (on) => toggleStep(step.key, on),
3890
3881
  onPatch: (patch) => onChange(withStepFields(value, step.key, patch))
3891
3882
  },
@@ -3900,6 +3891,8 @@ function StepRow({
3900
3891
  issueMessage,
3901
3892
  prompts,
3902
3893
  promptsLoading,
3894
+ models,
3895
+ modelsLoading,
3903
3896
  onToggle,
3904
3897
  onPatch
3905
3898
  }) {
@@ -3953,6 +3946,8 @@ function StepRow({
3953
3946
  step,
3954
3947
  settings: readStep(value, step.key),
3955
3948
  disabled: !canWrite || blockedReason !== null,
3949
+ models,
3950
+ modelsLoading,
3956
3951
  onPatch
3957
3952
  }
3958
3953
  ) })
@@ -3963,12 +3958,14 @@ function StepOptions({
3963
3958
  step,
3964
3959
  settings,
3965
3960
  disabled,
3961
+ models,
3962
+ modelsLoading,
3966
3963
  onPatch
3967
3964
  }) {
3968
3965
  const model = stepString(settings, "model");
3969
- const known = findModelOption(model);
3966
+ const known = models.includes(model);
3970
3967
  const [freeText, setFreeText] = react.useState(false);
3971
- const showFreeText = freeText || model !== "" && !known;
3968
+ const showFreeText = freeText || model !== "" && !known && !modelsLoading;
3972
3969
  const ids = useIds(step.key);
3973
3970
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3974
3971
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
@@ -3977,25 +3974,20 @@ function StepOptions({
3977
3974
  uiSdk.Select,
3978
3975
  {
3979
3976
  "aria-label": `Mod\xE8le \u2014 ${step.label}`,
3980
- value: showFreeText ? CUSTOM_MODEL_VALUE : known?.model ?? void 0,
3977
+ value: showFreeText ? CUSTOM_MODEL_VALUE : known ? model : void 0,
3981
3978
  onValueChange: (next) => {
3982
3979
  if (next === CUSTOM_MODEL_VALUE) {
3983
3980
  setFreeText(true);
3984
3981
  return;
3985
3982
  }
3986
3983
  setFreeText(false);
3987
- const option = findModelOption(next);
3988
- if (!option) return;
3989
- onPatch({ model: option.model, provider: option.provider });
3984
+ onPatch({ model: next, provider: DEFAULT_STEP_PROVIDER });
3990
3985
  },
3991
3986
  items: [
3992
- ...KNOWN_MODELS.map((option) => ({
3993
- value: option.model,
3994
- label: `${option.label} \u2014 ${option.hint}`
3995
- })),
3987
+ ...models.map((name) => ({ value: name, label: name })),
3996
3988
  { value: CUSTOM_MODEL_VALUE, label: "Autre \u2014 saisir un identifiant de mod\xE8le" }
3997
3989
  ],
3998
- disabled
3990
+ disabled: disabled || modelsLoading
3999
3991
  }
4000
3992
  ),
4001
3993
  showFreeText && // The provider travels WITH the model: a free-text id typed after a
@@ -4093,7 +4085,7 @@ function StepPromptField({
4093
4085
  onPatch
4094
4086
  }) {
4095
4087
  if (stepUsesAgentPrompt(step.key)) {
4096
- return /* @__PURE__ */ jsxRuntime.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." });
4088
+ return /* @__PURE__ */ jsxRuntime.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." });
4097
4089
  }
4098
4090
  const name = stepPromptName(settings);
4099
4091
  const label = stepPromptLabel(settings);
@@ -4205,6 +4197,7 @@ function SettingsPage() {
4205
4197
  const [installedAppsUnavailable, setInstalledAppsUnavailable] = react.useState(false);
4206
4198
  const [connections, setConnections] = react.useState(void 0);
4207
4199
  const promptCatalogue = usePromptCatalogue();
4200
+ const modelCatalogue = useModelCatalogue();
4208
4201
  const formInitializedRef = react.useRef(false);
4209
4202
  react.useEffect(() => {
4210
4203
  if (settings && !formInitializedRef.current) {
@@ -4581,9 +4574,15 @@ function SettingsPage() {
4581
4574
  canWrite,
4582
4575
  issueMessage: nodesIssue ? settingsIssueLabel(nodesIssue.key, nodesIssue.message) : null,
4583
4576
  prompts: promptCatalogue.prompts,
4584
- promptsLoading: promptCatalogue.isLoading
4577
+ promptsLoading: promptCatalogue.isLoading,
4578
+ models: modelCatalogue.models,
4579
+ modelsLoading: modelCatalogue.isLoading
4585
4580
  }
4586
4581
  ),
4582
+ modelCatalogue.error !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-destructive", children: [
4583
+ "Liste des mod\xE8les indisponible \u2014 ",
4584
+ describeApiError(modelCatalogue.error)
4585
+ ] }),
4587
4586
  promptCatalogue.error !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-destructive", children: [
4588
4587
  "Catalogue de prompts indisponible \u2014 ",
4589
4588
  describeApiError(promptCatalogue.error)
@@ -4623,7 +4622,7 @@ function hasNoDraftNode(profile) {
4623
4622
  // src/ui/graph-canvas/reachability.ts
4624
4623
  function stubPrompts() {
4625
4624
  const ref = { name: "", label: "production" };
4626
- return { triage: ref, escalate: ref, draft: ref, evaluate: ref, revise: ref };
4625
+ return { triage: ref, escalate: ref, draft: ref, evaluate: ref };
4627
4626
  }
4628
4627
  var PROMPT_403_NODES = /* @__PURE__ */ new Set(["triage", "escalate", "draft", "evaluate", "revise"]);
4629
4628
  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.";