@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.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, computeWordDiff, DEFAULT_LLM_PROVIDER, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-
|
|
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, computeWordDiff, DEFAULT_LLM_PROVIDER, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-CVYJU4SV.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';
|
|
@@ -836,6 +836,7 @@ function idempotencyKeyFor(operation, payload) {
|
|
|
836
836
|
var SETTINGS_ISSUE_LABELS = {
|
|
837
837
|
sourceViewId: "Vue Gorgias source requise \u2014 choisissez la vue que cette app poss\xE8de.",
|
|
838
838
|
nodes: "nodes.triage doit \xEAtre configur\xE9 \u2014 une \xE9tape de triage \xE0 null ne triagerait rien.",
|
|
839
|
+
nodePrompt: "Chaque \xE9tape active doit d\xE9signer un prompt Langfuse \u2014 sans prompt, l'\xE9tape n'a rien \xE0 dire au mod\xE8le.",
|
|
839
840
|
senderEmail: "Adresse d'envoi requise quand l'envoi automatique est actif (sauf en mode WhatsApp \xAB auto_reply \xBB)."
|
|
840
841
|
};
|
|
841
842
|
function settingsIssueLabel(key, fallback) {
|
|
@@ -1985,12 +1986,14 @@ function CategoryFormModal({
|
|
|
1985
1986
|
groupId,
|
|
1986
1987
|
agentId: category?.agentId ?? "",
|
|
1987
1988
|
extraTags: category?.extraTags.join(", ") ?? "",
|
|
1989
|
+
description: category?.description ?? "",
|
|
1988
1990
|
examples: category?.examples ?? ""
|
|
1989
1991
|
});
|
|
1990
1992
|
const nameId = useId();
|
|
1991
1993
|
const tagId = useId();
|
|
1992
1994
|
const agentSelectId = useId();
|
|
1993
1995
|
const extraTagsId = useId();
|
|
1996
|
+
const descriptionId = useId();
|
|
1994
1997
|
const examplesId = useId();
|
|
1995
1998
|
const isValid = form.name.trim() !== "" && form.tagName.trim() !== "";
|
|
1996
1999
|
async function submit(event) {
|
|
@@ -2040,6 +2043,18 @@ function CategoryFormModal({
|
|
|
2040
2043
|
}
|
|
2041
2044
|
)
|
|
2042
2045
|
] }),
|
|
2046
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2047
|
+
/* @__PURE__ */ jsx("label", { htmlFor: descriptionId, className: "mb-1 block text-sm font-medium", children: "Description" }),
|
|
2048
|
+
/* @__PURE__ */ jsx(
|
|
2049
|
+
Textarea,
|
|
2050
|
+
{
|
|
2051
|
+
id: descriptionId,
|
|
2052
|
+
value: form.description,
|
|
2053
|
+
onChange: (e) => setForm({ ...form, description: e.target.value })
|
|
2054
|
+
}
|
|
2055
|
+
),
|
|
2056
|
+
/* @__PURE__ */ 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." })
|
|
2057
|
+
] }),
|
|
2043
2058
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2044
2059
|
/* @__PURE__ */ jsx("label", { htmlFor: examplesId, className: "mb-1 block text-sm font-medium", children: "Exemples" }),
|
|
2045
2060
|
/* @__PURE__ */ jsx(
|
|
@@ -2121,6 +2136,10 @@ function CategoriesPage() {
|
|
|
2121
2136
|
groupId: form.groupId || null,
|
|
2122
2137
|
agentId: form.agentId || null,
|
|
2123
2138
|
extraTags: form.extraTags.split(",").map((t) => t.trim()).filter(Boolean),
|
|
2139
|
+
// Explicit, `null` when blank — never omitted: the platform validates a
|
|
2140
|
+
// record write against the declared fields, and a declared-but-absent
|
|
2141
|
+
// key is a 422 (same trap as the graph-dry-run payload fixed in 2.7.1).
|
|
2142
|
+
description: form.description.trim() || null,
|
|
2124
2143
|
examples: form.examples
|
|
2125
2144
|
};
|
|
2126
2145
|
try {
|
|
@@ -3050,6 +3069,25 @@ function stepBoolean(step, field2, fallback) {
|
|
|
3050
3069
|
const value = step?.[field2];
|
|
3051
3070
|
return typeof value === "boolean" ? value : fallback;
|
|
3052
3071
|
}
|
|
3072
|
+
function stepUsesAgentPrompt(key) {
|
|
3073
|
+
return key === "draft";
|
|
3074
|
+
}
|
|
3075
|
+
var DEFAULT_PROMPT_LABEL = "production";
|
|
3076
|
+
function stepPromptName(step) {
|
|
3077
|
+
return readPromptField(step, "name");
|
|
3078
|
+
}
|
|
3079
|
+
function stepPromptLabel(step) {
|
|
3080
|
+
return readPromptField(step, "label") || DEFAULT_PROMPT_LABEL;
|
|
3081
|
+
}
|
|
3082
|
+
function readPromptField(step, field2) {
|
|
3083
|
+
const prompt = step?.prompt;
|
|
3084
|
+
if (typeof prompt !== "object" || prompt === null) return "";
|
|
3085
|
+
const value = prompt[field2];
|
|
3086
|
+
return typeof value === "string" ? value : "";
|
|
3087
|
+
}
|
|
3088
|
+
function promptPatch(name, label) {
|
|
3089
|
+
return { prompt: { name, label } };
|
|
3090
|
+
}
|
|
3053
3091
|
function stepReasoning(step) {
|
|
3054
3092
|
const value = step?.reasoning;
|
|
3055
3093
|
return REASONING_EFFORTS.some((effort) => effort.value === value) ? value : "off";
|
|
@@ -3129,7 +3167,14 @@ function applyPreset(value, preset, restore) {
|
|
|
3129
3167
|
return next;
|
|
3130
3168
|
}
|
|
3131
3169
|
var PERCENT = 100;
|
|
3132
|
-
function PipelineNodesForm({
|
|
3170
|
+
function PipelineNodesForm({
|
|
3171
|
+
value,
|
|
3172
|
+
onChange,
|
|
3173
|
+
canWrite,
|
|
3174
|
+
issueMessage,
|
|
3175
|
+
prompts,
|
|
3176
|
+
promptsLoading = false
|
|
3177
|
+
}) {
|
|
3133
3178
|
const [remembered, setRemembered] = useState({});
|
|
3134
3179
|
useEffect(() => {
|
|
3135
3180
|
setRemembered((prev) => {
|
|
@@ -3174,6 +3219,8 @@ function PipelineNodesForm({ value, onChange, canWrite, issueMessage }) {
|
|
|
3174
3219
|
value,
|
|
3175
3220
|
canWrite,
|
|
3176
3221
|
issueMessage: step.key === "triage" ? issueMessage : null,
|
|
3222
|
+
prompts,
|
|
3223
|
+
promptsLoading,
|
|
3177
3224
|
onToggle: (on) => toggleStep(step.key, on),
|
|
3178
3225
|
onPatch: (patch) => onChange(withStepFields(value, step.key, patch))
|
|
3179
3226
|
},
|
|
@@ -3190,11 +3237,14 @@ function StepRow({
|
|
|
3190
3237
|
value,
|
|
3191
3238
|
canWrite,
|
|
3192
3239
|
issueMessage,
|
|
3240
|
+
prompts,
|
|
3241
|
+
promptsLoading,
|
|
3193
3242
|
onToggle,
|
|
3194
3243
|
onPatch
|
|
3195
3244
|
}) {
|
|
3196
3245
|
const enabled = isStepEnabled(value, step.key);
|
|
3197
3246
|
const blockedReason = stepBlockedReason(value, step.key);
|
|
3247
|
+
const promptFieldId = useId();
|
|
3198
3248
|
const triageLocked = step.key === "triage" && enabled;
|
|
3199
3249
|
const editable = canWrite && !blockedReason && !triageLocked;
|
|
3200
3250
|
const toggle = /* @__PURE__ */ jsx(
|
|
@@ -3219,6 +3269,21 @@ function StepRow({
|
|
|
3219
3269
|
] }),
|
|
3220
3270
|
blockedReason && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: blockedReason }),
|
|
3221
3271
|
issueMessage && !enabled && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: issueMessage }),
|
|
3272
|
+
enabled && // In the row itself, NOT behind « Options »: this is the one field
|
|
3273
|
+
// without which the step cannot run at all, so it is stated where the
|
|
3274
|
+
// step is, next to its own switch.
|
|
3275
|
+
/* @__PURE__ */ jsx("div", { className: "rounded-md bg-muted/40 p-3", children: /* @__PURE__ */ jsx(
|
|
3276
|
+
StepPromptField,
|
|
3277
|
+
{
|
|
3278
|
+
step,
|
|
3279
|
+
settings: readStep(value, step.key),
|
|
3280
|
+
disabled: !canWrite || blockedReason !== null,
|
|
3281
|
+
prompts,
|
|
3282
|
+
promptsLoading,
|
|
3283
|
+
id: promptFieldId,
|
|
3284
|
+
onPatch
|
|
3285
|
+
}
|
|
3286
|
+
) }),
|
|
3222
3287
|
enabled && /* @__PURE__ */ jsxs("details", { children: [
|
|
3223
3288
|
/* @__PURE__ */ jsx("summary", { className: "cursor-pointer text-sm text-muted-foreground", children: "Options" }),
|
|
3224
3289
|
/* @__PURE__ */ jsx("div", { className: "mt-3 grid gap-4 rounded-md bg-muted/40 p-3 sm:grid-cols-2", children: /* @__PURE__ */ jsx(
|
|
@@ -3357,6 +3422,63 @@ function StepOptions({
|
|
|
3357
3422
|
] })
|
|
3358
3423
|
] });
|
|
3359
3424
|
}
|
|
3425
|
+
function StepPromptField({
|
|
3426
|
+
step,
|
|
3427
|
+
settings,
|
|
3428
|
+
disabled,
|
|
3429
|
+
prompts,
|
|
3430
|
+
promptsLoading,
|
|
3431
|
+
id,
|
|
3432
|
+
onPatch
|
|
3433
|
+
}) {
|
|
3434
|
+
if (stepUsesAgentPrompt(step.key)) {
|
|
3435
|
+
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." });
|
|
3436
|
+
}
|
|
3437
|
+
const name = stepPromptName(settings);
|
|
3438
|
+
const label = stepPromptLabel(settings);
|
|
3439
|
+
const known = prompts.find((entry) => entry.name === name);
|
|
3440
|
+
const orphaned = name !== "" && !known && !promptsLoading;
|
|
3441
|
+
const labels = known?.labels.length ? known.labels : [DEFAULT_PROMPT_LABEL];
|
|
3442
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3443
|
+
/* @__PURE__ */ jsx("label", { htmlFor: id, className: "mb-1 block text-sm font-medium", children: "Prompt Langfuse" }),
|
|
3444
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2 sm:grid-cols-2", children: [
|
|
3445
|
+
/* @__PURE__ */ jsx(
|
|
3446
|
+
Select,
|
|
3447
|
+
{
|
|
3448
|
+
"aria-label": `Prompt \u2014 ${step.label}`,
|
|
3449
|
+
value: known ? name : void 0,
|
|
3450
|
+
onValueChange: (next) => onPatch(promptPatch(next, DEFAULT_PROMPT_LABEL)),
|
|
3451
|
+
items: [
|
|
3452
|
+
...orphaned ? [{ value: name, label: `${name} \u2014 introuvable dans Langfuse` }] : [],
|
|
3453
|
+
...prompts.map((entry) => ({ value: entry.name, label: entry.name }))
|
|
3454
|
+
],
|
|
3455
|
+
disabled: disabled || promptsLoading
|
|
3456
|
+
}
|
|
3457
|
+
),
|
|
3458
|
+
/* @__PURE__ */ jsx(
|
|
3459
|
+
Select,
|
|
3460
|
+
{
|
|
3461
|
+
"aria-label": `Version du prompt \u2014 ${step.label}`,
|
|
3462
|
+
value: labels.includes(label) ? label : void 0,
|
|
3463
|
+
onValueChange: (next) => onPatch(promptPatch(name, next)),
|
|
3464
|
+
items: labels.map((entry) => ({ value: entry, label: entry })),
|
|
3465
|
+
disabled: disabled || promptsLoading || name === ""
|
|
3466
|
+
}
|
|
3467
|
+
)
|
|
3468
|
+
] }),
|
|
3469
|
+
name === "" && !promptsLoading && /* @__PURE__ */ 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." }),
|
|
3470
|
+
orphaned && /* @__PURE__ */ jsxs("p", { className: "mt-1 text-sm text-destructive", children: [
|
|
3471
|
+
"\xAB ",
|
|
3472
|
+
name,
|
|
3473
|
+
" \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."
|
|
3474
|
+
] }),
|
|
3475
|
+
/* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs text-muted-foreground", children: [
|
|
3476
|
+
"Le label suit les promotions faites dans Langfuse : promouvoir une nouvelle version sous \xAB ",
|
|
3477
|
+
label,
|
|
3478
|
+
" \xBB la met en service sans repasser ici."
|
|
3479
|
+
] })
|
|
3480
|
+
] });
|
|
3481
|
+
}
|
|
3360
3482
|
function useIds(stepKey) {
|
|
3361
3483
|
const base2 = useId();
|
|
3362
3484
|
return {
|
|
@@ -3430,6 +3552,37 @@ function NodesJsonField({
|
|
|
3430
3552
|
function stringify(value) {
|
|
3431
3553
|
return JSON.stringify(value ?? null, null, 2);
|
|
3432
3554
|
}
|
|
3555
|
+
function usePromptCatalogue() {
|
|
3556
|
+
const { appSlug } = useAppContext();
|
|
3557
|
+
const api = useAppApi();
|
|
3558
|
+
const [prompts, setPrompts] = useState([]);
|
|
3559
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
3560
|
+
const [error, setError] = useState(void 0);
|
|
3561
|
+
const clientRef = useRef(api);
|
|
3562
|
+
clientRef.current = api;
|
|
3563
|
+
const requestIdRef = useRef(0);
|
|
3564
|
+
const isMountedRef = useRef(true);
|
|
3565
|
+
useEffect(() => {
|
|
3566
|
+
isMountedRef.current = true;
|
|
3567
|
+
const requestId = ++requestIdRef.current;
|
|
3568
|
+
setIsLoading(true);
|
|
3569
|
+
void clientRef.current.get(`/data/apps/${appSlug}/prompts`).then((catalogue) => {
|
|
3570
|
+
if (requestId !== requestIdRef.current || !isMountedRef.current) return;
|
|
3571
|
+
setPrompts(catalogue);
|
|
3572
|
+
setError(void 0);
|
|
3573
|
+
}).catch((err) => {
|
|
3574
|
+
if (requestId !== requestIdRef.current || !isMountedRef.current) return;
|
|
3575
|
+
setError(err);
|
|
3576
|
+
}).finally(() => {
|
|
3577
|
+
if (requestId !== requestIdRef.current || !isMountedRef.current) return;
|
|
3578
|
+
setIsLoading(false);
|
|
3579
|
+
});
|
|
3580
|
+
return () => {
|
|
3581
|
+
isMountedRef.current = false;
|
|
3582
|
+
};
|
|
3583
|
+
}, [appSlug]);
|
|
3584
|
+
return { prompts, isLoading, error };
|
|
3585
|
+
}
|
|
3433
3586
|
var WHATSAPP_MODE_LABELS = {
|
|
3434
3587
|
escalate_only: "Escalade uniquement",
|
|
3435
3588
|
draft_only: "Brouillon uniquement",
|
|
@@ -3484,6 +3637,7 @@ function SettingsPage() {
|
|
|
3484
3637
|
const [uncheckedAppSlugs, setUncheckedAppSlugs] = useState([]);
|
|
3485
3638
|
const [installedAppsUnavailable, setInstalledAppsUnavailable] = useState(false);
|
|
3486
3639
|
const [connections, setConnections] = useState(void 0);
|
|
3640
|
+
const promptCatalogue = usePromptCatalogue();
|
|
3487
3641
|
const formInitializedRef = useRef(false);
|
|
3488
3642
|
useEffect(() => {
|
|
3489
3643
|
if (settings && !formInitializedRef.current) {
|
|
@@ -3851,9 +4005,15 @@ function SettingsPage() {
|
|
|
3851
4005
|
value: form.nodes,
|
|
3852
4006
|
onChange: (v) => set("nodes", v),
|
|
3853
4007
|
canWrite,
|
|
3854
|
-
issueMessage: nodesIssue ? settingsIssueLabel(nodesIssue.key, nodesIssue.message) : null
|
|
4008
|
+
issueMessage: nodesIssue ? settingsIssueLabel(nodesIssue.key, nodesIssue.message) : null,
|
|
4009
|
+
prompts: promptCatalogue.prompts,
|
|
4010
|
+
promptsLoading: promptCatalogue.isLoading
|
|
3855
4011
|
}
|
|
3856
4012
|
),
|
|
4013
|
+
promptCatalogue.error !== void 0 && /* @__PURE__ */ jsxs("p", { className: "text-sm text-destructive", children: [
|
|
4014
|
+
"Catalogue de prompts indisponible \u2014 ",
|
|
4015
|
+
describeApiError(promptCatalogue.error)
|
|
4016
|
+
] }),
|
|
3857
4017
|
/* @__PURE__ */ jsx(Link, { href: `/espace/${appSlug}/graph-canvas`, children: "Visualiser dans Graphe" })
|
|
3858
4018
|
] }) }),
|
|
3859
4019
|
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-3 p-4", children: [
|