@apotech-os/support-kit 10.4.0 → 10.6.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/README.md +8 -5
- package/dist/{chunk-ZKFQ3DIY.js → chunk-CQQANQLB.js} +94 -6
- package/dist/chunk-CQQANQLB.js.map +1 -0
- package/dist/index.cjs +214 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +89 -1
- package/dist/index.d.ts +89 -1
- package/dist/index.js +131 -43
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +565 -137
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +403 -30
- package/dist/ui/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-ZKFQ3DIY.js.map +0 -1
package/dist/ui/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EVALUATION_VERDICTS, WHATSAPP_MODES, foldOutcomes, foldDailyOutcomes, fillMissingDays, autonomyRate, settledCount, countFailed, dashboardSignals, foldHumanReasons, foldCategoryOutcomes, toDeliveryPolicy, validateSettings, settingsWarnings, SUPPORT_CHANNELS, AGENT_GUARDRAILS, periodBoundsOf, toCategory, OUTCOME_METRICS, OUTCOME_GROUP_BY, TRIAGE_HANDOFF_GROUP_BY, CATEGORY_TRIAGE_GROUP_BY, CATEGORY_OUTCOME_GROUP_BY, ratePoints, REPLY_TIMING_METRICS, REPLY_TIMING_GROUP_BY, foldReplyTimings, DELAY_BUCKETS, toGeneratedResponse, toTriageDecision, toAgent, toResponseComparison, isGeneratedResponseStatus, isInvalidatableStatus, toCategoryGroup, followupIntegrationName, FOLLOWUP_WEBHOOK_TRIGGER, followupWebhookPath, FOLLOWUP_WEBHOOK_FORM, readConversationEnd, DEFAULT_CONVERSATION_END_TAG, NODE_NAMES, settingsToProfile, hasNoDraftNode, buildTimelineSteps, conversationEndEffects, outcomeTags, DEFAULT_LLM_PROVIDER, computeWordDiff, isSendableVerdict, COLLISION_GUARDRAILS, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-
|
|
2
|
-
import { forwardRef,
|
|
3
|
-
import { Textarea,
|
|
1
|
+
import { EVALUATION_VERDICTS, WHATSAPP_MODES, toSharedPromptUsages, promptUsageOf, REFERENCE_TAG_SOURCE, isPromptUsedIn, foldOutcomes, foldDailyOutcomes, fillMissingDays, autonomyRate, settledCount, countFailed, dashboardSignals, foldHumanReasons, foldCategoryOutcomes, toDeliveryPolicy, DEFAULT_PROMPT_USAGE, validateSettings, settingsWarnings, SUPPORT_CHANNELS, AGENT_GUARDRAILS, SYSTEM_PROMPTS, systemPromptOf, periodBoundsOf, toCategory, OUTCOME_METRICS, OUTCOME_GROUP_BY, TRIAGE_HANDOFF_GROUP_BY, CATEGORY_TRIAGE_GROUP_BY, CATEGORY_OUTCOME_GROUP_BY, ratePoints, REPLY_TIMING_METRICS, REPLY_TIMING_GROUP_BY, foldReplyTimings, DELAY_BUCKETS, toGeneratedResponse, toTriageDecision, toAgent, toResponseComparison, isGeneratedResponseStatus, isInvalidatableStatus, toCategoryGroup, followupIntegrationName, FOLLOWUP_WEBHOOK_TRIGGER, followupWebhookPath, FOLLOWUP_WEBHOOK_FORM, readConversationEnd, DEFAULT_CONVERSATION_END_TAG, NODE_NAMES, settingsToProfile, hasNoDraftNode, isPromptUsage, buildTimelineSteps, conversationEndEffects, outcomeTags, DEFAULT_LLM_PROVIDER, computeWordDiff, isSendableVerdict, COLLISION_GUARDRAILS, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-CQQANQLB.js';
|
|
2
|
+
import { forwardRef, useMemo, useRef, useState, useEffect, useCallback, useId } from 'react';
|
|
3
|
+
import { cn, Textarea, useAppContext, useAppApi, useAppSettings, useAppPageHref, DateRangeCompare, Link, Card, CardHeader, CardTitle, CardContent, AreaChart, StackedBarChart, Badge, useToast, Button, Select, DataTable, Spinner, Switch, Checkbox, Input, comparisonRange, SidePanel, Modal, Tooltip, buttonVariants, useAppRun, AppInvokeError, CopyButton, relativeDelta, Table, TableHeader, TableRow, TableHead, TableBody, TableCell, downloadBlob } from '@apotech-os/ui-sdk';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
function useRecordList(objectKey, query, mapper) {
|
|
@@ -2156,7 +2156,7 @@ var PIPELINE_STEPS = [
|
|
|
2156
2156
|
{
|
|
2157
2157
|
key: "draft",
|
|
2158
2158
|
label: "R\xE9daction",
|
|
2159
|
-
description: "pr\xE9pare un projet de r\xE9ponse",
|
|
2159
|
+
description: "pr\xE9pare un projet de r\xE9ponse \u2014 mod\xE8le et effort par d\xE9faut des agents qui n'en pr\xE9cisent pas",
|
|
2160
2160
|
requires: null,
|
|
2161
2161
|
blockedReason: null
|
|
2162
2162
|
},
|
|
@@ -2170,7 +2170,7 @@ var PIPELINE_STEPS = [
|
|
|
2170
2170
|
{
|
|
2171
2171
|
key: "revise",
|
|
2172
2172
|
label: "R\xE9vision",
|
|
2173
|
-
description: "r\xE9\xE9crit la r\xE9ponse si l'\xE9valuation la juge insuffisante",
|
|
2173
|
+
description: "r\xE9\xE9crit la r\xE9ponse si l'\xE9valuation la juge insuffisante, avec le mod\xE8le et l'effort de l'agent qui l'a r\xE9dig\xE9e \u2014 ceux-ci \xE0 d\xE9faut",
|
|
2174
2174
|
requires: "evaluate",
|
|
2175
2175
|
blockedReason: "Sans \xE9valuation, rien ne d\xE9clenche une r\xE9vision."
|
|
2176
2176
|
}
|
|
@@ -2380,29 +2380,254 @@ function ConfirmModal({
|
|
|
2380
2380
|
] })
|
|
2381
2381
|
] }) });
|
|
2382
2382
|
}
|
|
2383
|
+
|
|
2384
|
+
// src/prompts/syntax.ts
|
|
2385
|
+
var PROMPT_VARIABLES = {
|
|
2386
|
+
agent_name: { replacedBy: "le pr\xE9nom de la personne qui r\xE9pond, vide quand l'agent r\xE9pond seul", allowsSpaces: true },
|
|
2387
|
+
categories: { replacedBy: "la liste des cat\xE9gories, dans le prompt de tri uniquement", allowsSpaces: false },
|
|
2388
|
+
channel_prompt: { replacedBy: null, allowsSpaces: false }
|
|
2389
|
+
};
|
|
2390
|
+
var USAGE_SENTENCES = {
|
|
2391
|
+
always: "Inclus dans toutes les r\xE9ponses.",
|
|
2392
|
+
auto: "R\xE9ponse automatique seulement : ignor\xE9 quand un membre de l'\xE9quipe g\xE9n\xE8re une r\xE9ponse depuis l'extension.",
|
|
2393
|
+
operator: "Op\xE9rateur seulement : ignor\xE9 quand l'agent r\xE9pond seul."
|
|
2394
|
+
};
|
|
2395
|
+
var TAG_PREFIX = "@@@langfusePrompt:";
|
|
2396
|
+
var TAG_EXAMPLE = "@@@langfusePrompt:name=shared/nom|label=production@@@";
|
|
2397
|
+
var VARIABLE_RE = /\{\{([^{}\n]*)\}\}/g;
|
|
2398
|
+
var UNCLOSED_VARIABLE_RE = /\{\{(?![^{}\n]*\}\})[^\n]*/g;
|
|
2399
|
+
function referenceTokens(content, knowledge) {
|
|
2400
|
+
const tokens = [];
|
|
2401
|
+
const wellFormedStarts = /* @__PURE__ */ new Set();
|
|
2402
|
+
for (const match of content.matchAll(new RegExp(REFERENCE_TAG_SOURCE, "g"))) {
|
|
2403
|
+
const [raw, name, version, label] = match;
|
|
2404
|
+
const start = match.index ?? 0;
|
|
2405
|
+
wellFormedStarts.add(start);
|
|
2406
|
+
tokens.push({ start, end: start + raw.length, kind: "reference", ...describeReference(name, version, label, knowledge) });
|
|
2407
|
+
}
|
|
2408
|
+
let from = content.indexOf(TAG_PREFIX);
|
|
2409
|
+
while (from !== -1) {
|
|
2410
|
+
if (!wellFormedStarts.has(from)) {
|
|
2411
|
+
tokens.push({
|
|
2412
|
+
start: from,
|
|
2413
|
+
end: malformedEnd(content, from),
|
|
2414
|
+
kind: "malformed",
|
|
2415
|
+
status: "error",
|
|
2416
|
+
message: `R\xE9f\xE9rence mal form\xE9e, elle sera envoy\xE9e telle quelle au mod\xE8le. Forme attendue : ${TAG_EXAMPLE}`
|
|
2417
|
+
});
|
|
2418
|
+
}
|
|
2419
|
+
from = content.indexOf(TAG_PREFIX, from + TAG_PREFIX.length);
|
|
2420
|
+
}
|
|
2421
|
+
return tokens;
|
|
2422
|
+
}
|
|
2423
|
+
function malformedEnd(content, start) {
|
|
2424
|
+
const lineEnd = content.indexOf("\n", start);
|
|
2425
|
+
const limit = lineEnd === -1 ? content.length : lineEnd;
|
|
2426
|
+
const closing = content.indexOf("@@@", start + TAG_PREFIX.length);
|
|
2427
|
+
return closing !== -1 && closing < limit ? closing + 3 : limit;
|
|
2428
|
+
}
|
|
2429
|
+
function describeReference(name, version, label, knowledge) {
|
|
2430
|
+
const entry = knowledge.catalogue?.find((prompt) => prompt.name === name);
|
|
2431
|
+
if (knowledge.catalogue && !entry) {
|
|
2432
|
+
return { status: "error", message: `Prompt introuvable : \xAB ${name} \xBB n'existe pas ou n'est pas accessible depuis cette app.` };
|
|
2433
|
+
}
|
|
2434
|
+
if (entry && version !== void 0 && Number(version) > entry.latestVersion) {
|
|
2435
|
+
return { status: "error", message: `La version ${version} de \xAB ${name} \xBB n'existe pas (derni\xE8re version : ${entry.latestVersion}).` };
|
|
2436
|
+
}
|
|
2437
|
+
if (entry && label !== void 0 && !entry.labels.includes(label)) {
|
|
2438
|
+
return { status: "error", message: `Aucune version de \xAB ${name} \xBB ne porte le label \xAB ${label} \xBB.` };
|
|
2439
|
+
}
|
|
2440
|
+
const usage = promptUsageOf(name, knowledge.usages);
|
|
2441
|
+
const target = version !== void 0 ? `version ${version}` : `label \xAB ${label} \xBB`;
|
|
2442
|
+
return {
|
|
2443
|
+
status: isPromptUsedIn("auto", usage) && isPromptUsedIn("operator", usage) ? "ok" : "restricted",
|
|
2444
|
+
message: `Prompt \xAB ${name} \xBB, ${target}. ${USAGE_SENTENCES[usage]}`
|
|
2445
|
+
};
|
|
2446
|
+
}
|
|
2447
|
+
function variableTokens(content) {
|
|
2448
|
+
const tokens = [];
|
|
2449
|
+
for (const match of content.matchAll(VARIABLE_RE)) {
|
|
2450
|
+
const start = match.index ?? 0;
|
|
2451
|
+
const inner = match[1] ?? "";
|
|
2452
|
+
tokens.push({ start, end: start + match[0].length, kind: "variable", ...describeVariable(inner) });
|
|
2453
|
+
}
|
|
2454
|
+
for (const match of content.matchAll(UNCLOSED_VARIABLE_RE)) {
|
|
2455
|
+
const start = match.index ?? 0;
|
|
2456
|
+
tokens.push({
|
|
2457
|
+
start,
|
|
2458
|
+
end: start + match[0].length,
|
|
2459
|
+
kind: "variable",
|
|
2460
|
+
status: "error",
|
|
2461
|
+
message: "Accolades \xAB {{ \xBB sans fermeture \xAB }} \xBB sur la m\xEAme ligne."
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
return tokens;
|
|
2465
|
+
}
|
|
2466
|
+
function describeVariable(inner) {
|
|
2467
|
+
const name = inner.trim();
|
|
2468
|
+
const known = PROMPT_VARIABLES[name];
|
|
2469
|
+
if (!known) {
|
|
2470
|
+
return {
|
|
2471
|
+
status: "error",
|
|
2472
|
+
message: `Variable inconnue : \xAB {{${name}}} \xBB ne sera pas remplac\xE9e. Variables disponibles : ${Object.keys(PROMPT_VARIABLES).join(", ")}.`
|
|
2473
|
+
};
|
|
2474
|
+
}
|
|
2475
|
+
if (known.replacedBy === null) {
|
|
2476
|
+
return { status: "error", message: `\xAB {{${name}}} \xBB n'est pas remplac\xE9e pour l'instant : elle arrive telle quelle au mod\xE8le.` };
|
|
2477
|
+
}
|
|
2478
|
+
if (inner !== name && !known.allowsSpaces) {
|
|
2479
|
+
return { status: "error", message: `\xC9crire \xAB {{${name}}} \xBB sans espaces, sinon la variable n'est pas remplac\xE9e.` };
|
|
2480
|
+
}
|
|
2481
|
+
return { status: "ok", message: `Variable remplac\xE9e par ${known.replacedBy}.` };
|
|
2482
|
+
}
|
|
2483
|
+
function readPromptSyntax(content, knowledge) {
|
|
2484
|
+
const drafts = [...referenceTokens(content, knowledge), ...variableTokens(content)].sort((a, b) => a.start - b.start);
|
|
2485
|
+
const tokens = [];
|
|
2486
|
+
let cursor = 0;
|
|
2487
|
+
let line = 1;
|
|
2488
|
+
let counted = 0;
|
|
2489
|
+
for (const draft of drafts) {
|
|
2490
|
+
if (draft.start < cursor) continue;
|
|
2491
|
+
for (; counted < draft.start; counted += 1) if (content[counted] === "\n") line += 1;
|
|
2492
|
+
tokens.push({ ...draft, line });
|
|
2493
|
+
cursor = draft.end;
|
|
2494
|
+
}
|
|
2495
|
+
return tokens;
|
|
2496
|
+
}
|
|
2497
|
+
var PROMPT_USAGE_LABELS = {
|
|
2498
|
+
always: "Toujours",
|
|
2499
|
+
auto: "R\xE9ponse automatique seulement",
|
|
2500
|
+
operator: "Op\xE9rateur seulement"
|
|
2501
|
+
};
|
|
2502
|
+
var PROMPT_USAGE_HINTS = {
|
|
2503
|
+
always: "Inclus dans toutes les r\xE9ponses.",
|
|
2504
|
+
auto: "Inclus seulement quand l'agent r\xE9pond seul. Ignor\xE9 quand un membre de l'\xE9quipe g\xE9n\xE8re une r\xE9ponse depuis l'extension.",
|
|
2505
|
+
operator: "Inclus seulement quand un membre de l'\xE9quipe g\xE9n\xE8re une r\xE9ponse depuis l'extension. Ignor\xE9 quand l'agent r\xE9pond seul."
|
|
2506
|
+
};
|
|
2507
|
+
var PROMPT_USAGE_OPTIONS = Object.keys(PROMPT_USAGE_LABELS).map((value) => ({
|
|
2508
|
+
value,
|
|
2509
|
+
label: PROMPT_USAGE_LABELS[value]
|
|
2510
|
+
}));
|
|
2511
|
+
function useSharedPromptUsages() {
|
|
2512
|
+
const { settings, error, save, isSaving, saveError } = useAppSettings();
|
|
2513
|
+
const usages = toSharedPromptUsages(settings?.sharedPromptUsages);
|
|
2514
|
+
const isReady = settings !== void 0 && error === void 0;
|
|
2515
|
+
return {
|
|
2516
|
+
usages,
|
|
2517
|
+
usageOf: (name) => promptUsageOf(name, usages),
|
|
2518
|
+
isReady,
|
|
2519
|
+
setUsage: (name, usage) => {
|
|
2520
|
+
if (!isReady) return Promise.resolve();
|
|
2521
|
+
const next = { ...usages };
|
|
2522
|
+
if (usage === DEFAULT_PROMPT_USAGE) delete next[name];
|
|
2523
|
+
else next[name] = usage;
|
|
2524
|
+
return save({ sharedPromptUsages: next });
|
|
2525
|
+
},
|
|
2526
|
+
isSaving,
|
|
2527
|
+
saveError
|
|
2528
|
+
};
|
|
2529
|
+
}
|
|
2383
2530
|
var PROMPT_PANEL_CLASS = "w-[min(92vw,64rem)] max-w-none";
|
|
2384
2531
|
var PRODUCTION_LABEL = "production";
|
|
2532
|
+
var TOKEN_CLASSES = {
|
|
2533
|
+
ok: "rounded-sm bg-status-info/15 text-status-info",
|
|
2534
|
+
restricted: "rounded-sm bg-status-pending/15 text-status-pending underline decoration-dashed underline-offset-2",
|
|
2535
|
+
error: "rounded-sm bg-status-blocked/15 text-status-blocked underline decoration-wavy underline-offset-2"
|
|
2536
|
+
};
|
|
2537
|
+
var EDITOR_BOX = "whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs leading-relaxed [scrollbar-gutter:stable]";
|
|
2385
2538
|
var PromptTextarea = forwardRef(
|
|
2386
|
-
function PromptTextarea2({ value, className, rows = 14, ...props }, ref) {
|
|
2539
|
+
function PromptTextarea2({ value, className, rows = 14, onScroll, ...props }, ref) {
|
|
2540
|
+
const knowledge = usePromptSyntaxKnowledge();
|
|
2541
|
+
const tokens = useMemo(() => readPromptSyntax(value, knowledge), [value, knowledge]);
|
|
2542
|
+
const layerRef = useRef(null);
|
|
2543
|
+
const [hovered, setHovered] = useState(null);
|
|
2544
|
+
const errors = tokens.filter((token) => token.status === "error");
|
|
2545
|
+
function hoverAt(event) {
|
|
2546
|
+
const index = document.elementsFromPoint?.(event.clientX, event.clientY).map((el) => el instanceof HTMLElement ? el.dataset.promptToken : void 0).find((found) => found !== void 0);
|
|
2547
|
+
const token = index === void 0 ? void 0 : tokens[Number(index)];
|
|
2548
|
+
const box = event.currentTarget.getBoundingClientRect();
|
|
2549
|
+
setHovered(token ? { token, x: event.clientX - box.left, y: event.clientY - box.top } : null);
|
|
2550
|
+
}
|
|
2387
2551
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
2388
|
-
/* @__PURE__ */
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2552
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
2553
|
+
/* @__PURE__ */ jsxs(
|
|
2554
|
+
"pre",
|
|
2555
|
+
{
|
|
2556
|
+
ref: layerRef,
|
|
2557
|
+
"aria-hidden": true,
|
|
2558
|
+
"data-testid": "prompt-syntax-layer",
|
|
2559
|
+
className: cn("absolute inset-0 m-0 overflow-hidden border border-transparent text-foreground", EDITOR_BOX),
|
|
2560
|
+
children: [
|
|
2561
|
+
renderSegments(value, tokens),
|
|
2562
|
+
value.endsWith("\n") ? " " : null
|
|
2563
|
+
]
|
|
2564
|
+
}
|
|
2565
|
+
),
|
|
2566
|
+
/* @__PURE__ */ jsx(
|
|
2567
|
+
Textarea,
|
|
2568
|
+
{
|
|
2569
|
+
ref,
|
|
2570
|
+
value,
|
|
2571
|
+
rows,
|
|
2572
|
+
spellCheck: false,
|
|
2573
|
+
className: cn("relative text-transparent caret-foreground", EDITOR_BOX, className),
|
|
2574
|
+
onScroll: (event) => {
|
|
2575
|
+
if (layerRef.current) layerRef.current.scrollTop = event.currentTarget.scrollTop;
|
|
2576
|
+
setHovered(null);
|
|
2577
|
+
onScroll?.(event);
|
|
2578
|
+
},
|
|
2579
|
+
onMouseMove: hoverAt,
|
|
2580
|
+
onMouseLeave: () => setHovered(null),
|
|
2581
|
+
...props
|
|
2582
|
+
}
|
|
2583
|
+
),
|
|
2584
|
+
hovered && /* @__PURE__ */ jsx(
|
|
2585
|
+
"div",
|
|
2586
|
+
{
|
|
2587
|
+
role: "tooltip",
|
|
2588
|
+
className: "pointer-events-none absolute z-50 max-w-sm rounded-md bg-foreground px-2 py-1 text-xs text-background shadow-md",
|
|
2589
|
+
style: { left: hovered.x + 12, top: hovered.y + 16 },
|
|
2590
|
+
children: hovered.token.message
|
|
2591
|
+
}
|
|
2592
|
+
)
|
|
2593
|
+
] }),
|
|
2398
2594
|
/* @__PURE__ */ jsxs("p", { className: "mt-1 text-right text-xs text-muted-foreground", children: [
|
|
2399
2595
|
value.length.toLocaleString("fr-FR"),
|
|
2400
2596
|
" caract\xE8re",
|
|
2401
2597
|
value.length > 1 ? "s" : ""
|
|
2402
|
-
] })
|
|
2598
|
+
] }),
|
|
2599
|
+
errors.length > 0 && /* @__PURE__ */ jsx("ul", { "aria-label": "Erreurs dans le prompt", className: "mt-1 space-y-1 text-xs", children: errors.map((token) => /* @__PURE__ */ jsxs("li", { className: "flex gap-2", children: [
|
|
2600
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "text-status-blocked", children: "\u2715" }),
|
|
2601
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
2602
|
+
"Ligne ",
|
|
2603
|
+
token.line,
|
|
2604
|
+
" : ",
|
|
2605
|
+
token.message
|
|
2606
|
+
] })
|
|
2607
|
+
] }, `${token.start}-${token.end}`)) })
|
|
2403
2608
|
] });
|
|
2404
2609
|
}
|
|
2405
2610
|
);
|
|
2611
|
+
function renderSegments(value, tokens) {
|
|
2612
|
+
const segments = [];
|
|
2613
|
+
let cursor = 0;
|
|
2614
|
+
tokens.forEach((token, index) => {
|
|
2615
|
+
if (token.start > cursor) segments.push(value.slice(cursor, token.start));
|
|
2616
|
+
segments.push(
|
|
2617
|
+
/* @__PURE__ */ jsx("span", { "data-prompt-token": index, "data-status": token.status, className: TOKEN_CLASSES[token.status], children: value.slice(token.start, token.end) }, token.start)
|
|
2618
|
+
);
|
|
2619
|
+
cursor = token.end;
|
|
2620
|
+
});
|
|
2621
|
+
if (cursor < value.length) segments.push(value.slice(cursor));
|
|
2622
|
+
return segments;
|
|
2623
|
+
}
|
|
2624
|
+
function usePromptSyntaxKnowledge() {
|
|
2625
|
+
const { prompts, isLoading, error } = usePromptCatalogue();
|
|
2626
|
+
const { usages } = useSharedPromptUsages();
|
|
2627
|
+
const catalogue = isLoading || error !== void 0 ? null : prompts;
|
|
2628
|
+
const usagesKey = JSON.stringify(usages);
|
|
2629
|
+
return useMemo(() => ({ catalogue, usages }), [catalogue, usagesKey]);
|
|
2630
|
+
}
|
|
2406
2631
|
function defaultExpandedVersion(versions) {
|
|
2407
2632
|
const production = versions.find((v) => v.labels.includes(PRODUCTION_LABEL));
|
|
2408
2633
|
if (production) return production.version;
|
|
@@ -2457,8 +2682,8 @@ function VersionCard({
|
|
|
2457
2682
|
] })
|
|
2458
2683
|
] });
|
|
2459
2684
|
}
|
|
2460
|
-
function useNewVersionDraft() {
|
|
2461
|
-
const [content, setContent] = useState(
|
|
2685
|
+
function useNewVersionDraft(initialContent = "") {
|
|
2686
|
+
const [content, setContent] = useState(initialContent);
|
|
2462
2687
|
const [pendingPrefill, setPendingPrefill] = useState(null);
|
|
2463
2688
|
const editorRef = useRef(null);
|
|
2464
2689
|
function loadIntoEditor(versionContent) {
|
|
@@ -2642,6 +2867,7 @@ function emptyForm() {
|
|
|
2642
2867
|
name: "",
|
|
2643
2868
|
modelId: "",
|
|
2644
2869
|
provider: DEFAULT_LLM_PROVIDER,
|
|
2870
|
+
reasoningEffort: "",
|
|
2645
2871
|
status: "available",
|
|
2646
2872
|
promptName: "",
|
|
2647
2873
|
promptLabel: "",
|
|
@@ -2653,12 +2879,14 @@ function formFromAgent(agent) {
|
|
|
2653
2879
|
name: agent.name,
|
|
2654
2880
|
modelId: agent.modelId,
|
|
2655
2881
|
provider: agent.provider,
|
|
2882
|
+
reasoningEffort: agent.reasoningEffort ?? "",
|
|
2656
2883
|
status: agent.status,
|
|
2657
2884
|
promptName: agent.promptName,
|
|
2658
2885
|
promptLabel: agent.promptLabel ?? "",
|
|
2659
2886
|
systemPromptSnapshot: agent.systemPromptSnapshot ?? ""
|
|
2660
2887
|
};
|
|
2661
2888
|
}
|
|
2889
|
+
var STEP_EFFORT_VALUE = "__step__";
|
|
2662
2890
|
var DERIVED_PROMPT_VALUE = "__derived__";
|
|
2663
2891
|
var CUSTOM_PROMPT_VALUE = "__custom-prompt__";
|
|
2664
2892
|
var DEFAULT_LABEL_VALUE = "__production__";
|
|
@@ -2790,6 +3018,25 @@ function AgentFormPanel({
|
|
|
2790
3018
|
)
|
|
2791
3019
|
] })
|
|
2792
3020
|
] }),
|
|
3021
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
3022
|
+
/* @__PURE__ */ jsx("p", { className: "mb-1 text-sm font-medium", children: "Effort de raisonnement" }),
|
|
3023
|
+
/* @__PURE__ */ jsx(
|
|
3024
|
+
Select,
|
|
3025
|
+
{
|
|
3026
|
+
"aria-label": "Effort de raisonnement",
|
|
3027
|
+
value: form.reasoningEffort === "" ? STEP_EFFORT_VALUE : form.reasoningEffort,
|
|
3028
|
+
onValueChange: (next) => setForm({ ...form, reasoningEffort: next === STEP_EFFORT_VALUE ? "" : next }),
|
|
3029
|
+
items: [
|
|
3030
|
+
{ value: STEP_EFFORT_VALUE, label: "Celui de l'\xE9tape R\xE9daction" },
|
|
3031
|
+
...REASONING_EFFORTS.map((effort) => ({
|
|
3032
|
+
value: effort.value,
|
|
3033
|
+
label: effort.label
|
|
3034
|
+
}))
|
|
3035
|
+
]
|
|
3036
|
+
}
|
|
3037
|
+
),
|
|
3038
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "Ignor\xE9 par les mod\xE8les qui ne raisonnent pas." })
|
|
3039
|
+
] }),
|
|
2793
3040
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2794
3041
|
/* @__PURE__ */ jsx("p", { className: "mb-1 text-sm font-medium", children: "Prompt Langfuse" }),
|
|
2795
3042
|
/* @__PURE__ */ jsxs("div", { className: "grid gap-2 sm:grid-cols-2", children: [
|
|
@@ -3121,6 +3368,7 @@ function AgentsPage() {
|
|
|
3121
3368
|
name: form.name,
|
|
3122
3369
|
modelId: form.modelId,
|
|
3123
3370
|
provider: form.provider,
|
|
3371
|
+
reasoningEffort: form.reasoningEffort,
|
|
3124
3372
|
systemPromptSnapshot: form.systemPromptSnapshot,
|
|
3125
3373
|
// Verbatim (trim only) — empty means "derive agent/<id>", and an
|
|
3126
3374
|
// empty label means "follow production" (stored null, never the
|
|
@@ -3136,6 +3384,7 @@ function AgentsPage() {
|
|
|
3136
3384
|
name: form.name,
|
|
3137
3385
|
modelId: form.modelId,
|
|
3138
3386
|
provider: form.provider,
|
|
3387
|
+
reasoningEffort: form.reasoningEffort || null,
|
|
3139
3388
|
promptName: form.promptName.trim(),
|
|
3140
3389
|
promptLabel: form.promptLabel.trim() || null,
|
|
3141
3390
|
...formAgent.status !== "default" ? { status: form.status } : {}
|
|
@@ -3154,7 +3403,14 @@ function AgentsPage() {
|
|
|
3154
3403
|
}
|
|
3155
3404
|
const columns = [
|
|
3156
3405
|
{ key: "name", header: "Nom", cell: (row) => row.name },
|
|
3157
|
-
{
|
|
3406
|
+
{
|
|
3407
|
+
key: "model",
|
|
3408
|
+
header: "Mod\xE8le",
|
|
3409
|
+
cell: (row) => {
|
|
3410
|
+
const effort = REASONING_EFFORTS.find((e) => e.value === row.reasoningEffort);
|
|
3411
|
+
return `${row.provider} / ${row.modelId}${effort ? ` \xB7 effort ${effort.label.toLowerCase()}` : ""}`;
|
|
3412
|
+
}
|
|
3413
|
+
},
|
|
3158
3414
|
{
|
|
3159
3415
|
key: "status",
|
|
3160
3416
|
header: "Statut",
|
|
@@ -5920,9 +6176,23 @@ function useSharedPrompts() {
|
|
|
5920
6176
|
var SHARED_PREFIX2 = "shared/";
|
|
5921
6177
|
var SLUG_RE = /^[a-z0-9-]{1,64}$/;
|
|
5922
6178
|
var SLUG_ERROR = "Le nom doit contenir 1 \xE0 64 minuscules, chiffres ou tirets.";
|
|
5923
|
-
function VersionsPanel({
|
|
5924
|
-
|
|
5925
|
-
|
|
6179
|
+
function VersionsPanel({
|
|
6180
|
+
name,
|
|
6181
|
+
canWrite,
|
|
6182
|
+
usage,
|
|
6183
|
+
isAdmin,
|
|
6184
|
+
canEditUsage,
|
|
6185
|
+
isSavingUsage,
|
|
6186
|
+
onUsageChange,
|
|
6187
|
+
system,
|
|
6188
|
+
isPublished,
|
|
6189
|
+
servesDefault,
|
|
6190
|
+
onPublished,
|
|
6191
|
+
onClose
|
|
6192
|
+
}) {
|
|
6193
|
+
const [exists, setExists] = useState(isPublished);
|
|
6194
|
+
const { versions, error, promote, deleteVersion, refresh } = usePromptVersions(exists ? name : null);
|
|
6195
|
+
const draft = useNewVersionDraft(servesDefault ? system?.defaultContent ?? "" : "");
|
|
5926
6196
|
const [isCreating, setIsCreating] = useState(false);
|
|
5927
6197
|
const [createError, setCreateError] = useState(null);
|
|
5928
6198
|
const [deletingVersion, setDeletingVersion] = useState(null);
|
|
@@ -5932,6 +6202,7 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5932
6202
|
const [compareRight, setCompareRight] = useState(null);
|
|
5933
6203
|
const newVersionId = useId();
|
|
5934
6204
|
const api = useAppApi();
|
|
6205
|
+
const { appSlug } = useAppContext();
|
|
5935
6206
|
const toast = useToast();
|
|
5936
6207
|
const sorted = [...versions].sort((a, b) => b.version - a.version);
|
|
5937
6208
|
const expandedVersion = defaultExpandedVersion(versions);
|
|
@@ -5949,6 +6220,7 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5949
6220
|
const version = promotingVersion;
|
|
5950
6221
|
try {
|
|
5951
6222
|
await promote(version);
|
|
6223
|
+
onPublished();
|
|
5952
6224
|
toast({ title: `Version ${version} promue en production.`, variant: "success" });
|
|
5953
6225
|
} catch (err) {
|
|
5954
6226
|
toast({ title: "\xC9chec de la promotion", description: describeApiError(err), variant: "error" });
|
|
@@ -5974,13 +6246,21 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5974
6246
|
setCreateError(null);
|
|
5975
6247
|
const payload = { name, content: draft.content };
|
|
5976
6248
|
try {
|
|
5977
|
-
await api.invoke(
|
|
6249
|
+
const result = await api.invoke(
|
|
5978
6250
|
"create-shared-prompt-version",
|
|
5979
6251
|
payload,
|
|
5980
6252
|
{ idempotencyKey: idempotencyKeyFor("create-shared-prompt-version", payload) }
|
|
5981
6253
|
);
|
|
5982
6254
|
draft.setContent("");
|
|
5983
|
-
|
|
6255
|
+
if (exists) {
|
|
6256
|
+
await refresh();
|
|
6257
|
+
} else {
|
|
6258
|
+
await api.post(`/data/apps/${appSlug}/prompts/promote`, { name, version: result.version, label: PRODUCTION_LABEL }).catch(() => {
|
|
6259
|
+
toast({ title: "Version cr\xE9\xE9e, mais pas encore en production", description: "Promouvez-la pour qu'elle soit utilis\xE9e.", variant: "error" });
|
|
6260
|
+
});
|
|
6261
|
+
setExists(true);
|
|
6262
|
+
onPublished();
|
|
6263
|
+
}
|
|
5984
6264
|
} catch (err) {
|
|
5985
6265
|
setCreateError(describeInvokeError(err));
|
|
5986
6266
|
} finally {
|
|
@@ -5990,6 +6270,37 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5990
6270
|
return /* @__PURE__ */ jsxs(SidePanel, { open: true, onClose, title: name, description: "Ressource commune \xE0 l'entreprise \u2014 toute nouvelle version s'applique \xE0 toutes les apps qui utilisent ce prompt.", className: PROMPT_PANEL_CLASS, children: [
|
|
5991
6271
|
/* @__PURE__ */ jsxs("div", { "data-testid": "shared-prompt-versions", className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto", children: [
|
|
5992
6272
|
error !== void 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du chargement des versions." }),
|
|
6273
|
+
system && /* @__PURE__ */ jsxs("div", { className: "space-y-1 rounded-md border bg-muted/40 p-3 text-sm", children: [
|
|
6274
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium", children: "Prompt syst\xE8me" }),
|
|
6275
|
+
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground", children: [
|
|
6276
|
+
system.description,
|
|
6277
|
+
" Il existe toujours et son nom ne peut pas changer : seul son texte se modifie."
|
|
6278
|
+
] }),
|
|
6279
|
+
(!exists || versions.length > 0 && !hasActiveVersion) && /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground", children: [
|
|
6280
|
+
"Aucune version en production : le texte par d\xE9faut est utilis\xE9.",
|
|
6281
|
+
exists ? " Promouvez une version pour la mettre en service." : " Cr\xE9ez une version pour le modifier."
|
|
6282
|
+
] })
|
|
6283
|
+
] }),
|
|
6284
|
+
!system && /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
6285
|
+
/* @__PURE__ */ jsx("p", { className: "block text-sm font-medium", children: "Utilisation" }),
|
|
6286
|
+
/* @__PURE__ */ jsx(
|
|
6287
|
+
Select,
|
|
6288
|
+
{
|
|
6289
|
+
"aria-label": "Utilisation",
|
|
6290
|
+
value: usage,
|
|
6291
|
+
onValueChange: (value) => {
|
|
6292
|
+
if (isPromptUsage(value)) onUsageChange(value);
|
|
6293
|
+
},
|
|
6294
|
+
items: PROMPT_USAGE_OPTIONS,
|
|
6295
|
+
disabled: !canEditUsage || isSavingUsage
|
|
6296
|
+
}
|
|
6297
|
+
),
|
|
6298
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
6299
|
+
PROMPT_USAGE_HINTS[usage],
|
|
6300
|
+
" Ce r\xE9glage ne vaut que pour cette app.",
|
|
6301
|
+
!isAdmin && " Seul un administrateur de l'app peut le changer."
|
|
6302
|
+
] })
|
|
6303
|
+
] }),
|
|
5993
6304
|
versions.length > 0 && !hasActiveVersion && /* @__PURE__ */ jsx("p", { className: "rounded-md border border-status-warning/40 bg-status-warning/10 p-2 text-sm text-status-warning", children: "Aucune version active \u2014 aucune version ne porte le label \xAB production \xBB." }),
|
|
5994
6305
|
versions.length >= 2 && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: openCompare, children: "Comparer" }) }),
|
|
5995
6306
|
isComparing && compareLeft !== null && compareRight !== null && /* @__PURE__ */ jsx(
|
|
@@ -6014,7 +6325,7 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
6014
6325
|
},
|
|
6015
6326
|
v.version
|
|
6016
6327
|
)),
|
|
6017
|
-
sorted.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune version pour l'instant." })
|
|
6328
|
+
sorted.length === 0 && exists && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune version pour l'instant." })
|
|
6018
6329
|
] }),
|
|
6019
6330
|
canWrite && /* @__PURE__ */ jsxs("div", { className: "space-y-2 border-t pt-3", children: [
|
|
6020
6331
|
/* @__PURE__ */ jsx("label", { htmlFor: newVersionId, className: "block text-sm font-medium", children: "Nouvelle version" }),
|
|
@@ -6142,16 +6453,61 @@ function SharedPromptsPage() {
|
|
|
6142
6453
|
const { role } = useAppContext();
|
|
6143
6454
|
const canWrite = canWriteForRole(role);
|
|
6144
6455
|
const { prompts, isLoading, error, refresh } = useSharedPrompts();
|
|
6456
|
+
const { usageOf, setUsage, isReady: areUsagesReady, isSaving: isSavingUsage, saveError: usageSaveError } = useSharedPromptUsages();
|
|
6457
|
+
const toast = useToast();
|
|
6145
6458
|
const [selected, setSelected] = useState(null);
|
|
6146
6459
|
const [isCreateOpen, setIsCreateOpen] = useState(false);
|
|
6460
|
+
const wasSavingUsageRef = useRef(false);
|
|
6461
|
+
useEffect(() => {
|
|
6462
|
+
if (wasSavingUsageRef.current && !isSavingUsage) {
|
|
6463
|
+
if (usageSaveError === void 0) toast({ title: "Utilisation enregistr\xE9e.", variant: "success" });
|
|
6464
|
+
else toast({ title: "\xC9chec de l'enregistrement", description: describeApiError(usageSaveError), variant: "error" });
|
|
6465
|
+
}
|
|
6466
|
+
wasSavingUsageRef.current = isSavingUsage;
|
|
6467
|
+
}, [isSavingUsage, usageSaveError, toast]);
|
|
6468
|
+
const publishedNames = new Set(prompts.map((prompt) => prompt.name));
|
|
6469
|
+
const rows = isLoading || error ? prompts : [
|
|
6470
|
+
...prompts,
|
|
6471
|
+
...SYSTEM_PROMPTS.filter((system) => !publishedNames.has(system.name)).map((system) => ({
|
|
6472
|
+
name: system.name,
|
|
6473
|
+
labels: [],
|
|
6474
|
+
latestVersion: 0,
|
|
6475
|
+
isUnpublished: true
|
|
6476
|
+
}))
|
|
6477
|
+
].sort((a, b) => a.name.localeCompare(b.name));
|
|
6478
|
+
const selectedSystem = selected ? systemPromptOf(selected) : void 0;
|
|
6147
6479
|
const columns = [
|
|
6148
|
-
{
|
|
6480
|
+
{
|
|
6481
|
+
key: "name",
|
|
6482
|
+
header: "Nom",
|
|
6483
|
+
cell: (row) => systemPromptOf(row.name) ? /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-2", children: [
|
|
6484
|
+
row.name,
|
|
6485
|
+
/* @__PURE__ */ jsx(Badge, { children: "Syst\xE8me" })
|
|
6486
|
+
] }) : row.name
|
|
6487
|
+
},
|
|
6488
|
+
{
|
|
6489
|
+
key: "usage",
|
|
6490
|
+
header: "Utilisation",
|
|
6491
|
+
cell: (row) => {
|
|
6492
|
+
const usage = systemPromptOf(row.name)?.usage ?? usageOf(row.name);
|
|
6493
|
+
return usage === DEFAULT_PROMPT_USAGE ? PROMPT_USAGE_LABELS[usage] : /* @__PURE__ */ jsx(Badge, { variant: "info", children: PROMPT_USAGE_LABELS[usage] });
|
|
6494
|
+
}
|
|
6495
|
+
},
|
|
6149
6496
|
{
|
|
6150
6497
|
key: "labels",
|
|
6151
6498
|
header: "Labels",
|
|
6152
6499
|
cell: (row) => row.labels.length > 0 ? row.labels.map((l) => /* @__PURE__ */ jsx(Badge, { children: l }, l)) : "\u2014"
|
|
6153
6500
|
},
|
|
6154
|
-
{
|
|
6501
|
+
{
|
|
6502
|
+
key: "latestVersion",
|
|
6503
|
+
header: "Derni\xE8re version",
|
|
6504
|
+
align: "right",
|
|
6505
|
+
cell: (row) => {
|
|
6506
|
+
if (row.isUnpublished) return "Texte par d\xE9faut";
|
|
6507
|
+
const servesDefault = systemPromptOf(row.name) && !row.labels.includes(PRODUCTION_LABEL);
|
|
6508
|
+
return servesDefault ? `v${row.latestVersion} \xB7 texte par d\xE9faut utilis\xE9` : `v${row.latestVersion}`;
|
|
6509
|
+
}
|
|
6510
|
+
}
|
|
6155
6511
|
];
|
|
6156
6512
|
return /* @__PURE__ */ jsxs(PageShell, { children: [
|
|
6157
6513
|
/* @__PURE__ */ jsx(
|
|
@@ -6167,7 +6523,7 @@ function SharedPromptsPage() {
|
|
|
6167
6523
|
DataTable,
|
|
6168
6524
|
{
|
|
6169
6525
|
columns,
|
|
6170
|
-
rows
|
|
6526
|
+
rows,
|
|
6171
6527
|
rowId: (row) => row.name,
|
|
6172
6528
|
manual: true,
|
|
6173
6529
|
loading: isLoading,
|
|
@@ -6179,7 +6535,24 @@ function SharedPromptsPage() {
|
|
|
6179
6535
|
empty: "Aucun prompt \xAB shared/* \xBB accessible depuis cette app."
|
|
6180
6536
|
}
|
|
6181
6537
|
),
|
|
6182
|
-
selected && /* @__PURE__ */ jsx(
|
|
6538
|
+
selected && /* @__PURE__ */ jsx(
|
|
6539
|
+
VersionsPanel,
|
|
6540
|
+
{
|
|
6541
|
+
name: selected,
|
|
6542
|
+
canWrite,
|
|
6543
|
+
usage: usageOf(selected),
|
|
6544
|
+
isAdmin: role === "ADMIN",
|
|
6545
|
+
canEditUsage: role === "ADMIN" && areUsagesReady,
|
|
6546
|
+
isSavingUsage,
|
|
6547
|
+
onUsageChange: (usage) => void setUsage(selected, usage),
|
|
6548
|
+
system: selectedSystem,
|
|
6549
|
+
isPublished: !rows.some((row) => row.name === selected && row.isUnpublished),
|
|
6550
|
+
servesDefault: selectedSystem !== void 0 && !rows.some((row) => row.name === selected && row.labels.includes(PRODUCTION_LABEL)),
|
|
6551
|
+
onPublished: () => void refresh(),
|
|
6552
|
+
onClose: () => setSelected(null)
|
|
6553
|
+
},
|
|
6554
|
+
selected
|
|
6555
|
+
),
|
|
6183
6556
|
isCreateOpen && /* @__PURE__ */ jsx(
|
|
6184
6557
|
NewSharedPromptModal,
|
|
6185
6558
|
{
|