@apotech-os/support-kit 2.9.1 → 2.10.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/index.cjs +41 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +41 -19
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +536 -378
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +396 -238
- package/dist/ui/index.js.map +1 -1
- package/package.json +3 -3
package/dist/ui/index.cjs
CHANGED
|
@@ -1568,6 +1568,331 @@ function PipelinePage() {
|
|
|
1568
1568
|
)
|
|
1569
1569
|
] });
|
|
1570
1570
|
}
|
|
1571
|
+
var AGENT_FIELD_NAME_UID = "e9cfec6f-15c6-4d02-8f79-0667f64b9eb5";
|
|
1572
|
+
var AGENT_FIELD_PROVIDER_UID = "e522b809-e8a7-4439-a2df-936158d04389";
|
|
1573
|
+
var AGENT_FIELD_MODEL_ID_UID = "d95977ba-362c-44d6-a2f0-24156c76cf8a";
|
|
1574
|
+
var AGENT_FIELD_STATUS_UID = "348725a0-a896-4f8d-8a56-86f4193234a8";
|
|
1575
|
+
var AGENT_FIELD_DEFAULT_KEY_UID = "0134491a-c969-4c42-894c-36ad4880fed3";
|
|
1576
|
+
var AGENT_FIELD_PROMPT_NAME_UID = "32e7f234-00bb-44d2-917b-be28f32f7214";
|
|
1577
|
+
var AGENT_FIELD_PROMPT_LABEL_UID = "bdee53ff-571a-4df6-91ec-00b513a70fe0";
|
|
1578
|
+
var AGENT_FIELD_PROMPT_VERSION_UID = "e7c66f99-e1e0-4fc2-9f9e-3bafe3af8e88";
|
|
1579
|
+
var AGENT_FIELD_SYSTEM_PROMPT_SNAPSHOT_UID = "710b73c6-929b-48b7-abc0-792849adf1c2";
|
|
1580
|
+
var AGENT_FIELD_REASONING_EFFORT_UID = "aa57fc6e-c989-47d3-9fc8-e04184b1e67c";
|
|
1581
|
+
var AGENT_FIELD_MAX_TOOL_CALLS_UID = "6948a5ca-48ef-45d7-9118-c7ab195343a3";
|
|
1582
|
+
|
|
1583
|
+
// src/records/agent.ts
|
|
1584
|
+
var AGENT_STATUSES = ["default", "available", "archived"];
|
|
1585
|
+
var REASONING_EFFORT_OPTIONS = ["off", "low", "medium", "high"];
|
|
1586
|
+
var DEFAULT_LLM_PROVIDER = "openai";
|
|
1587
|
+
({
|
|
1588
|
+
fields: [
|
|
1589
|
+
{
|
|
1590
|
+
universalIdentifier: AGENT_FIELD_NAME_UID,
|
|
1591
|
+
name: "name",
|
|
1592
|
+
type: appKit.FieldType.TEXT,
|
|
1593
|
+
label: "Name",
|
|
1594
|
+
isNullable: false
|
|
1595
|
+
},
|
|
1596
|
+
{
|
|
1597
|
+
universalIdentifier: AGENT_FIELD_PROVIDER_UID,
|
|
1598
|
+
name: "provider",
|
|
1599
|
+
type: appKit.FieldType.TEXT,
|
|
1600
|
+
label: "Provider",
|
|
1601
|
+
description: "Free text (spec \xA73.4) \u2014 a new provider must not need a kit release.",
|
|
1602
|
+
isNullable: false,
|
|
1603
|
+
defaultValue: DEFAULT_LLM_PROVIDER
|
|
1604
|
+
},
|
|
1605
|
+
{
|
|
1606
|
+
universalIdentifier: AGENT_FIELD_MODEL_ID_UID,
|
|
1607
|
+
name: "modelId",
|
|
1608
|
+
type: appKit.FieldType.TEXT,
|
|
1609
|
+
label: "Model id",
|
|
1610
|
+
isNullable: false
|
|
1611
|
+
},
|
|
1612
|
+
{
|
|
1613
|
+
universalIdentifier: AGENT_FIELD_STATUS_UID,
|
|
1614
|
+
name: "status",
|
|
1615
|
+
type: appKit.FieldType.SELECT,
|
|
1616
|
+
label: "Status",
|
|
1617
|
+
isNullable: false,
|
|
1618
|
+
options: [...AGENT_STATUSES],
|
|
1619
|
+
defaultValue: "available"
|
|
1620
|
+
},
|
|
1621
|
+
{
|
|
1622
|
+
universalIdentifier: AGENT_FIELD_DEFAULT_KEY_UID,
|
|
1623
|
+
name: "defaultKey",
|
|
1624
|
+
type: appKit.FieldType.TEXT,
|
|
1625
|
+
label: "Default key",
|
|
1626
|
+
description: "Equals 'default' when status='default', absent otherwise. Unique.",
|
|
1627
|
+
isNullable: true
|
|
1628
|
+
},
|
|
1629
|
+
{
|
|
1630
|
+
universalIdentifier: AGENT_FIELD_PROMPT_NAME_UID,
|
|
1631
|
+
name: "promptName",
|
|
1632
|
+
type: appKit.FieldType.TEXT,
|
|
1633
|
+
label: "Prompt name",
|
|
1634
|
+
description: "Free Langfuse prompt name (ETL keeps legacy agent/<old id> names).",
|
|
1635
|
+
isNullable: false
|
|
1636
|
+
},
|
|
1637
|
+
{
|
|
1638
|
+
universalIdentifier: AGENT_FIELD_PROMPT_LABEL_UID,
|
|
1639
|
+
name: "promptLabel",
|
|
1640
|
+
type: appKit.FieldType.TEXT,
|
|
1641
|
+
label: "Prompt label",
|
|
1642
|
+
isNullable: true
|
|
1643
|
+
},
|
|
1644
|
+
{
|
|
1645
|
+
universalIdentifier: AGENT_FIELD_PROMPT_VERSION_UID,
|
|
1646
|
+
name: "promptVersion",
|
|
1647
|
+
type: appKit.FieldType.NUMBER,
|
|
1648
|
+
label: "Prompt version",
|
|
1649
|
+
description: 'Pinning; absent means "follow the label".',
|
|
1650
|
+
isNullable: true
|
|
1651
|
+
},
|
|
1652
|
+
{
|
|
1653
|
+
universalIdentifier: AGENT_FIELD_SYSTEM_PROMPT_SNAPSHOT_UID,
|
|
1654
|
+
name: "systemPromptSnapshot",
|
|
1655
|
+
type: appKit.FieldType.TEXT,
|
|
1656
|
+
label: "System prompt snapshot",
|
|
1657
|
+
description: "Level-3 fallback of the prompt ladder (\xA73.7).",
|
|
1658
|
+
isNullable: true
|
|
1659
|
+
},
|
|
1660
|
+
{
|
|
1661
|
+
universalIdentifier: AGENT_FIELD_REASONING_EFFORT_UID,
|
|
1662
|
+
name: "reasoningEffort",
|
|
1663
|
+
type: appKit.FieldType.SELECT,
|
|
1664
|
+
label: "Reasoning effort",
|
|
1665
|
+
isNullable: true,
|
|
1666
|
+
options: [...REASONING_EFFORT_OPTIONS]
|
|
1667
|
+
},
|
|
1668
|
+
{
|
|
1669
|
+
universalIdentifier: AGENT_FIELD_MAX_TOOL_CALLS_UID,
|
|
1670
|
+
name: "maxToolCalls",
|
|
1671
|
+
type: appKit.FieldType.NUMBER,
|
|
1672
|
+
label: "Max tool calls",
|
|
1673
|
+
isNullable: true
|
|
1674
|
+
}
|
|
1675
|
+
]});
|
|
1676
|
+
|
|
1677
|
+
// src/ui/settings/pipeline-nodes.ts
|
|
1678
|
+
var PIPELINE_STEP_KEYS = ["triage", "escalate", "draft", "evaluate", "revise"];
|
|
1679
|
+
var PIPELINE_STEPS = [
|
|
1680
|
+
{
|
|
1681
|
+
key: "triage",
|
|
1682
|
+
label: "Triage",
|
|
1683
|
+
description: "comprend et classe chaque demande entrante",
|
|
1684
|
+
requires: null,
|
|
1685
|
+
blockedReason: null
|
|
1686
|
+
},
|
|
1687
|
+
{
|
|
1688
|
+
key: "escalate",
|
|
1689
|
+
label: "Escalade",
|
|
1690
|
+
description: "passe la main \xE0 un humain",
|
|
1691
|
+
requires: null,
|
|
1692
|
+
blockedReason: null
|
|
1693
|
+
},
|
|
1694
|
+
{
|
|
1695
|
+
key: "draft",
|
|
1696
|
+
label: "R\xE9daction",
|
|
1697
|
+
description: "pr\xE9pare un projet de r\xE9ponse",
|
|
1698
|
+
requires: null,
|
|
1699
|
+
blockedReason: null
|
|
1700
|
+
},
|
|
1701
|
+
{
|
|
1702
|
+
key: "evaluate",
|
|
1703
|
+
label: "\xC9valuation",
|
|
1704
|
+
description: "relit la r\xE9ponse avant envoi",
|
|
1705
|
+
requires: "draft",
|
|
1706
|
+
blockedReason: "Il n'y a rien \xE0 \xE9valuer sans r\xE9daction."
|
|
1707
|
+
},
|
|
1708
|
+
{
|
|
1709
|
+
key: "revise",
|
|
1710
|
+
label: "R\xE9vision",
|
|
1711
|
+
description: "r\xE9\xE9crit la r\xE9ponse si l'\xE9valuation la juge insuffisante",
|
|
1712
|
+
requires: "evaluate",
|
|
1713
|
+
blockedReason: "Sans \xE9valuation, rien ne d\xE9clenche une r\xE9vision."
|
|
1714
|
+
}
|
|
1715
|
+
];
|
|
1716
|
+
var TRIAGE_LOCK_REASON = "Sans triage l'app ne traite rien.";
|
|
1717
|
+
var STEP_BY_KEY = new Map(PIPELINE_STEPS.map((step) => [step.key, step]));
|
|
1718
|
+
function pipelineStep(key) {
|
|
1719
|
+
const step = STEP_BY_KEY.get(key);
|
|
1720
|
+
if (!step) throw new Error(`unknown pipeline step: ${key}`);
|
|
1721
|
+
return step;
|
|
1722
|
+
}
|
|
1723
|
+
function readNodes(value) {
|
|
1724
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return {};
|
|
1725
|
+
return value;
|
|
1726
|
+
}
|
|
1727
|
+
function readStep(value, key) {
|
|
1728
|
+
const step = readNodes(value)[key];
|
|
1729
|
+
if (typeof step !== "object" || step === null || Array.isArray(step)) return null;
|
|
1730
|
+
return step;
|
|
1731
|
+
}
|
|
1732
|
+
function isStepEnabled(value, key) {
|
|
1733
|
+
return readStep(value, key) !== null;
|
|
1734
|
+
}
|
|
1735
|
+
function stepBlockedReason(value, key) {
|
|
1736
|
+
const { requires, blockedReason } = pipelineStep(key);
|
|
1737
|
+
if (!requires) return null;
|
|
1738
|
+
return isStepActive(value, requires) ? null : blockedReason;
|
|
1739
|
+
}
|
|
1740
|
+
function isStepActive(value, key) {
|
|
1741
|
+
return isStepEnabled(value, key) && stepBlockedReason(value, key) === null;
|
|
1742
|
+
}
|
|
1743
|
+
function withStep(value, key, step) {
|
|
1744
|
+
return { ...readNodes(value), [key]: step };
|
|
1745
|
+
}
|
|
1746
|
+
function withStepFields(value, key, patch) {
|
|
1747
|
+
const step = readStep(value, key);
|
|
1748
|
+
if (!step) return readNodes(value);
|
|
1749
|
+
const next = { ...step };
|
|
1750
|
+
for (const [field2, fieldValue] of Object.entries(patch)) {
|
|
1751
|
+
if (fieldValue === void 0) delete next[field2];
|
|
1752
|
+
else next[field2] = fieldValue;
|
|
1753
|
+
}
|
|
1754
|
+
return withStep(value, key, next);
|
|
1755
|
+
}
|
|
1756
|
+
function stepString(step, field2) {
|
|
1757
|
+
const value = step?.[field2];
|
|
1758
|
+
return typeof value === "string" ? value : "";
|
|
1759
|
+
}
|
|
1760
|
+
function stepNumber(step, field2, fallback) {
|
|
1761
|
+
const value = step?.[field2];
|
|
1762
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
1763
|
+
}
|
|
1764
|
+
function stepBoolean(step, field2, fallback) {
|
|
1765
|
+
const value = step?.[field2];
|
|
1766
|
+
return typeof value === "boolean" ? value : fallback;
|
|
1767
|
+
}
|
|
1768
|
+
function stepUsesAgentPrompt(key) {
|
|
1769
|
+
return key === "draft";
|
|
1770
|
+
}
|
|
1771
|
+
var DEFAULT_PROMPT_LABEL = "production";
|
|
1772
|
+
function stepPromptName(step) {
|
|
1773
|
+
return readPromptField(step, "name");
|
|
1774
|
+
}
|
|
1775
|
+
function stepPromptLabel(step) {
|
|
1776
|
+
return readPromptField(step, "label") || DEFAULT_PROMPT_LABEL;
|
|
1777
|
+
}
|
|
1778
|
+
function readPromptField(step, field2) {
|
|
1779
|
+
const prompt = step?.prompt;
|
|
1780
|
+
if (typeof prompt !== "object" || prompt === null) return "";
|
|
1781
|
+
const value = prompt[field2];
|
|
1782
|
+
return typeof value === "string" ? value : "";
|
|
1783
|
+
}
|
|
1784
|
+
function promptPatch(name, label) {
|
|
1785
|
+
return { prompt: { name, label } };
|
|
1786
|
+
}
|
|
1787
|
+
function stepReasoning(step) {
|
|
1788
|
+
const value = step?.reasoning;
|
|
1789
|
+
return REASONING_EFFORTS.some((effort) => effort.value === value) ? value : "off";
|
|
1790
|
+
}
|
|
1791
|
+
var REASONING_EFFORTS = [
|
|
1792
|
+
{ value: "off", label: "Aucun" },
|
|
1793
|
+
{ value: "low", label: "L\xE9ger" },
|
|
1794
|
+
{ value: "medium", label: "Moyen" },
|
|
1795
|
+
{ value: "high", label: "Pouss\xE9" }
|
|
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
|
+
var CUSTOM_MODEL_VALUE = "__custom__";
|
|
1836
|
+
function findModelOption(model) {
|
|
1837
|
+
return KNOWN_MODELS.find((option) => option.model === model);
|
|
1838
|
+
}
|
|
1839
|
+
function defaultStep() {
|
|
1840
|
+
const [first] = KNOWN_MODELS;
|
|
1841
|
+
return { model: first.model, provider: first.provider, reasoning: "off" };
|
|
1842
|
+
}
|
|
1843
|
+
var PIPELINE_PRESETS = [
|
|
1844
|
+
{
|
|
1845
|
+
id: "triage-only",
|
|
1846
|
+
label: "D\xE9marrage prudent \u2014 triage seul",
|
|
1847
|
+
description: "Les demandes sont comprises et class\xE9es. Aucune r\xE9ponse n\u2019est pr\xE9par\xE9e.",
|
|
1848
|
+
enabled: ["triage"]
|
|
1849
|
+
},
|
|
1850
|
+
{
|
|
1851
|
+
id: "assisted",
|
|
1852
|
+
label: "R\xE9ponse assist\xE9e",
|
|
1853
|
+
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.",
|
|
1854
|
+
enabled: ["triage", "escalate", "draft"]
|
|
1855
|
+
}
|
|
1856
|
+
];
|
|
1857
|
+
function applyPreset(value, preset, restore) {
|
|
1858
|
+
let next = readNodes(value);
|
|
1859
|
+
for (const key of PIPELINE_STEP_KEYS) {
|
|
1860
|
+
const on = preset.enabled.includes(key);
|
|
1861
|
+
next = withStep(next, key, on ? readStep(next, key) ?? restore(key) : null);
|
|
1862
|
+
}
|
|
1863
|
+
return next;
|
|
1864
|
+
}
|
|
1865
|
+
function usePromptCatalogue() {
|
|
1866
|
+
const { appSlug } = uiSdk.useAppContext();
|
|
1867
|
+
const api = uiSdk.useAppApi();
|
|
1868
|
+
const [prompts, setPrompts] = react.useState([]);
|
|
1869
|
+
const [isLoading, setIsLoading] = react.useState(true);
|
|
1870
|
+
const [error, setError] = react.useState(void 0);
|
|
1871
|
+
const clientRef = react.useRef(api);
|
|
1872
|
+
clientRef.current = api;
|
|
1873
|
+
const requestIdRef = react.useRef(0);
|
|
1874
|
+
const isMountedRef = react.useRef(true);
|
|
1875
|
+
react.useEffect(() => {
|
|
1876
|
+
isMountedRef.current = true;
|
|
1877
|
+
const requestId = ++requestIdRef.current;
|
|
1878
|
+
setIsLoading(true);
|
|
1879
|
+
void clientRef.current.get(`/data/apps/${appSlug}/prompts`).then((catalogue) => {
|
|
1880
|
+
if (requestId !== requestIdRef.current || !isMountedRef.current) return;
|
|
1881
|
+
setPrompts(catalogue);
|
|
1882
|
+
setError(void 0);
|
|
1883
|
+
}).catch((err) => {
|
|
1884
|
+
if (requestId !== requestIdRef.current || !isMountedRef.current) return;
|
|
1885
|
+
setError(err);
|
|
1886
|
+
}).finally(() => {
|
|
1887
|
+
if (requestId !== requestIdRef.current || !isMountedRef.current) return;
|
|
1888
|
+
setIsLoading(false);
|
|
1889
|
+
});
|
|
1890
|
+
return () => {
|
|
1891
|
+
isMountedRef.current = false;
|
|
1892
|
+
};
|
|
1893
|
+
}, [appSlug]);
|
|
1894
|
+
return { prompts, isLoading, error };
|
|
1895
|
+
}
|
|
1571
1896
|
function ConfirmModal({
|
|
1572
1897
|
title,
|
|
1573
1898
|
description,
|
|
@@ -1771,18 +2096,34 @@ var STATUS_VARIANT = {
|
|
|
1771
2096
|
archived: "outline"
|
|
1772
2097
|
};
|
|
1773
2098
|
function emptyForm() {
|
|
1774
|
-
return {
|
|
2099
|
+
return {
|
|
2100
|
+
name: "",
|
|
2101
|
+
modelId: "",
|
|
2102
|
+
provider: DEFAULT_LLM_PROVIDER,
|
|
2103
|
+
status: "available",
|
|
2104
|
+
promptName: "",
|
|
2105
|
+
promptLabel: "",
|
|
2106
|
+
systemPromptSnapshot: ""
|
|
2107
|
+
};
|
|
1775
2108
|
}
|
|
1776
2109
|
function formFromAgent(agent) {
|
|
1777
2110
|
return {
|
|
1778
2111
|
name: agent.name,
|
|
1779
2112
|
modelId: agent.modelId,
|
|
1780
2113
|
provider: agent.provider,
|
|
2114
|
+
status: agent.status,
|
|
2115
|
+
promptName: agent.promptName,
|
|
2116
|
+
promptLabel: agent.promptLabel ?? "",
|
|
1781
2117
|
systemPromptSnapshot: agent.systemPromptSnapshot ?? ""
|
|
1782
2118
|
};
|
|
1783
2119
|
}
|
|
2120
|
+
var DERIVED_PROMPT_VALUE = "__derived__";
|
|
2121
|
+
var CUSTOM_PROMPT_VALUE = "__custom-prompt__";
|
|
2122
|
+
var DEFAULT_LABEL_VALUE = "__production__";
|
|
1784
2123
|
function AgentFormModal({
|
|
1785
2124
|
agent,
|
|
2125
|
+
prompts,
|
|
2126
|
+
promptsLoading,
|
|
1786
2127
|
onClose,
|
|
1787
2128
|
onSave
|
|
1788
2129
|
}) {
|
|
@@ -1790,10 +2131,19 @@ function AgentFormModal({
|
|
|
1790
2131
|
agent === "new" ? emptyForm() : formFromAgent(agent)
|
|
1791
2132
|
);
|
|
1792
2133
|
const [isSaving, setIsSaving] = react.useState(false);
|
|
2134
|
+
const [freeTextModel, setFreeTextModel] = react.useState(false);
|
|
2135
|
+
const [freeTextPrompt, setFreeTextPrompt] = react.useState(false);
|
|
1793
2136
|
const nameId = react.useId();
|
|
1794
|
-
const
|
|
2137
|
+
const modelInputId = react.useId();
|
|
2138
|
+
const providerInputId = react.useId();
|
|
2139
|
+
const promptInputId = react.useId();
|
|
1795
2140
|
const snapshotId = react.useId();
|
|
1796
|
-
const
|
|
2141
|
+
const knownModel = findModelOption(form.modelId);
|
|
2142
|
+
const showModelFreeText = freeTextModel || form.modelId !== "" && !knownModel;
|
|
2143
|
+
const knownPrompt = prompts.find((entry) => entry.name === form.promptName);
|
|
2144
|
+
const showPromptFreeText = freeTextPrompt || agent !== "new" && form.promptName !== "" && !knownPrompt && !promptsLoading;
|
|
2145
|
+
const promptLabels = knownPrompt?.labels ?? [];
|
|
2146
|
+
const isValid = form.name.trim() !== "" && form.modelId.trim() !== "" && (agent === "new" || form.promptName.trim() !== "");
|
|
1797
2147
|
async function submit(event) {
|
|
1798
2148
|
event.preventDefault();
|
|
1799
2149
|
if (isSaving || !isValid) return;
|
|
@@ -1804,6 +2154,14 @@ function AgentFormModal({
|
|
|
1804
2154
|
setIsSaving(false);
|
|
1805
2155
|
}
|
|
1806
2156
|
}
|
|
2157
|
+
function pickPrompt(next) {
|
|
2158
|
+
if (next === CUSTOM_PROMPT_VALUE) {
|
|
2159
|
+
setFreeTextPrompt(true);
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2162
|
+
setFreeTextPrompt(false);
|
|
2163
|
+
setForm({ ...form, promptName: next === DERIVED_PROMPT_VALUE ? "" : next, promptLabel: "" });
|
|
2164
|
+
}
|
|
1807
2165
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1808
2166
|
uiSdk.Modal,
|
|
1809
2167
|
{
|
|
@@ -1815,24 +2173,113 @@ function AgentFormModal({
|
|
|
1815
2173
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: nameId, className: "mb-1 block text-sm font-medium", children: "Nom" }),
|
|
1816
2174
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Input, { id: nameId, value: form.name, onChange: (e) => setForm({ ...form, name: e.target.value }) })
|
|
1817
2175
|
] }),
|
|
1818
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1819
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
2176
|
+
agent !== "new" && agent.status !== "default" && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2177
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-sm font-medium", children: "Statut" }),
|
|
1820
2178
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1821
|
-
uiSdk.
|
|
2179
|
+
uiSdk.Select,
|
|
1822
2180
|
{
|
|
1823
|
-
|
|
1824
|
-
value: form.
|
|
1825
|
-
|
|
2181
|
+
"aria-label": "Statut",
|
|
2182
|
+
value: form.status,
|
|
2183
|
+
onValueChange: (next) => setForm({ ...form, status: next }),
|
|
2184
|
+
items: [
|
|
2185
|
+
{ value: "available", label: STATUS_LABELS.available },
|
|
2186
|
+
{ value: "archived", label: STATUS_LABELS.archived }
|
|
2187
|
+
]
|
|
1826
2188
|
}
|
|
1827
2189
|
)
|
|
1828
2190
|
] }),
|
|
1829
2191
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1830
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-sm font-medium", children: "
|
|
1831
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1832
|
-
|
|
1833
|
-
|
|
2192
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-sm font-medium", children: "Mod\xE8le" }),
|
|
2193
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2194
|
+
uiSdk.Select,
|
|
2195
|
+
{
|
|
2196
|
+
"aria-label": "Mod\xE8le",
|
|
2197
|
+
value: showModelFreeText ? CUSTOM_MODEL_VALUE : knownModel?.model ?? void 0,
|
|
2198
|
+
onValueChange: (next) => {
|
|
2199
|
+
if (next === CUSTOM_MODEL_VALUE) {
|
|
2200
|
+
setFreeTextModel(true);
|
|
2201
|
+
return;
|
|
2202
|
+
}
|
|
2203
|
+
setFreeTextModel(false);
|
|
2204
|
+
const option = findModelOption(next);
|
|
2205
|
+
if (!option) return;
|
|
2206
|
+
setForm({ ...form, modelId: option.model, provider: option.provider });
|
|
2207
|
+
},
|
|
2208
|
+
items: [
|
|
2209
|
+
...KNOWN_MODELS.map((option) => ({
|
|
2210
|
+
value: option.model,
|
|
2211
|
+
label: `${option.label} \u2014 ${option.hint}`
|
|
2212
|
+
})),
|
|
2213
|
+
{ value: CUSTOM_MODEL_VALUE, label: "Autre \u2014 saisir un identifiant de mod\xE8le" }
|
|
2214
|
+
]
|
|
2215
|
+
}
|
|
2216
|
+
),
|
|
2217
|
+
showModelFreeText && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 space-y-2", children: [
|
|
2218
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: modelInputId, className: "mb-1 block text-sm font-medium", children: "Identifiant de mod\xE8le" }),
|
|
2219
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2220
|
+
uiSdk.Input,
|
|
2221
|
+
{
|
|
2222
|
+
id: modelInputId,
|
|
2223
|
+
value: form.modelId,
|
|
2224
|
+
onChange: (e) => setForm({ ...form, modelId: e.target.value })
|
|
2225
|
+
}
|
|
2226
|
+
),
|
|
2227
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: providerInputId, className: "mb-1 block text-sm font-medium", children: "Fournisseur" }),
|
|
2228
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2229
|
+
uiSdk.Input,
|
|
2230
|
+
{
|
|
2231
|
+
id: providerInputId,
|
|
2232
|
+
value: form.provider,
|
|
2233
|
+
onChange: (e) => setForm({ ...form, provider: e.target.value })
|
|
2234
|
+
}
|
|
2235
|
+
)
|
|
1834
2236
|
] })
|
|
1835
2237
|
] }),
|
|
2238
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2239
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-sm font-medium", children: "Prompt Langfuse" }),
|
|
2240
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-2 sm:grid-cols-2", children: [
|
|
2241
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2242
|
+
uiSdk.Select,
|
|
2243
|
+
{
|
|
2244
|
+
"aria-label": "Prompt Langfuse",
|
|
2245
|
+
value: showPromptFreeText ? CUSTOM_PROMPT_VALUE : knownPrompt ? form.promptName : agent === "new" ? DERIVED_PROMPT_VALUE : void 0,
|
|
2246
|
+
onValueChange: pickPrompt,
|
|
2247
|
+
items: [
|
|
2248
|
+
...agent === "new" ? [{ value: DERIVED_PROMPT_VALUE, label: "Nouveau prompt \u2014 agent/<g\xE9n\xE9r\xE9 automatiquement>" }] : [],
|
|
2249
|
+
...prompts.map((entry) => ({ value: entry.name, label: entry.name })),
|
|
2250
|
+
{ value: CUSTOM_PROMPT_VALUE, label: "Autre \u2014 saisir un nom de prompt" }
|
|
2251
|
+
],
|
|
2252
|
+
disabled: promptsLoading
|
|
2253
|
+
}
|
|
2254
|
+
),
|
|
2255
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2256
|
+
uiSdk.Select,
|
|
2257
|
+
{
|
|
2258
|
+
"aria-label": "Tag du prompt",
|
|
2259
|
+
value: form.promptLabel === "" ? DEFAULT_LABEL_VALUE : form.promptLabel,
|
|
2260
|
+
onValueChange: (next) => setForm({ ...form, promptLabel: next === DEFAULT_LABEL_VALUE ? "" : next }),
|
|
2261
|
+
items: [
|
|
2262
|
+
{ value: DEFAULT_LABEL_VALUE, label: "production (par d\xE9faut)" },
|
|
2263
|
+
...promptLabels.filter((label) => label !== DEFAULT_PROMPT_LABEL).map((label) => ({ value: label, label })),
|
|
2264
|
+
...form.promptLabel !== "" && !promptLabels.includes(form.promptLabel) ? [{ value: form.promptLabel, label: form.promptLabel }] : []
|
|
2265
|
+
],
|
|
2266
|
+
disabled: promptsLoading || form.promptName === "" && !showPromptFreeText
|
|
2267
|
+
}
|
|
2268
|
+
)
|
|
2269
|
+
] }),
|
|
2270
|
+
showPromptFreeText && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2", children: [
|
|
2271
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: promptInputId, className: "mb-1 block text-sm font-medium", children: "Nom du prompt Langfuse" }),
|
|
2272
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2273
|
+
uiSdk.Input,
|
|
2274
|
+
{
|
|
2275
|
+
id: promptInputId,
|
|
2276
|
+
value: form.promptName,
|
|
2277
|
+
onChange: (e) => setForm({ ...form, promptName: e.target.value })
|
|
2278
|
+
}
|
|
2279
|
+
)
|
|
2280
|
+
] }),
|
|
2281
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "Laisser sur \xAB Nouveau prompt \xBB pour en cr\xE9er un ; choisir un prompt existant pour y rattacher l'agent. Le nom est \xE9crit tel quel, sans normalisation." })
|
|
2282
|
+
] }),
|
|
1836
2283
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1837
2284
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: snapshotId, className: "mb-1 block text-sm font-medium", children: "Prompt de secours (niveau 3)" }),
|
|
1838
2285
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2032,6 +2479,8 @@ function AgentsPage() {
|
|
|
2032
2479
|
const [formAgent, setFormAgent] = react.useState(null);
|
|
2033
2480
|
const [versionsAgent, setVersionsAgent] = react.useState(null);
|
|
2034
2481
|
const [deletingAgent, setDeletingAgent] = react.useState(null);
|
|
2482
|
+
const { prompts, isLoading: promptsLoading, error: promptsError } = usePromptCatalogue();
|
|
2483
|
+
const promptExists = (name) => promptsLoading || promptsError !== void 0 || prompts.some((entry) => entry.name === name);
|
|
2035
2484
|
const recordPath = (id) => `/data/apps/${appSlug}/records/agent/${id}`;
|
|
2036
2485
|
async function patchStatus(agent, status) {
|
|
2037
2486
|
try {
|
|
@@ -2067,12 +2516,30 @@ function AgentsPage() {
|
|
|
2067
2516
|
if (formAgent === "new") {
|
|
2068
2517
|
await api.invoke(
|
|
2069
2518
|
"create-agent",
|
|
2070
|
-
{
|
|
2519
|
+
{
|
|
2520
|
+
name: form.name,
|
|
2521
|
+
modelId: form.modelId,
|
|
2522
|
+
provider: form.provider,
|
|
2523
|
+
systemPromptSnapshot: form.systemPromptSnapshot,
|
|
2524
|
+
// Verbatim (trim only) — empty means "derive agent/<id>", and an
|
|
2525
|
+
// empty label means "follow production" (stored null, never the
|
|
2526
|
+
// literal string).
|
|
2527
|
+
promptName: form.promptName.trim(),
|
|
2528
|
+
promptLabel: form.promptLabel.trim()
|
|
2529
|
+
},
|
|
2071
2530
|
{ idempotencyKey: crypto.randomUUID() }
|
|
2072
2531
|
);
|
|
2073
2532
|
} else if (formAgent) {
|
|
2074
2533
|
await api.patch(recordPath(formAgent.id), {
|
|
2075
|
-
data: {
|
|
2534
|
+
data: {
|
|
2535
|
+
name: form.name,
|
|
2536
|
+
modelId: form.modelId,
|
|
2537
|
+
provider: form.provider,
|
|
2538
|
+
systemPromptSnapshot: form.systemPromptSnapshot,
|
|
2539
|
+
promptName: form.promptName.trim(),
|
|
2540
|
+
promptLabel: form.promptLabel.trim() || null,
|
|
2541
|
+
...formAgent.status !== "default" ? { status: form.status } : {}
|
|
2542
|
+
}
|
|
2076
2543
|
});
|
|
2077
2544
|
}
|
|
2078
2545
|
setFormAgent(null);
|
|
@@ -2093,7 +2560,14 @@ function AgentsPage() {
|
|
|
2093
2560
|
header: "Statut",
|
|
2094
2561
|
cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: STATUS_VARIANT[row.status] ?? "neutral", children: STATUS_LABELS[row.status] ?? row.status })
|
|
2095
2562
|
},
|
|
2096
|
-
{
|
|
2563
|
+
{
|
|
2564
|
+
key: "promptName",
|
|
2565
|
+
header: "Prompt",
|
|
2566
|
+
cell: (row) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-2", children: [
|
|
2567
|
+
row.promptName,
|
|
2568
|
+
!promptExists(row.promptName) && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "warning", children: "prompt introuvable chez Langfuse" })
|
|
2569
|
+
] })
|
|
2570
|
+
},
|
|
2097
2571
|
{
|
|
2098
2572
|
key: "actions",
|
|
2099
2573
|
header: "",
|
|
@@ -2139,7 +2613,16 @@ function AgentsPage() {
|
|
|
2139
2613
|
empty: "Aucun agent configur\xE9."
|
|
2140
2614
|
}
|
|
2141
2615
|
),
|
|
2142
|
-
formAgent && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2616
|
+
formAgent && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2617
|
+
AgentFormModal,
|
|
2618
|
+
{
|
|
2619
|
+
agent: formAgent,
|
|
2620
|
+
prompts,
|
|
2621
|
+
promptsLoading,
|
|
2622
|
+
onClose: () => setFormAgent(null),
|
|
2623
|
+
onSave: save
|
|
2624
|
+
}
|
|
2625
|
+
),
|
|
2143
2626
|
versionsAgent && /* @__PURE__ */ jsxRuntime.jsx(PromptVersionsPanel, { agent: versionsAgent, canWrite, onClose: () => setVersionsAgent(null) }),
|
|
2144
2627
|
deletingAgent && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2145
2628
|
ConfirmModal,
|
|
@@ -3182,147 +3665,42 @@ function validateSettings(settings) {
|
|
|
3182
3665
|
const stepsWithoutPrompt = stepsMissingPrompt(settings.nodes);
|
|
3183
3666
|
if (stepsWithoutPrompt.length > 0) {
|
|
3184
3667
|
issues.push({
|
|
3185
|
-
key: "nodePrompt",
|
|
3186
|
-
message: `Every active step needs a Langfuse prompt \u2014 missing on: ${stepsWithoutPrompt.join(", ")}.`
|
|
3187
|
-
});
|
|
3188
|
-
}
|
|
3189
|
-
const autoSendEnabled = settings.autoSendEnabled === true;
|
|
3190
|
-
const isWhatsappAutoReply = settings.whatsappMode === "auto_reply";
|
|
3191
|
-
if (autoSendEnabled && !isWhatsappAutoReply && !isNonEmptyString(settings.senderEmail)) {
|
|
3192
|
-
issues.push({
|
|
3193
|
-
key: "senderEmail",
|
|
3194
|
-
message: "senderEmail is required when autoSendEnabled is on, unless whatsappMode is 'auto_reply'."
|
|
3195
|
-
});
|
|
3196
|
-
}
|
|
3197
|
-
return issues;
|
|
3198
|
-
}
|
|
3199
|
-
function isNonEmptyString(value) {
|
|
3200
|
-
return typeof value === "string" && value.length > 0;
|
|
3201
|
-
}
|
|
3202
|
-
var STEPS_REQUIRING_PROMPT = ["triage", "escalate", "evaluate", "revise"];
|
|
3203
|
-
function stepsMissingPrompt(nodes) {
|
|
3204
|
-
if (typeof nodes !== "object" || nodes === null) return [];
|
|
3205
|
-
const byStep = nodes;
|
|
3206
|
-
return STEPS_REQUIRING_PROMPT.filter((step) => {
|
|
3207
|
-
const node = byStep[step];
|
|
3208
|
-
if (typeof node !== "object" || node === null) return false;
|
|
3209
|
-
return !isNonEmptyString(promptNameOf(node));
|
|
3210
|
-
});
|
|
3211
|
-
}
|
|
3212
|
-
function promptNameOf(node) {
|
|
3213
|
-
const prompt = node.prompt;
|
|
3214
|
-
return typeof prompt === "object" && prompt !== null ? prompt.name : void 0;
|
|
3215
|
-
}
|
|
3216
|
-
function isConfiguredNode(nodes) {
|
|
3217
|
-
if (typeof nodes !== "object" || nodes === null) return false;
|
|
3218
|
-
const triage = nodes.triage;
|
|
3219
|
-
return typeof triage === "object" && triage !== null;
|
|
3220
|
-
}
|
|
3221
|
-
var AGENT_FIELD_NAME_UID = "e9cfec6f-15c6-4d02-8f79-0667f64b9eb5";
|
|
3222
|
-
var AGENT_FIELD_PROVIDER_UID = "e522b809-e8a7-4439-a2df-936158d04389";
|
|
3223
|
-
var AGENT_FIELD_MODEL_ID_UID = "d95977ba-362c-44d6-a2f0-24156c76cf8a";
|
|
3224
|
-
var AGENT_FIELD_STATUS_UID = "348725a0-a896-4f8d-8a56-86f4193234a8";
|
|
3225
|
-
var AGENT_FIELD_DEFAULT_KEY_UID = "0134491a-c969-4c42-894c-36ad4880fed3";
|
|
3226
|
-
var AGENT_FIELD_PROMPT_NAME_UID = "32e7f234-00bb-44d2-917b-be28f32f7214";
|
|
3227
|
-
var AGENT_FIELD_PROMPT_LABEL_UID = "bdee53ff-571a-4df6-91ec-00b513a70fe0";
|
|
3228
|
-
var AGENT_FIELD_PROMPT_VERSION_UID = "e7c66f99-e1e0-4fc2-9f9e-3bafe3af8e88";
|
|
3229
|
-
var AGENT_FIELD_SYSTEM_PROMPT_SNAPSHOT_UID = "710b73c6-929b-48b7-abc0-792849adf1c2";
|
|
3230
|
-
var AGENT_FIELD_REASONING_EFFORT_UID = "aa57fc6e-c989-47d3-9fc8-e04184b1e67c";
|
|
3231
|
-
var AGENT_FIELD_MAX_TOOL_CALLS_UID = "6948a5ca-48ef-45d7-9118-c7ab195343a3";
|
|
3232
|
-
|
|
3233
|
-
// src/records/agent.ts
|
|
3234
|
-
var AGENT_STATUSES = ["default", "available", "archived"];
|
|
3235
|
-
var REASONING_EFFORT_OPTIONS = ["off", "low", "medium", "high"];
|
|
3236
|
-
var DEFAULT_LLM_PROVIDER = "openai";
|
|
3237
|
-
({
|
|
3238
|
-
fields: [
|
|
3239
|
-
{
|
|
3240
|
-
universalIdentifier: AGENT_FIELD_NAME_UID,
|
|
3241
|
-
name: "name",
|
|
3242
|
-
type: appKit.FieldType.TEXT,
|
|
3243
|
-
label: "Name",
|
|
3244
|
-
isNullable: false
|
|
3245
|
-
},
|
|
3246
|
-
{
|
|
3247
|
-
universalIdentifier: AGENT_FIELD_PROVIDER_UID,
|
|
3248
|
-
name: "provider",
|
|
3249
|
-
type: appKit.FieldType.TEXT,
|
|
3250
|
-
label: "Provider",
|
|
3251
|
-
description: "Free text (spec \xA73.4) \u2014 a new provider must not need a kit release.",
|
|
3252
|
-
isNullable: false,
|
|
3253
|
-
defaultValue: DEFAULT_LLM_PROVIDER
|
|
3254
|
-
},
|
|
3255
|
-
{
|
|
3256
|
-
universalIdentifier: AGENT_FIELD_MODEL_ID_UID,
|
|
3257
|
-
name: "modelId",
|
|
3258
|
-
type: appKit.FieldType.TEXT,
|
|
3259
|
-
label: "Model id",
|
|
3260
|
-
isNullable: false
|
|
3261
|
-
},
|
|
3262
|
-
{
|
|
3263
|
-
universalIdentifier: AGENT_FIELD_STATUS_UID,
|
|
3264
|
-
name: "status",
|
|
3265
|
-
type: appKit.FieldType.SELECT,
|
|
3266
|
-
label: "Status",
|
|
3267
|
-
isNullable: false,
|
|
3268
|
-
options: [...AGENT_STATUSES],
|
|
3269
|
-
defaultValue: "available"
|
|
3270
|
-
},
|
|
3271
|
-
{
|
|
3272
|
-
universalIdentifier: AGENT_FIELD_DEFAULT_KEY_UID,
|
|
3273
|
-
name: "defaultKey",
|
|
3274
|
-
type: appKit.FieldType.TEXT,
|
|
3275
|
-
label: "Default key",
|
|
3276
|
-
description: "Equals 'default' when status='default', absent otherwise. Unique.",
|
|
3277
|
-
isNullable: true
|
|
3278
|
-
},
|
|
3279
|
-
{
|
|
3280
|
-
universalIdentifier: AGENT_FIELD_PROMPT_NAME_UID,
|
|
3281
|
-
name: "promptName",
|
|
3282
|
-
type: appKit.FieldType.TEXT,
|
|
3283
|
-
label: "Prompt name",
|
|
3284
|
-
description: "Free Langfuse prompt name (ETL keeps legacy agent/<old id> names).",
|
|
3285
|
-
isNullable: false
|
|
3286
|
-
},
|
|
3287
|
-
{
|
|
3288
|
-
universalIdentifier: AGENT_FIELD_PROMPT_LABEL_UID,
|
|
3289
|
-
name: "promptLabel",
|
|
3290
|
-
type: appKit.FieldType.TEXT,
|
|
3291
|
-
label: "Prompt label",
|
|
3292
|
-
isNullable: true
|
|
3293
|
-
},
|
|
3294
|
-
{
|
|
3295
|
-
universalIdentifier: AGENT_FIELD_PROMPT_VERSION_UID,
|
|
3296
|
-
name: "promptVersion",
|
|
3297
|
-
type: appKit.FieldType.NUMBER,
|
|
3298
|
-
label: "Prompt version",
|
|
3299
|
-
description: 'Pinning; absent means "follow the label".',
|
|
3300
|
-
isNullable: true
|
|
3301
|
-
},
|
|
3302
|
-
{
|
|
3303
|
-
universalIdentifier: AGENT_FIELD_SYSTEM_PROMPT_SNAPSHOT_UID,
|
|
3304
|
-
name: "systemPromptSnapshot",
|
|
3305
|
-
type: appKit.FieldType.TEXT,
|
|
3306
|
-
label: "System prompt snapshot",
|
|
3307
|
-
description: "Level-3 fallback of the prompt ladder (\xA73.7).",
|
|
3308
|
-
isNullable: true
|
|
3309
|
-
},
|
|
3310
|
-
{
|
|
3311
|
-
universalIdentifier: AGENT_FIELD_REASONING_EFFORT_UID,
|
|
3312
|
-
name: "reasoningEffort",
|
|
3313
|
-
type: appKit.FieldType.SELECT,
|
|
3314
|
-
label: "Reasoning effort",
|
|
3315
|
-
isNullable: true,
|
|
3316
|
-
options: [...REASONING_EFFORT_OPTIONS]
|
|
3317
|
-
},
|
|
3318
|
-
{
|
|
3319
|
-
universalIdentifier: AGENT_FIELD_MAX_TOOL_CALLS_UID,
|
|
3320
|
-
name: "maxToolCalls",
|
|
3321
|
-
type: appKit.FieldType.NUMBER,
|
|
3322
|
-
label: "Max tool calls",
|
|
3323
|
-
isNullable: true
|
|
3324
|
-
}
|
|
3325
|
-
]});
|
|
3668
|
+
key: "nodePrompt",
|
|
3669
|
+
message: `Every active step needs a Langfuse prompt \u2014 missing on: ${stepsWithoutPrompt.join(", ")}.`
|
|
3670
|
+
});
|
|
3671
|
+
}
|
|
3672
|
+
const autoSendEnabled = settings.autoSendEnabled === true;
|
|
3673
|
+
const isWhatsappAutoReply = settings.whatsappMode === "auto_reply";
|
|
3674
|
+
if (autoSendEnabled && !isWhatsappAutoReply && !isNonEmptyString(settings.senderEmail)) {
|
|
3675
|
+
issues.push({
|
|
3676
|
+
key: "senderEmail",
|
|
3677
|
+
message: "senderEmail is required when autoSendEnabled is on, unless whatsappMode is 'auto_reply'."
|
|
3678
|
+
});
|
|
3679
|
+
}
|
|
3680
|
+
return issues;
|
|
3681
|
+
}
|
|
3682
|
+
function isNonEmptyString(value) {
|
|
3683
|
+
return typeof value === "string" && value.length > 0;
|
|
3684
|
+
}
|
|
3685
|
+
var STEPS_REQUIRING_PROMPT = ["triage", "escalate", "evaluate", "revise"];
|
|
3686
|
+
function stepsMissingPrompt(nodes) {
|
|
3687
|
+
if (typeof nodes !== "object" || nodes === null) return [];
|
|
3688
|
+
const byStep = nodes;
|
|
3689
|
+
return STEPS_REQUIRING_PROMPT.filter((step) => {
|
|
3690
|
+
const node = byStep[step];
|
|
3691
|
+
if (typeof node !== "object" || node === null) return false;
|
|
3692
|
+
return !isNonEmptyString(promptNameOf(node));
|
|
3693
|
+
});
|
|
3694
|
+
}
|
|
3695
|
+
function promptNameOf(node) {
|
|
3696
|
+
const prompt = node.prompt;
|
|
3697
|
+
return typeof prompt === "object" && prompt !== null ? prompt.name : void 0;
|
|
3698
|
+
}
|
|
3699
|
+
function isConfiguredNode(nodes) {
|
|
3700
|
+
if (typeof nodes !== "object" || nodes === null) return false;
|
|
3701
|
+
const triage = nodes.triage;
|
|
3702
|
+
return typeof triage === "object" && triage !== null;
|
|
3703
|
+
}
|
|
3326
3704
|
|
|
3327
3705
|
// src/settings/to-profile.ts
|
|
3328
3706
|
var DEFAULT_REASONING = "off";
|
|
@@ -3453,195 +3831,6 @@ function NumberField({ id, label, value, onChange, disabled, min, max, integer,
|
|
|
3453
3831
|
hint && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: hint })
|
|
3454
3832
|
] });
|
|
3455
3833
|
}
|
|
3456
|
-
|
|
3457
|
-
// src/ui/settings/pipeline-nodes.ts
|
|
3458
|
-
var PIPELINE_STEP_KEYS = ["triage", "escalate", "draft", "evaluate", "revise"];
|
|
3459
|
-
var PIPELINE_STEPS = [
|
|
3460
|
-
{
|
|
3461
|
-
key: "triage",
|
|
3462
|
-
label: "Triage",
|
|
3463
|
-
description: "comprend et classe chaque demande entrante",
|
|
3464
|
-
requires: null,
|
|
3465
|
-
blockedReason: null
|
|
3466
|
-
},
|
|
3467
|
-
{
|
|
3468
|
-
key: "escalate",
|
|
3469
|
-
label: "Escalade",
|
|
3470
|
-
description: "passe la main \xE0 un humain",
|
|
3471
|
-
requires: null,
|
|
3472
|
-
blockedReason: null
|
|
3473
|
-
},
|
|
3474
|
-
{
|
|
3475
|
-
key: "draft",
|
|
3476
|
-
label: "R\xE9daction",
|
|
3477
|
-
description: "pr\xE9pare un projet de r\xE9ponse",
|
|
3478
|
-
requires: null,
|
|
3479
|
-
blockedReason: null
|
|
3480
|
-
},
|
|
3481
|
-
{
|
|
3482
|
-
key: "evaluate",
|
|
3483
|
-
label: "\xC9valuation",
|
|
3484
|
-
description: "relit la r\xE9ponse avant envoi",
|
|
3485
|
-
requires: "draft",
|
|
3486
|
-
blockedReason: "Il n'y a rien \xE0 \xE9valuer sans r\xE9daction."
|
|
3487
|
-
},
|
|
3488
|
-
{
|
|
3489
|
-
key: "revise",
|
|
3490
|
-
label: "R\xE9vision",
|
|
3491
|
-
description: "r\xE9\xE9crit la r\xE9ponse si l'\xE9valuation la juge insuffisante",
|
|
3492
|
-
requires: "evaluate",
|
|
3493
|
-
blockedReason: "Sans \xE9valuation, rien ne d\xE9clenche une r\xE9vision."
|
|
3494
|
-
}
|
|
3495
|
-
];
|
|
3496
|
-
var TRIAGE_LOCK_REASON = "Sans triage l'app ne traite rien.";
|
|
3497
|
-
var STEP_BY_KEY = new Map(PIPELINE_STEPS.map((step) => [step.key, step]));
|
|
3498
|
-
function pipelineStep(key) {
|
|
3499
|
-
const step = STEP_BY_KEY.get(key);
|
|
3500
|
-
if (!step) throw new Error(`unknown pipeline step: ${key}`);
|
|
3501
|
-
return step;
|
|
3502
|
-
}
|
|
3503
|
-
function readNodes(value) {
|
|
3504
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return {};
|
|
3505
|
-
return value;
|
|
3506
|
-
}
|
|
3507
|
-
function readStep(value, key) {
|
|
3508
|
-
const step = readNodes(value)[key];
|
|
3509
|
-
if (typeof step !== "object" || step === null || Array.isArray(step)) return null;
|
|
3510
|
-
return step;
|
|
3511
|
-
}
|
|
3512
|
-
function isStepEnabled(value, key) {
|
|
3513
|
-
return readStep(value, key) !== null;
|
|
3514
|
-
}
|
|
3515
|
-
function stepBlockedReason(value, key) {
|
|
3516
|
-
const { requires, blockedReason } = pipelineStep(key);
|
|
3517
|
-
if (!requires) return null;
|
|
3518
|
-
return isStepActive(value, requires) ? null : blockedReason;
|
|
3519
|
-
}
|
|
3520
|
-
function isStepActive(value, key) {
|
|
3521
|
-
return isStepEnabled(value, key) && stepBlockedReason(value, key) === null;
|
|
3522
|
-
}
|
|
3523
|
-
function withStep(value, key, step) {
|
|
3524
|
-
return { ...readNodes(value), [key]: step };
|
|
3525
|
-
}
|
|
3526
|
-
function withStepFields(value, key, patch) {
|
|
3527
|
-
const step = readStep(value, key);
|
|
3528
|
-
if (!step) return readNodes(value);
|
|
3529
|
-
const next = { ...step };
|
|
3530
|
-
for (const [field2, fieldValue] of Object.entries(patch)) {
|
|
3531
|
-
if (fieldValue === void 0) delete next[field2];
|
|
3532
|
-
else next[field2] = fieldValue;
|
|
3533
|
-
}
|
|
3534
|
-
return withStep(value, key, next);
|
|
3535
|
-
}
|
|
3536
|
-
function stepString(step, field2) {
|
|
3537
|
-
const value = step?.[field2];
|
|
3538
|
-
return typeof value === "string" ? value : "";
|
|
3539
|
-
}
|
|
3540
|
-
function stepNumber(step, field2, fallback) {
|
|
3541
|
-
const value = step?.[field2];
|
|
3542
|
-
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
3543
|
-
}
|
|
3544
|
-
function stepBoolean(step, field2, fallback) {
|
|
3545
|
-
const value = step?.[field2];
|
|
3546
|
-
return typeof value === "boolean" ? value : fallback;
|
|
3547
|
-
}
|
|
3548
|
-
function stepUsesAgentPrompt(key) {
|
|
3549
|
-
return key === "draft";
|
|
3550
|
-
}
|
|
3551
|
-
var DEFAULT_PROMPT_LABEL = "production";
|
|
3552
|
-
function stepPromptName(step) {
|
|
3553
|
-
return readPromptField(step, "name");
|
|
3554
|
-
}
|
|
3555
|
-
function stepPromptLabel(step) {
|
|
3556
|
-
return readPromptField(step, "label") || DEFAULT_PROMPT_LABEL;
|
|
3557
|
-
}
|
|
3558
|
-
function readPromptField(step, field2) {
|
|
3559
|
-
const prompt = step?.prompt;
|
|
3560
|
-
if (typeof prompt !== "object" || prompt === null) return "";
|
|
3561
|
-
const value = prompt[field2];
|
|
3562
|
-
return typeof value === "string" ? value : "";
|
|
3563
|
-
}
|
|
3564
|
-
function promptPatch(name, label) {
|
|
3565
|
-
return { prompt: { name, label } };
|
|
3566
|
-
}
|
|
3567
|
-
function stepReasoning(step) {
|
|
3568
|
-
const value = step?.reasoning;
|
|
3569
|
-
return REASONING_EFFORTS.some((effort) => effort.value === value) ? value : "off";
|
|
3570
|
-
}
|
|
3571
|
-
var REASONING_EFFORTS = [
|
|
3572
|
-
{ value: "off", label: "Aucun" },
|
|
3573
|
-
{ value: "low", label: "L\xE9ger" },
|
|
3574
|
-
{ value: "medium", label: "Moyen" },
|
|
3575
|
-
{ value: "high", label: "Pouss\xE9" }
|
|
3576
|
-
];
|
|
3577
|
-
var KNOWN_MODELS = [
|
|
3578
|
-
{
|
|
3579
|
-
provider: "openai",
|
|
3580
|
-
model: "gpt-4o-mini",
|
|
3581
|
-
label: "GPT-4o mini",
|
|
3582
|
-
hint: "Le moins cher, tr\xE8s rapide \u2014 suffisant pour classer"
|
|
3583
|
-
},
|
|
3584
|
-
{
|
|
3585
|
-
provider: "openai",
|
|
3586
|
-
model: "gpt-5-mini",
|
|
3587
|
-
label: "GPT-5 mini",
|
|
3588
|
-
hint: "Rapide, bon march\xE9, meilleur raisonnement"
|
|
3589
|
-
},
|
|
3590
|
-
{
|
|
3591
|
-
provider: "openai",
|
|
3592
|
-
model: "gpt-4.1",
|
|
3593
|
-
label: "GPT-4.1",
|
|
3594
|
-
hint: "Co\xFBt moyen \u2014 r\xE9daction soign\xE9e"
|
|
3595
|
-
},
|
|
3596
|
-
{
|
|
3597
|
-
provider: "openai",
|
|
3598
|
-
model: "gpt-5",
|
|
3599
|
-
label: "GPT-5",
|
|
3600
|
-
hint: "Le plus capable \u2014 le plus lent et le plus cher"
|
|
3601
|
-
},
|
|
3602
|
-
{
|
|
3603
|
-
provider: "anthropic",
|
|
3604
|
-
model: "claude-3-5-haiku-latest",
|
|
3605
|
-
label: "Claude 3.5 Haiku",
|
|
3606
|
-
hint: "Rapide et bon march\xE9"
|
|
3607
|
-
},
|
|
3608
|
-
{
|
|
3609
|
-
provider: "anthropic",
|
|
3610
|
-
model: "claude-3-5-sonnet-latest",
|
|
3611
|
-
label: "Claude 3.5 Sonnet",
|
|
3612
|
-
hint: "Co\xFBt moyen \u2014 r\xE9daction soign\xE9e"
|
|
3613
|
-
}
|
|
3614
|
-
];
|
|
3615
|
-
var CUSTOM_MODEL_VALUE = "__custom__";
|
|
3616
|
-
function findModelOption(model) {
|
|
3617
|
-
return KNOWN_MODELS.find((option) => option.model === model);
|
|
3618
|
-
}
|
|
3619
|
-
function defaultStep() {
|
|
3620
|
-
const [first] = KNOWN_MODELS;
|
|
3621
|
-
return { model: first.model, provider: first.provider, reasoning: "off" };
|
|
3622
|
-
}
|
|
3623
|
-
var PIPELINE_PRESETS = [
|
|
3624
|
-
{
|
|
3625
|
-
id: "triage-only",
|
|
3626
|
-
label: "D\xE9marrage prudent \u2014 triage seul",
|
|
3627
|
-
description: "Les demandes sont comprises et class\xE9es. Aucune r\xE9ponse n\u2019est pr\xE9par\xE9e.",
|
|
3628
|
-
enabled: ["triage"]
|
|
3629
|
-
},
|
|
3630
|
-
{
|
|
3631
|
-
id: "assisted",
|
|
3632
|
-
label: "R\xE9ponse assist\xE9e",
|
|
3633
|
-
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.",
|
|
3634
|
-
enabled: ["triage", "escalate", "draft"]
|
|
3635
|
-
}
|
|
3636
|
-
];
|
|
3637
|
-
function applyPreset(value, preset, restore) {
|
|
3638
|
-
let next = readNodes(value);
|
|
3639
|
-
for (const key of PIPELINE_STEP_KEYS) {
|
|
3640
|
-
const on = preset.enabled.includes(key);
|
|
3641
|
-
next = withStep(next, key, on ? readStep(next, key) ?? restore(key) : null);
|
|
3642
|
-
}
|
|
3643
|
-
return next;
|
|
3644
|
-
}
|
|
3645
3834
|
var PERCENT = 100;
|
|
3646
3835
|
function PipelineNodesForm({
|
|
3647
3836
|
value,
|
|
@@ -3961,37 +4150,6 @@ function useIds(stepKey) {
|
|
|
3961
4150
|
minConfidence: `${base2}-${stepKey}-min-confidence`
|
|
3962
4151
|
};
|
|
3963
4152
|
}
|
|
3964
|
-
function usePromptCatalogue() {
|
|
3965
|
-
const { appSlug } = uiSdk.useAppContext();
|
|
3966
|
-
const api = uiSdk.useAppApi();
|
|
3967
|
-
const [prompts, setPrompts] = react.useState([]);
|
|
3968
|
-
const [isLoading, setIsLoading] = react.useState(true);
|
|
3969
|
-
const [error, setError] = react.useState(void 0);
|
|
3970
|
-
const clientRef = react.useRef(api);
|
|
3971
|
-
clientRef.current = api;
|
|
3972
|
-
const requestIdRef = react.useRef(0);
|
|
3973
|
-
const isMountedRef = react.useRef(true);
|
|
3974
|
-
react.useEffect(() => {
|
|
3975
|
-
isMountedRef.current = true;
|
|
3976
|
-
const requestId = ++requestIdRef.current;
|
|
3977
|
-
setIsLoading(true);
|
|
3978
|
-
void clientRef.current.get(`/data/apps/${appSlug}/prompts`).then((catalogue) => {
|
|
3979
|
-
if (requestId !== requestIdRef.current || !isMountedRef.current) return;
|
|
3980
|
-
setPrompts(catalogue);
|
|
3981
|
-
setError(void 0);
|
|
3982
|
-
}).catch((err) => {
|
|
3983
|
-
if (requestId !== requestIdRef.current || !isMountedRef.current) return;
|
|
3984
|
-
setError(err);
|
|
3985
|
-
}).finally(() => {
|
|
3986
|
-
if (requestId !== requestIdRef.current || !isMountedRef.current) return;
|
|
3987
|
-
setIsLoading(false);
|
|
3988
|
-
});
|
|
3989
|
-
return () => {
|
|
3990
|
-
isMountedRef.current = false;
|
|
3991
|
-
};
|
|
3992
|
-
}, [appSlug]);
|
|
3993
|
-
return { prompts, isLoading, error };
|
|
3994
|
-
}
|
|
3995
4153
|
var WHATSAPP_MODE_LABELS = {
|
|
3996
4154
|
escalate_only: "Escalade uniquement",
|
|
3997
4155
|
draft_only: "Brouillon uniquement",
|