@apotech-os/support-kit 2.7.1 → 2.9.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/{chunk-HE7Q4VCS.js → chunk-CVYJU4SV.js} +50 -16
- package/dist/chunk-CVYJU4SV.js.map +1 -0
- package/dist/index.cjs +88 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -19
- package/dist/index.d.ts +80 -19
- package/dist/index.js +42 -50
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +184 -2
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +163 -3
- package/dist/ui/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-HE7Q4VCS.js.map +0 -1
package/dist/ui/index.cjs
CHANGED
|
@@ -41,6 +41,7 @@ function toCategory(record) {
|
|
|
41
41
|
groupId: data.groupId ?? null,
|
|
42
42
|
order: data.order ?? 0,
|
|
43
43
|
extraTags: data.extraTags ?? [],
|
|
44
|
+
description: data.description ?? null,
|
|
44
45
|
examples: data.examples ?? null,
|
|
45
46
|
autoReplyEnabled: data.autoReplyEnabled ?? false,
|
|
46
47
|
fastResponseEnabled: data.fastResponseEnabled ?? false
|
|
@@ -989,6 +990,7 @@ function idempotencyKeyFor(operation, payload) {
|
|
|
989
990
|
var SETTINGS_ISSUE_LABELS = {
|
|
990
991
|
sourceViewId: "Vue Gorgias source requise \u2014 choisissez la vue que cette app poss\xE8de.",
|
|
991
992
|
nodes: "nodes.triage doit \xEAtre configur\xE9 \u2014 une \xE9tape de triage \xE0 null ne triagerait rien.",
|
|
993
|
+
nodePrompt: "Chaque \xE9tape active doit d\xE9signer un prompt Langfuse \u2014 sans prompt, l'\xE9tape n'a rien \xE0 dire au mod\xE8le.",
|
|
992
994
|
senderEmail: "Adresse d'envoi requise quand l'envoi automatique est actif (sauf en mode WhatsApp \xAB auto_reply \xBB)."
|
|
993
995
|
};
|
|
994
996
|
function settingsIssueLabel(key, fallback) {
|
|
@@ -2195,12 +2197,14 @@ function CategoryFormModal({
|
|
|
2195
2197
|
groupId,
|
|
2196
2198
|
agentId: category?.agentId ?? "",
|
|
2197
2199
|
extraTags: category?.extraTags.join(", ") ?? "",
|
|
2200
|
+
description: category?.description ?? "",
|
|
2198
2201
|
examples: category?.examples ?? ""
|
|
2199
2202
|
});
|
|
2200
2203
|
const nameId = react.useId();
|
|
2201
2204
|
const tagId = react.useId();
|
|
2202
2205
|
const agentSelectId = react.useId();
|
|
2203
2206
|
const extraTagsId = react.useId();
|
|
2207
|
+
const descriptionId = react.useId();
|
|
2204
2208
|
const examplesId = react.useId();
|
|
2205
2209
|
const isValid = form.name.trim() !== "" && form.tagName.trim() !== "";
|
|
2206
2210
|
async function submit(event) {
|
|
@@ -2250,6 +2254,18 @@ function CategoryFormModal({
|
|
|
2250
2254
|
}
|
|
2251
2255
|
)
|
|
2252
2256
|
] }),
|
|
2257
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2258
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: descriptionId, className: "mb-1 block text-sm font-medium", children: "Description" }),
|
|
2259
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2260
|
+
uiSdk.Textarea,
|
|
2261
|
+
{
|
|
2262
|
+
id: descriptionId,
|
|
2263
|
+
value: form.description,
|
|
2264
|
+
onChange: (e) => setForm({ ...form, description: e.target.value })
|
|
2265
|
+
}
|
|
2266
|
+
),
|
|
2267
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "Ce que le tri montre au mod\xE8le pour choisir cette cat\xE9gorie. Les \xAB Exemples \xBB ci-dessous restent des messages clients types \u2014 les deux sont envoy\xE9s s\xE9par\xE9ment." })
|
|
2268
|
+
] }),
|
|
2253
2269
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2254
2270
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: examplesId, className: "mb-1 block text-sm font-medium", children: "Exemples" }),
|
|
2255
2271
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2331,6 +2347,10 @@ function CategoriesPage() {
|
|
|
2331
2347
|
groupId: form.groupId || null,
|
|
2332
2348
|
agentId: form.agentId || null,
|
|
2333
2349
|
extraTags: form.extraTags.split(",").map((t) => t.trim()).filter(Boolean),
|
|
2350
|
+
// Explicit, `null` when blank — never omitted: the platform validates a
|
|
2351
|
+
// record write against the declared fields, and a declared-but-absent
|
|
2352
|
+
// key is a 422 (same trap as the graph-dry-run payload fixed in 2.7.1).
|
|
2353
|
+
description: form.description.trim() || null,
|
|
2334
2354
|
examples: form.examples
|
|
2335
2355
|
};
|
|
2336
2356
|
try {
|
|
@@ -3159,6 +3179,13 @@ function validateSettings(settings) {
|
|
|
3159
3179
|
message: "nodes.triage must be configured \u2014 a null triage step would triage nothing."
|
|
3160
3180
|
});
|
|
3161
3181
|
}
|
|
3182
|
+
const stepsWithoutPrompt = stepsMissingPrompt(settings.nodes);
|
|
3183
|
+
if (stepsWithoutPrompt.length > 0) {
|
|
3184
|
+
issues.push({
|
|
3185
|
+
key: "nodePrompt",
|
|
3186
|
+
message: `Every active step needs a Langfuse prompt \u2014 missing on: ${stepsWithoutPrompt.join(", ")}.`
|
|
3187
|
+
});
|
|
3188
|
+
}
|
|
3162
3189
|
const autoSendEnabled = settings.autoSendEnabled === true;
|
|
3163
3190
|
const isWhatsappAutoReply = settings.whatsappMode === "auto_reply";
|
|
3164
3191
|
if (autoSendEnabled && !isWhatsappAutoReply && !isNonEmptyString(settings.senderEmail)) {
|
|
@@ -3172,6 +3199,20 @@ function validateSettings(settings) {
|
|
|
3172
3199
|
function isNonEmptyString(value) {
|
|
3173
3200
|
return typeof value === "string" && value.length > 0;
|
|
3174
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
|
+
}
|
|
3175
3216
|
function isConfiguredNode(nodes) {
|
|
3176
3217
|
if (typeof nodes !== "object" || nodes === null) return false;
|
|
3177
3218
|
const triage = nodes.triage;
|
|
@@ -3504,6 +3545,25 @@ function stepBoolean(step, field2, fallback) {
|
|
|
3504
3545
|
const value = step?.[field2];
|
|
3505
3546
|
return typeof value === "boolean" ? value : fallback;
|
|
3506
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
|
+
}
|
|
3507
3567
|
function stepReasoning(step) {
|
|
3508
3568
|
const value = step?.reasoning;
|
|
3509
3569
|
return REASONING_EFFORTS.some((effort) => effort.value === value) ? value : "off";
|
|
@@ -3583,7 +3643,14 @@ function applyPreset(value, preset, restore) {
|
|
|
3583
3643
|
return next;
|
|
3584
3644
|
}
|
|
3585
3645
|
var PERCENT = 100;
|
|
3586
|
-
function PipelineNodesForm({
|
|
3646
|
+
function PipelineNodesForm({
|
|
3647
|
+
value,
|
|
3648
|
+
onChange,
|
|
3649
|
+
canWrite,
|
|
3650
|
+
issueMessage,
|
|
3651
|
+
prompts,
|
|
3652
|
+
promptsLoading = false
|
|
3653
|
+
}) {
|
|
3587
3654
|
const [remembered, setRemembered] = react.useState({});
|
|
3588
3655
|
react.useEffect(() => {
|
|
3589
3656
|
setRemembered((prev) => {
|
|
@@ -3628,6 +3695,8 @@ function PipelineNodesForm({ value, onChange, canWrite, issueMessage }) {
|
|
|
3628
3695
|
value,
|
|
3629
3696
|
canWrite,
|
|
3630
3697
|
issueMessage: step.key === "triage" ? issueMessage : null,
|
|
3698
|
+
prompts,
|
|
3699
|
+
promptsLoading,
|
|
3631
3700
|
onToggle: (on) => toggleStep(step.key, on),
|
|
3632
3701
|
onPatch: (patch) => onChange(withStepFields(value, step.key, patch))
|
|
3633
3702
|
},
|
|
@@ -3644,11 +3713,14 @@ function StepRow({
|
|
|
3644
3713
|
value,
|
|
3645
3714
|
canWrite,
|
|
3646
3715
|
issueMessage,
|
|
3716
|
+
prompts,
|
|
3717
|
+
promptsLoading,
|
|
3647
3718
|
onToggle,
|
|
3648
3719
|
onPatch
|
|
3649
3720
|
}) {
|
|
3650
3721
|
const enabled = isStepEnabled(value, step.key);
|
|
3651
3722
|
const blockedReason = stepBlockedReason(value, step.key);
|
|
3723
|
+
const promptFieldId = react.useId();
|
|
3652
3724
|
const triageLocked = step.key === "triage" && enabled;
|
|
3653
3725
|
const editable = canWrite && !blockedReason && !triageLocked;
|
|
3654
3726
|
const toggle = /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3673,6 +3745,21 @@ function StepRow({
|
|
|
3673
3745
|
] }),
|
|
3674
3746
|
blockedReason && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: blockedReason }),
|
|
3675
3747
|
issueMessage && !enabled && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: issueMessage }),
|
|
3748
|
+
enabled && // In the row itself, NOT behind « Options »: this is the one field
|
|
3749
|
+
// without which the step cannot run at all, so it is stated where the
|
|
3750
|
+
// step is, next to its own switch.
|
|
3751
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md bg-muted/40 p-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3752
|
+
StepPromptField,
|
|
3753
|
+
{
|
|
3754
|
+
step,
|
|
3755
|
+
settings: readStep(value, step.key),
|
|
3756
|
+
disabled: !canWrite || blockedReason !== null,
|
|
3757
|
+
prompts,
|
|
3758
|
+
promptsLoading,
|
|
3759
|
+
id: promptFieldId,
|
|
3760
|
+
onPatch
|
|
3761
|
+
}
|
|
3762
|
+
) }),
|
|
3676
3763
|
enabled && /* @__PURE__ */ jsxRuntime.jsxs("details", { children: [
|
|
3677
3764
|
/* @__PURE__ */ jsxRuntime.jsx("summary", { className: "cursor-pointer text-sm text-muted-foreground", children: "Options" }),
|
|
3678
3765
|
/* @__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(
|
|
@@ -3811,6 +3898,63 @@ function StepOptions({
|
|
|
3811
3898
|
] })
|
|
3812
3899
|
] });
|
|
3813
3900
|
}
|
|
3901
|
+
function StepPromptField({
|
|
3902
|
+
step,
|
|
3903
|
+
settings,
|
|
3904
|
+
disabled,
|
|
3905
|
+
prompts,
|
|
3906
|
+
promptsLoading,
|
|
3907
|
+
id,
|
|
3908
|
+
onPatch
|
|
3909
|
+
}) {
|
|
3910
|
+
if (stepUsesAgentPrompt(step.key)) {
|
|
3911
|
+
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." });
|
|
3912
|
+
}
|
|
3913
|
+
const name = stepPromptName(settings);
|
|
3914
|
+
const label = stepPromptLabel(settings);
|
|
3915
|
+
const known = prompts.find((entry) => entry.name === name);
|
|
3916
|
+
const orphaned = name !== "" && !known && !promptsLoading;
|
|
3917
|
+
const labels = known?.labels.length ? known.labels : [DEFAULT_PROMPT_LABEL];
|
|
3918
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3919
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: "mb-1 block text-sm font-medium", children: "Prompt Langfuse" }),
|
|
3920
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-2 sm:grid-cols-2", children: [
|
|
3921
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3922
|
+
uiSdk.Select,
|
|
3923
|
+
{
|
|
3924
|
+
"aria-label": `Prompt \u2014 ${step.label}`,
|
|
3925
|
+
value: known ? name : void 0,
|
|
3926
|
+
onValueChange: (next) => onPatch(promptPatch(next, DEFAULT_PROMPT_LABEL)),
|
|
3927
|
+
items: [
|
|
3928
|
+
...orphaned ? [{ value: name, label: `${name} \u2014 introuvable dans Langfuse` }] : [],
|
|
3929
|
+
...prompts.map((entry) => ({ value: entry.name, label: entry.name }))
|
|
3930
|
+
],
|
|
3931
|
+
disabled: disabled || promptsLoading
|
|
3932
|
+
}
|
|
3933
|
+
),
|
|
3934
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3935
|
+
uiSdk.Select,
|
|
3936
|
+
{
|
|
3937
|
+
"aria-label": `Version du prompt \u2014 ${step.label}`,
|
|
3938
|
+
value: labels.includes(label) ? label : void 0,
|
|
3939
|
+
onValueChange: (next) => onPatch(promptPatch(name, next)),
|
|
3940
|
+
items: labels.map((entry) => ({ value: entry, label: entry })),
|
|
3941
|
+
disabled: disabled || promptsLoading || name === ""
|
|
3942
|
+
}
|
|
3943
|
+
)
|
|
3944
|
+
] }),
|
|
3945
|
+
name === "" && !promptsLoading && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-destructive", children: "Aucun prompt choisi \u2014 cette \xE9tape ne peut pas s'ex\xE9cuter tant qu'elle n'en d\xE9signe pas un." }),
|
|
3946
|
+
orphaned && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-1 text-sm text-destructive", children: [
|
|
3947
|
+
"\xAB ",
|
|
3948
|
+
name,
|
|
3949
|
+
" \xBB n'est pas dans le catalogue de cette app \u2014 le prochain traitement \xE9chouera tant que ce prompt n'est pas r\xE9tabli ou remplac\xE9."
|
|
3950
|
+
] }),
|
|
3951
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-1 text-xs text-muted-foreground", children: [
|
|
3952
|
+
"Le label suit les promotions faites dans Langfuse : promouvoir une nouvelle version sous \xAB ",
|
|
3953
|
+
label,
|
|
3954
|
+
" \xBB la met en service sans repasser ici."
|
|
3955
|
+
] })
|
|
3956
|
+
] });
|
|
3957
|
+
}
|
|
3814
3958
|
function useIds(stepKey) {
|
|
3815
3959
|
const base2 = react.useId();
|
|
3816
3960
|
return {
|
|
@@ -3884,6 +4028,37 @@ function NodesJsonField({
|
|
|
3884
4028
|
function stringify(value) {
|
|
3885
4029
|
return JSON.stringify(value ?? null, null, 2);
|
|
3886
4030
|
}
|
|
4031
|
+
function usePromptCatalogue() {
|
|
4032
|
+
const { appSlug } = uiSdk.useAppContext();
|
|
4033
|
+
const api = uiSdk.useAppApi();
|
|
4034
|
+
const [prompts, setPrompts] = react.useState([]);
|
|
4035
|
+
const [isLoading, setIsLoading] = react.useState(true);
|
|
4036
|
+
const [error, setError] = react.useState(void 0);
|
|
4037
|
+
const clientRef = react.useRef(api);
|
|
4038
|
+
clientRef.current = api;
|
|
4039
|
+
const requestIdRef = react.useRef(0);
|
|
4040
|
+
const isMountedRef = react.useRef(true);
|
|
4041
|
+
react.useEffect(() => {
|
|
4042
|
+
isMountedRef.current = true;
|
|
4043
|
+
const requestId = ++requestIdRef.current;
|
|
4044
|
+
setIsLoading(true);
|
|
4045
|
+
void clientRef.current.get(`/data/apps/${appSlug}/prompts`).then((catalogue) => {
|
|
4046
|
+
if (requestId !== requestIdRef.current || !isMountedRef.current) return;
|
|
4047
|
+
setPrompts(catalogue);
|
|
4048
|
+
setError(void 0);
|
|
4049
|
+
}).catch((err) => {
|
|
4050
|
+
if (requestId !== requestIdRef.current || !isMountedRef.current) return;
|
|
4051
|
+
setError(err);
|
|
4052
|
+
}).finally(() => {
|
|
4053
|
+
if (requestId !== requestIdRef.current || !isMountedRef.current) return;
|
|
4054
|
+
setIsLoading(false);
|
|
4055
|
+
});
|
|
4056
|
+
return () => {
|
|
4057
|
+
isMountedRef.current = false;
|
|
4058
|
+
};
|
|
4059
|
+
}, [appSlug]);
|
|
4060
|
+
return { prompts, isLoading, error };
|
|
4061
|
+
}
|
|
3887
4062
|
var WHATSAPP_MODE_LABELS = {
|
|
3888
4063
|
escalate_only: "Escalade uniquement",
|
|
3889
4064
|
draft_only: "Brouillon uniquement",
|
|
@@ -3938,6 +4113,7 @@ function SettingsPage() {
|
|
|
3938
4113
|
const [uncheckedAppSlugs, setUncheckedAppSlugs] = react.useState([]);
|
|
3939
4114
|
const [installedAppsUnavailable, setInstalledAppsUnavailable] = react.useState(false);
|
|
3940
4115
|
const [connections, setConnections] = react.useState(void 0);
|
|
4116
|
+
const promptCatalogue = usePromptCatalogue();
|
|
3941
4117
|
const formInitializedRef = react.useRef(false);
|
|
3942
4118
|
react.useEffect(() => {
|
|
3943
4119
|
if (settings && !formInitializedRef.current) {
|
|
@@ -4305,9 +4481,15 @@ function SettingsPage() {
|
|
|
4305
4481
|
value: form.nodes,
|
|
4306
4482
|
onChange: (v) => set("nodes", v),
|
|
4307
4483
|
canWrite,
|
|
4308
|
-
issueMessage: nodesIssue ? settingsIssueLabel(nodesIssue.key, nodesIssue.message) : null
|
|
4484
|
+
issueMessage: nodesIssue ? settingsIssueLabel(nodesIssue.key, nodesIssue.message) : null,
|
|
4485
|
+
prompts: promptCatalogue.prompts,
|
|
4486
|
+
promptsLoading: promptCatalogue.isLoading
|
|
4309
4487
|
}
|
|
4310
4488
|
),
|
|
4489
|
+
promptCatalogue.error !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-destructive", children: [
|
|
4490
|
+
"Catalogue de prompts indisponible \u2014 ",
|
|
4491
|
+
describeApiError(promptCatalogue.error)
|
|
4492
|
+
] }),
|
|
4311
4493
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: `/espace/${appSlug}/graph-canvas`, children: "Visualiser dans Graphe" })
|
|
4312
4494
|
] }) }),
|
|
4313
4495
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-3 p-4", children: [
|