@apotech-os/support-kit 2.8.0 → 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-47QWWJBP.js → chunk-CVYJU4SV.js} +47 -15
- package/dist/chunk-CVYJU4SV.js.map +1 -0
- package/dist/index.cjs +74 -60
- 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 +31 -50
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +165 -2
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +145 -3
- package/dist/ui/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-47QWWJBP.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) {
|
|
@@ -3068,6 +3069,25 @@ function stepBoolean(step, field2, fallback) {
|
|
|
3068
3069
|
const value = step?.[field2];
|
|
3069
3070
|
return typeof value === "boolean" ? value : fallback;
|
|
3070
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
|
+
}
|
|
3071
3091
|
function stepReasoning(step) {
|
|
3072
3092
|
const value = step?.reasoning;
|
|
3073
3093
|
return REASONING_EFFORTS.some((effort) => effort.value === value) ? value : "off";
|
|
@@ -3147,7 +3167,14 @@ function applyPreset(value, preset, restore) {
|
|
|
3147
3167
|
return next;
|
|
3148
3168
|
}
|
|
3149
3169
|
var PERCENT = 100;
|
|
3150
|
-
function PipelineNodesForm({
|
|
3170
|
+
function PipelineNodesForm({
|
|
3171
|
+
value,
|
|
3172
|
+
onChange,
|
|
3173
|
+
canWrite,
|
|
3174
|
+
issueMessage,
|
|
3175
|
+
prompts,
|
|
3176
|
+
promptsLoading = false
|
|
3177
|
+
}) {
|
|
3151
3178
|
const [remembered, setRemembered] = useState({});
|
|
3152
3179
|
useEffect(() => {
|
|
3153
3180
|
setRemembered((prev) => {
|
|
@@ -3192,6 +3219,8 @@ function PipelineNodesForm({ value, onChange, canWrite, issueMessage }) {
|
|
|
3192
3219
|
value,
|
|
3193
3220
|
canWrite,
|
|
3194
3221
|
issueMessage: step.key === "triage" ? issueMessage : null,
|
|
3222
|
+
prompts,
|
|
3223
|
+
promptsLoading,
|
|
3195
3224
|
onToggle: (on) => toggleStep(step.key, on),
|
|
3196
3225
|
onPatch: (patch) => onChange(withStepFields(value, step.key, patch))
|
|
3197
3226
|
},
|
|
@@ -3208,11 +3237,14 @@ function StepRow({
|
|
|
3208
3237
|
value,
|
|
3209
3238
|
canWrite,
|
|
3210
3239
|
issueMessage,
|
|
3240
|
+
prompts,
|
|
3241
|
+
promptsLoading,
|
|
3211
3242
|
onToggle,
|
|
3212
3243
|
onPatch
|
|
3213
3244
|
}) {
|
|
3214
3245
|
const enabled = isStepEnabled(value, step.key);
|
|
3215
3246
|
const blockedReason = stepBlockedReason(value, step.key);
|
|
3247
|
+
const promptFieldId = useId();
|
|
3216
3248
|
const triageLocked = step.key === "triage" && enabled;
|
|
3217
3249
|
const editable = canWrite && !blockedReason && !triageLocked;
|
|
3218
3250
|
const toggle = /* @__PURE__ */ jsx(
|
|
@@ -3237,6 +3269,21 @@ function StepRow({
|
|
|
3237
3269
|
] }),
|
|
3238
3270
|
blockedReason && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: blockedReason }),
|
|
3239
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
|
+
) }),
|
|
3240
3287
|
enabled && /* @__PURE__ */ jsxs("details", { children: [
|
|
3241
3288
|
/* @__PURE__ */ jsx("summary", { className: "cursor-pointer text-sm text-muted-foreground", children: "Options" }),
|
|
3242
3289
|
/* @__PURE__ */ jsx("div", { className: "mt-3 grid gap-4 rounded-md bg-muted/40 p-3 sm:grid-cols-2", children: /* @__PURE__ */ jsx(
|
|
@@ -3375,6 +3422,63 @@ function StepOptions({
|
|
|
3375
3422
|
] })
|
|
3376
3423
|
] });
|
|
3377
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
|
+
}
|
|
3378
3482
|
function useIds(stepKey) {
|
|
3379
3483
|
const base2 = useId();
|
|
3380
3484
|
return {
|
|
@@ -3448,6 +3552,37 @@ function NodesJsonField({
|
|
|
3448
3552
|
function stringify(value) {
|
|
3449
3553
|
return JSON.stringify(value ?? null, null, 2);
|
|
3450
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
|
+
}
|
|
3451
3586
|
var WHATSAPP_MODE_LABELS = {
|
|
3452
3587
|
escalate_only: "Escalade uniquement",
|
|
3453
3588
|
draft_only: "Brouillon uniquement",
|
|
@@ -3502,6 +3637,7 @@ function SettingsPage() {
|
|
|
3502
3637
|
const [uncheckedAppSlugs, setUncheckedAppSlugs] = useState([]);
|
|
3503
3638
|
const [installedAppsUnavailable, setInstalledAppsUnavailable] = useState(false);
|
|
3504
3639
|
const [connections, setConnections] = useState(void 0);
|
|
3640
|
+
const promptCatalogue = usePromptCatalogue();
|
|
3505
3641
|
const formInitializedRef = useRef(false);
|
|
3506
3642
|
useEffect(() => {
|
|
3507
3643
|
if (settings && !formInitializedRef.current) {
|
|
@@ -3869,9 +4005,15 @@ function SettingsPage() {
|
|
|
3869
4005
|
value: form.nodes,
|
|
3870
4006
|
onChange: (v) => set("nodes", v),
|
|
3871
4007
|
canWrite,
|
|
3872
|
-
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
|
|
3873
4011
|
}
|
|
3874
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
|
+
] }),
|
|
3875
4017
|
/* @__PURE__ */ jsx(Link, { href: `/espace/${appSlug}/graph-canvas`, children: "Visualiser dans Graphe" })
|
|
3876
4018
|
] }) }),
|
|
3877
4019
|
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-3 p-4", children: [
|