@apotech-os/support-kit 5.0.1 → 6.1.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-ZFUWILDN.js → chunk-W2QU5367.js} +13 -6
- package/dist/chunk-W2QU5367.js.map +1 -0
- package/dist/index.cjs +417 -319
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -6
- package/dist/index.d.ts +33 -6
- package/dist/index.js +345 -255
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +424 -248
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +410 -251
- package/dist/ui/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-ZFUWILDN.js.map +0 -1
package/dist/ui/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, toAgent, toGeneratedResponse, toResponseComparison, toTriageDecision, isGeneratedResponseStatus, toCategoryGroup, NODE_NAMES, settingsToProfile, hasNoDraftNode, DEFAULT_LLM_PROVIDER, computeWordDiff, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-
|
|
2
|
-
import { useState, useMemo, useEffect, useRef, useCallback, useId } from 'react';
|
|
3
|
-
import { useAppContext, useAppSettings, DateRangeCompare, Link, Card, CardHeader, CardTitle, CardContent, AreaChart, StackedBarChart, Badge, useAppApi, useToast, Button, Select, DataTable, Spinner, Switch, Input, Checkbox,
|
|
1
|
+
import { EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, toAgent, toGeneratedResponse, toResponseComparison, toTriageDecision, isGeneratedResponseStatus, isInvalidatableStatus, toCategoryGroup, NODE_NAMES, settingsToProfile, hasNoDraftNode, DEFAULT_LLM_PROVIDER, computeWordDiff, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-W2QU5367.js';
|
|
2
|
+
import { forwardRef, useState, useMemo, useEffect, useRef, useCallback, useId } from 'react';
|
|
3
|
+
import { Textarea, cn, useAppContext, useAppSettings, DateRangeCompare, Link, Card, CardHeader, CardTitle, CardContent, AreaChart, StackedBarChart, Badge, useAppApi, useToast, Button, Select, DataTable, Spinner, Switch, Input, Checkbox, comparisonRange, SidePanel, Modal, Tooltip, buttonVariants, 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) {
|
|
@@ -1231,10 +1231,14 @@ function noResponseCause(decision) {
|
|
|
1231
1231
|
return "La cat\xE9gorie n'a pas la r\xE9ponse rapide activ\xE9e, ou n'a pas d'agent r\xE9dacteur.";
|
|
1232
1232
|
}
|
|
1233
1233
|
function TimelinePanel(props) {
|
|
1234
|
-
const { decision, job, comparisons, conversation, conversationLoading, categoryName, onClose } = props;
|
|
1234
|
+
const { decision, job, comparisons, conversation, conversationLoading, categoryName, onClose, onInvalidate, isInvalidating } = props;
|
|
1235
1235
|
const steps = buildTimeline({ decision, job, comparisons, conversation, conversationLoading });
|
|
1236
|
-
|
|
1237
|
-
|
|
1236
|
+
const canInvalidate = job !== void 0 && isGeneratedResponseStatus(job.status) && isInvalidatableStatus(job.status);
|
|
1237
|
+
return /* @__PURE__ */ jsx(SidePanel, { open: true, onClose, title: `Ticket ${decision.ticketId}`, description: categoryName, children: /* @__PURE__ */ jsxs("div", { className: "min-h-0 flex-1 space-y-1 overflow-y-auto text-sm", children: [
|
|
1238
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 pb-3", children: [
|
|
1239
|
+
/* @__PURE__ */ jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }),
|
|
1240
|
+
onInvalidate && canInvalidate && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: onInvalidate, disabled: isInvalidating, children: isInvalidating ? "Invalidation\u2026" : "Invalider la r\xE9ponse" })
|
|
1241
|
+
] }),
|
|
1238
1242
|
steps.map((step2, index) => /* @__PURE__ */ jsx(StepBlock, { step: step2, index, last: index === steps.length - 1, children: step2.reached ? renderStep(step2.key, props) : null }, step2.key))
|
|
1239
1243
|
] }) });
|
|
1240
1244
|
}
|
|
@@ -1482,6 +1486,7 @@ function TicketsPage() {
|
|
|
1482
1486
|
const [correctedFilter, setCorrectedFilter] = useState("");
|
|
1483
1487
|
const [detailDecision, setDetailDecision] = useState(null);
|
|
1484
1488
|
const [isTriaging, setIsTriaging] = useState(false);
|
|
1489
|
+
const [isInvalidating, setIsInvalidating] = useState(false);
|
|
1485
1490
|
const [triageInFlight] = useState(() => ({ current: false }));
|
|
1486
1491
|
const periodKey = JSON.stringify(period);
|
|
1487
1492
|
const bounds = useMemo(() => periodBoundsOf(JSON.parse(periodKey)).current, [periodKey]);
|
|
@@ -1619,6 +1624,18 @@ function TicketsPage() {
|
|
|
1619
1624
|
setIsTriaging(false);
|
|
1620
1625
|
}
|
|
1621
1626
|
}
|
|
1627
|
+
async function invalidateResponse(generatedResponseId) {
|
|
1628
|
+
setIsInvalidating(true);
|
|
1629
|
+
try {
|
|
1630
|
+
await api.invoke("invalidate-response", { generatedResponseId });
|
|
1631
|
+
toast({ title: "R\xE9ponse invalid\xE9e \u2014 le ticket pourra \xEAtre retrait\xE9 de z\xE9ro.", variant: "success" });
|
|
1632
|
+
await refreshAll();
|
|
1633
|
+
} catch (err) {
|
|
1634
|
+
toast({ title: "\xC9chec de l'invalidation", description: describeInvokeError(err), variant: "error" });
|
|
1635
|
+
} finally {
|
|
1636
|
+
setIsInvalidating(false);
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1622
1639
|
const columns = [
|
|
1623
1640
|
{ key: "ticketId", header: "Ticket", cell: ({ decision }) => /* @__PURE__ */ jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl }) },
|
|
1624
1641
|
{ key: "category", header: "Cat\xE9gorie", cell: ({ decision }) => decision.categoryId && categoryNames.get(decision.categoryId) || "\u2014" },
|
|
@@ -1755,7 +1772,9 @@ function TicketsPage() {
|
|
|
1755
1772
|
categoryName: detailDecision.categoryId && categoryNames.get(detailDecision.categoryId) || "\u2014",
|
|
1756
1773
|
agentName: detailRow?.job?.agentId && agentNames.get(detailRow.job.agentId) || "\u2014",
|
|
1757
1774
|
langfuseConfig,
|
|
1758
|
-
onClose: () => setDetailDecision(null)
|
|
1775
|
+
onClose: () => setDetailDecision(null),
|
|
1776
|
+
onInvalidate: canWrite && detailRow?.job ? () => void invalidateResponse(detailRow.job.id) : void 0,
|
|
1777
|
+
isInvalidating
|
|
1759
1778
|
}
|
|
1760
1779
|
)
|
|
1761
1780
|
] });
|
|
@@ -2030,6 +2049,131 @@ function ConfirmModal({
|
|
|
2030
2049
|
] })
|
|
2031
2050
|
] }) });
|
|
2032
2051
|
}
|
|
2052
|
+
var PROMPT_PANEL_CLASS = "w-[min(92vw,64rem)] max-w-none";
|
|
2053
|
+
var PRODUCTION_LABEL = "production";
|
|
2054
|
+
var PromptTextarea = forwardRef(
|
|
2055
|
+
function PromptTextarea2({ value, className, rows = 14, ...props }, ref) {
|
|
2056
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
2057
|
+
/* @__PURE__ */ jsx(
|
|
2058
|
+
Textarea,
|
|
2059
|
+
{
|
|
2060
|
+
ref,
|
|
2061
|
+
value,
|
|
2062
|
+
rows,
|
|
2063
|
+
className: cn("font-mono text-xs leading-relaxed", className),
|
|
2064
|
+
...props
|
|
2065
|
+
}
|
|
2066
|
+
),
|
|
2067
|
+
/* @__PURE__ */ jsxs("p", { className: "mt-1 text-right text-xs text-muted-foreground", children: [
|
|
2068
|
+
value.length.toLocaleString("fr-FR"),
|
|
2069
|
+
" caract\xE8re",
|
|
2070
|
+
value.length > 1 ? "s" : ""
|
|
2071
|
+
] })
|
|
2072
|
+
] });
|
|
2073
|
+
}
|
|
2074
|
+
);
|
|
2075
|
+
function defaultExpandedVersion(versions) {
|
|
2076
|
+
const production = versions.find((v) => v.labels.includes(PRODUCTION_LABEL));
|
|
2077
|
+
if (production) return production.version;
|
|
2078
|
+
return versions.reduce(
|
|
2079
|
+
(max, v) => max === null || v.version > max ? v.version : max,
|
|
2080
|
+
null
|
|
2081
|
+
);
|
|
2082
|
+
}
|
|
2083
|
+
function excerptOf(content) {
|
|
2084
|
+
return content.slice(0, 1e3).split("\n").find((line) => line.trim() !== "") ?? "";
|
|
2085
|
+
}
|
|
2086
|
+
function VersionCard({
|
|
2087
|
+
version,
|
|
2088
|
+
defaultOpen,
|
|
2089
|
+
onEditFrom,
|
|
2090
|
+
onPromote,
|
|
2091
|
+
onDelete
|
|
2092
|
+
}) {
|
|
2093
|
+
const [isOpen, setIsOpen] = useState(defaultOpen);
|
|
2094
|
+
const hasActions = onEditFrom !== void 0 || onPromote !== void 0 || onDelete !== void 0;
|
|
2095
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-md border", children: [
|
|
2096
|
+
/* @__PURE__ */ jsxs(
|
|
2097
|
+
"button",
|
|
2098
|
+
{
|
|
2099
|
+
type: "button",
|
|
2100
|
+
"aria-expanded": isOpen,
|
|
2101
|
+
onClick: () => setIsOpen((open) => !open),
|
|
2102
|
+
className: "flex w-full items-center gap-3 rounded-md p-3 text-left hover:bg-accent/50",
|
|
2103
|
+
children: [
|
|
2104
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
|
|
2105
|
+
/* @__PURE__ */ jsxs("span", { className: "shrink-0 text-sm font-medium", children: [
|
|
2106
|
+
"v",
|
|
2107
|
+
version.version
|
|
2108
|
+
] }),
|
|
2109
|
+
version.label && /* @__PURE__ */ jsx(Badge, { variant: "brand", children: version.label }),
|
|
2110
|
+
!isOpen && /* @__PURE__ */ jsx("span", { className: "truncate font-mono text-xs text-muted-foreground", children: excerptOf(version.content) })
|
|
2111
|
+
] }),
|
|
2112
|
+
/* @__PURE__ */ jsxs("span", { className: "shrink-0 text-xs text-muted-foreground", children: [
|
|
2113
|
+
"Cr\xE9\xE9e le ",
|
|
2114
|
+
formatDate(version.createdAt)
|
|
2115
|
+
] })
|
|
2116
|
+
]
|
|
2117
|
+
}
|
|
2118
|
+
),
|
|
2119
|
+
isOpen && /* @__PURE__ */ jsxs("div", { className: "space-y-2 border-t p-3", children: [
|
|
2120
|
+
hasActions && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap justify-end gap-2", children: [
|
|
2121
|
+
onEditFrom && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: onEditFrom, children: "Modifier cette version" }),
|
|
2122
|
+
onPromote && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: onPromote, children: "Promouvoir" }),
|
|
2123
|
+
onDelete && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: onDelete, children: "Supprimer la version" })
|
|
2124
|
+
] }),
|
|
2125
|
+
/* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap font-mono text-xs text-muted-foreground", children: version.content })
|
|
2126
|
+
] })
|
|
2127
|
+
] });
|
|
2128
|
+
}
|
|
2129
|
+
function useNewVersionDraft() {
|
|
2130
|
+
const [content, setContent] = useState("");
|
|
2131
|
+
const [pendingPrefill, setPendingPrefill] = useState(null);
|
|
2132
|
+
const editorRef = useRef(null);
|
|
2133
|
+
function loadIntoEditor(versionContent) {
|
|
2134
|
+
setContent(versionContent);
|
|
2135
|
+
setTimeout(() => {
|
|
2136
|
+
editorRef.current?.focus();
|
|
2137
|
+
editorRef.current?.scrollIntoView?.({ block: "center" });
|
|
2138
|
+
}, 0);
|
|
2139
|
+
}
|
|
2140
|
+
function prefill(versionContent) {
|
|
2141
|
+
if (content.trim() !== "" && content !== versionContent) {
|
|
2142
|
+
setPendingPrefill(versionContent);
|
|
2143
|
+
return;
|
|
2144
|
+
}
|
|
2145
|
+
loadIntoEditor(versionContent);
|
|
2146
|
+
}
|
|
2147
|
+
function confirmPrefill() {
|
|
2148
|
+
if (pendingPrefill !== null) loadIntoEditor(pendingPrefill);
|
|
2149
|
+
setPendingPrefill(null);
|
|
2150
|
+
}
|
|
2151
|
+
return {
|
|
2152
|
+
content,
|
|
2153
|
+
setContent,
|
|
2154
|
+
editorRef,
|
|
2155
|
+
prefill,
|
|
2156
|
+
pendingPrefill,
|
|
2157
|
+
confirmPrefill,
|
|
2158
|
+
cancelPrefill: () => setPendingPrefill(null)
|
|
2159
|
+
};
|
|
2160
|
+
}
|
|
2161
|
+
function ReplaceDraftConfirmModal({
|
|
2162
|
+
onConfirm,
|
|
2163
|
+
onCancel
|
|
2164
|
+
}) {
|
|
2165
|
+
return /* @__PURE__ */ jsx(
|
|
2166
|
+
ConfirmModal,
|
|
2167
|
+
{
|
|
2168
|
+
title: "Remplacer le brouillon ?",
|
|
2169
|
+
description: "Le texte d\xE9j\xE0 saisi dans \xAB Nouvelle version \xBB sera remplac\xE9 par le contenu de cette version.",
|
|
2170
|
+
confirmLabel: "Remplacer",
|
|
2171
|
+
busyLabel: "Remplacement\u2026",
|
|
2172
|
+
onConfirm,
|
|
2173
|
+
onCancel
|
|
2174
|
+
}
|
|
2175
|
+
);
|
|
2176
|
+
}
|
|
2033
2177
|
function usePromptVersions(promptName) {
|
|
2034
2178
|
const { appSlug } = useAppContext();
|
|
2035
2179
|
const api = useAppApi();
|
|
@@ -2187,7 +2331,7 @@ function formFromAgent(agent) {
|
|
|
2187
2331
|
var DERIVED_PROMPT_VALUE = "__derived__";
|
|
2188
2332
|
var CUSTOM_PROMPT_VALUE = "__custom-prompt__";
|
|
2189
2333
|
var DEFAULT_LABEL_VALUE = "__production__";
|
|
2190
|
-
function
|
|
2334
|
+
function AgentFormPanel({
|
|
2191
2335
|
agent,
|
|
2192
2336
|
prompts,
|
|
2193
2337
|
promptsLoading,
|
|
@@ -2211,13 +2355,17 @@ function AgentFormModal({
|
|
|
2211
2355
|
const knownPrompt = prompts.find((entry) => entry.name === form.promptName);
|
|
2212
2356
|
const showPromptFreeText = freeTextPrompt || agent !== "new" && form.promptName !== "" && !knownPrompt && !promptsLoading;
|
|
2213
2357
|
const promptLabels = knownPrompt?.labels ?? [];
|
|
2358
|
+
const previewName = agent === "new" && !showPromptFreeText && form.promptName !== "" ? form.promptName : null;
|
|
2359
|
+
const { versions: previewVersions } = usePromptVersions(previewName);
|
|
2360
|
+
const previewContent = previewVersions.find((v) => v.version === defaultExpandedVersion(previewVersions))?.content ?? "";
|
|
2361
|
+
const effectiveSnapshot = previewName !== null ? previewContent : form.systemPromptSnapshot;
|
|
2214
2362
|
const isValid = form.name.trim() !== "" && form.modelId.trim() !== "" && (agent === "new" || form.promptName.trim() !== "");
|
|
2215
2363
|
async function submit(event) {
|
|
2216
2364
|
event.preventDefault();
|
|
2217
2365
|
if (isSaving || !isValid) return;
|
|
2218
2366
|
setIsSaving(true);
|
|
2219
2367
|
try {
|
|
2220
|
-
await onSave(form);
|
|
2368
|
+
await onSave({ ...form, systemPromptSnapshot: effectiveSnapshot });
|
|
2221
2369
|
} finally {
|
|
2222
2370
|
setIsSaving(false);
|
|
2223
2371
|
}
|
|
@@ -2231,161 +2379,170 @@ function AgentFormModal({
|
|
|
2231
2379
|
setForm({ ...form, promptName: next === DERIVED_PROMPT_VALUE ? "" : next, promptLabel: "" });
|
|
2232
2380
|
}
|
|
2233
2381
|
return /* @__PURE__ */ jsx(
|
|
2234
|
-
|
|
2382
|
+
SidePanel,
|
|
2235
2383
|
{
|
|
2236
2384
|
open: true,
|
|
2237
2385
|
onClose,
|
|
2238
2386
|
title: agent === "new" ? "Nouvel agent" : `Modifier ${form.name}`,
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
/* @__PURE__ */
|
|
2243
|
-
|
|
2244
|
-
{
|
|
2245
|
-
id: nameId,
|
|
2246
|
-
value: form.name,
|
|
2247
|
-
onChange: (e) => setForm({ ...form, name: e.target.value })
|
|
2248
|
-
}
|
|
2249
|
-
)
|
|
2250
|
-
] }),
|
|
2251
|
-
agent !== "new" && agent.status !== "default" && /* @__PURE__ */ jsxs("div", { children: [
|
|
2252
|
-
/* @__PURE__ */ jsx("p", { className: "mb-1 text-sm font-medium", children: "Statut" }),
|
|
2253
|
-
/* @__PURE__ */ jsx(
|
|
2254
|
-
Select,
|
|
2255
|
-
{
|
|
2256
|
-
"aria-label": "Statut",
|
|
2257
|
-
value: form.status,
|
|
2258
|
-
onValueChange: (next) => setForm({ ...form, status: next }),
|
|
2259
|
-
items: [
|
|
2260
|
-
{ value: "available", label: STATUS_LABELS.available },
|
|
2261
|
-
{ value: "archived", label: STATUS_LABELS.archived }
|
|
2262
|
-
]
|
|
2263
|
-
}
|
|
2264
|
-
)
|
|
2265
|
-
] }),
|
|
2266
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2267
|
-
/* @__PURE__ */ jsx("p", { className: "mb-1 text-sm font-medium", children: "Mod\xE8le" }),
|
|
2268
|
-
/* @__PURE__ */ jsx(
|
|
2269
|
-
Select,
|
|
2270
|
-
{
|
|
2271
|
-
"aria-label": "Mod\xE8le",
|
|
2272
|
-
value: showModelFreeText ? CUSTOM_MODEL_VALUE : form.modelId,
|
|
2273
|
-
onValueChange: (next) => {
|
|
2274
|
-
if (next === CUSTOM_MODEL_VALUE) {
|
|
2275
|
-
setFreeTextModel(true);
|
|
2276
|
-
return;
|
|
2277
|
-
}
|
|
2278
|
-
setFreeTextModel(false);
|
|
2279
|
-
setForm({ ...form, modelId: next, provider: DEFAULT_STEP_PROVIDER });
|
|
2280
|
-
},
|
|
2281
|
-
items: [
|
|
2282
|
-
// The stored model, listed so the trigger can print it while the
|
|
2283
|
-
// provider's own list is still loading.
|
|
2284
|
-
...!showModelFreeText && form.modelId !== "" && !knownModel ? [{ value: form.modelId, label: form.modelId }] : [],
|
|
2285
|
-
...models.map((name) => ({ value: name, label: name })),
|
|
2286
|
-
{ value: CUSTOM_MODEL_VALUE, label: "Autre \u2014 saisir un identifiant de mod\xE8le" }
|
|
2287
|
-
],
|
|
2288
|
-
disabled: modelsLoading
|
|
2289
|
-
}
|
|
2290
|
-
),
|
|
2291
|
-
showModelFreeText && /* @__PURE__ */ jsxs("div", { className: "mt-2 space-y-2", children: [
|
|
2292
|
-
/* @__PURE__ */ jsx("label", { htmlFor: modelInputId, className: "mb-1 block text-sm font-medium", children: "Identifiant de mod\xE8le" }),
|
|
2293
|
-
/* @__PURE__ */ jsx(
|
|
2294
|
-
Input,
|
|
2295
|
-
{
|
|
2296
|
-
id: modelInputId,
|
|
2297
|
-
value: form.modelId,
|
|
2298
|
-
onChange: (e) => setForm({ ...form, modelId: e.target.value })
|
|
2299
|
-
}
|
|
2300
|
-
),
|
|
2301
|
-
/* @__PURE__ */ jsx("label", { htmlFor: providerInputId, className: "mb-1 block text-sm font-medium", children: "Fournisseur" }),
|
|
2387
|
+
className: PROMPT_PANEL_CLASS,
|
|
2388
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 flex-col overflow-y-auto pr-1", children: [
|
|
2389
|
+
/* @__PURE__ */ jsxs("form", { className: "space-y-3", onSubmit: (e) => void submit(e), children: [
|
|
2390
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2391
|
+
/* @__PURE__ */ jsx("label", { htmlFor: nameId, className: "mb-1 block text-sm font-medium", children: "Nom" }),
|
|
2302
2392
|
/* @__PURE__ */ jsx(
|
|
2303
2393
|
Input,
|
|
2304
2394
|
{
|
|
2305
|
-
id:
|
|
2306
|
-
value: form.
|
|
2307
|
-
onChange: (e) => setForm({ ...form,
|
|
2395
|
+
id: nameId,
|
|
2396
|
+
value: form.name,
|
|
2397
|
+
onChange: (e) => setForm({ ...form, name: e.target.value })
|
|
2308
2398
|
}
|
|
2309
2399
|
)
|
|
2310
|
-
] })
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
/* @__PURE__ */ jsx("p", { className: "mb-1 text-sm font-medium", children: "Prompt Langfuse" }),
|
|
2314
|
-
/* @__PURE__ */ jsxs("div", { className: "grid gap-2 sm:grid-cols-2", children: [
|
|
2400
|
+
] }),
|
|
2401
|
+
agent !== "new" && agent.status !== "default" && /* @__PURE__ */ jsxs("div", { children: [
|
|
2402
|
+
/* @__PURE__ */ jsx("p", { className: "mb-1 text-sm font-medium", children: "Statut" }),
|
|
2315
2403
|
/* @__PURE__ */ jsx(
|
|
2316
2404
|
Select,
|
|
2317
2405
|
{
|
|
2318
|
-
"aria-label": "
|
|
2319
|
-
value:
|
|
2320
|
-
onValueChange:
|
|
2406
|
+
"aria-label": "Statut",
|
|
2407
|
+
value: form.status,
|
|
2408
|
+
onValueChange: (next) => setForm({ ...form, status: next }),
|
|
2321
2409
|
items: [
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
label: "Nouveau prompt \u2014 agent/<g\xE9n\xE9r\xE9 automatiquement>"
|
|
2326
|
-
}
|
|
2327
|
-
] : [],
|
|
2328
|
-
// The agent's stored prompt, listed so the trigger can print it
|
|
2329
|
-
// while the catalogue is still loading.
|
|
2330
|
-
...!showPromptFreeText && form.promptName !== "" && !knownPrompt ? [{ value: form.promptName, label: form.promptName }] : [],
|
|
2331
|
-
...prompts.map((entry) => ({ value: entry.name, label: entry.name })),
|
|
2332
|
-
{ value: CUSTOM_PROMPT_VALUE, label: "Autre \u2014 saisir un nom de prompt" }
|
|
2333
|
-
],
|
|
2334
|
-
disabled: promptsLoading
|
|
2410
|
+
{ value: "available", label: STATUS_LABELS.available },
|
|
2411
|
+
{ value: "archived", label: STATUS_LABELS.archived }
|
|
2412
|
+
]
|
|
2335
2413
|
}
|
|
2336
|
-
)
|
|
2414
|
+
)
|
|
2415
|
+
] }),
|
|
2416
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2417
|
+
/* @__PURE__ */ jsx("p", { className: "mb-1 text-sm font-medium", children: "Mod\xE8le" }),
|
|
2337
2418
|
/* @__PURE__ */ jsx(
|
|
2338
2419
|
Select,
|
|
2339
2420
|
{
|
|
2340
|
-
"aria-label": "
|
|
2341
|
-
value:
|
|
2342
|
-
onValueChange: (next) =>
|
|
2421
|
+
"aria-label": "Mod\xE8le",
|
|
2422
|
+
value: showModelFreeText ? CUSTOM_MODEL_VALUE : form.modelId,
|
|
2423
|
+
onValueChange: (next) => {
|
|
2424
|
+
if (next === CUSTOM_MODEL_VALUE) {
|
|
2425
|
+
setFreeTextModel(true);
|
|
2426
|
+
return;
|
|
2427
|
+
}
|
|
2428
|
+
setFreeTextModel(false);
|
|
2429
|
+
setForm({ ...form, modelId: next, provider: DEFAULT_STEP_PROVIDER });
|
|
2430
|
+
},
|
|
2343
2431
|
items: [
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2432
|
+
// The stored model, listed so the trigger can print it while the
|
|
2433
|
+
// provider's own list is still loading.
|
|
2434
|
+
...!showModelFreeText && form.modelId !== "" && !knownModel ? [{ value: form.modelId, label: form.modelId }] : [],
|
|
2435
|
+
...models.map((name) => ({ value: name, label: name })),
|
|
2436
|
+
{ value: CUSTOM_MODEL_VALUE, label: "Autre \u2014 saisir un identifiant de mod\xE8le" }
|
|
2347
2437
|
],
|
|
2348
|
-
disabled:
|
|
2438
|
+
disabled: modelsLoading
|
|
2349
2439
|
}
|
|
2350
|
-
)
|
|
2440
|
+
),
|
|
2441
|
+
showModelFreeText && /* @__PURE__ */ jsxs("div", { className: "mt-2 space-y-2", children: [
|
|
2442
|
+
/* @__PURE__ */ jsx("label", { htmlFor: modelInputId, className: "mb-1 block text-sm font-medium", children: "Identifiant de mod\xE8le" }),
|
|
2443
|
+
/* @__PURE__ */ jsx(
|
|
2444
|
+
Input,
|
|
2445
|
+
{
|
|
2446
|
+
id: modelInputId,
|
|
2447
|
+
value: form.modelId,
|
|
2448
|
+
onChange: (e) => setForm({ ...form, modelId: e.target.value })
|
|
2449
|
+
}
|
|
2450
|
+
),
|
|
2451
|
+
/* @__PURE__ */ jsx("label", { htmlFor: providerInputId, className: "mb-1 block text-sm font-medium", children: "Fournisseur" }),
|
|
2452
|
+
/* @__PURE__ */ jsx(
|
|
2453
|
+
Input,
|
|
2454
|
+
{
|
|
2455
|
+
id: providerInputId,
|
|
2456
|
+
value: form.provider,
|
|
2457
|
+
onChange: (e) => setForm({ ...form, provider: e.target.value })
|
|
2458
|
+
}
|
|
2459
|
+
)
|
|
2460
|
+
] })
|
|
2351
2461
|
] }),
|
|
2352
|
-
|
|
2353
|
-
/* @__PURE__ */ jsx("
|
|
2462
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2463
|
+
/* @__PURE__ */ jsx("p", { className: "mb-1 text-sm font-medium", children: "Prompt Langfuse" }),
|
|
2464
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2 sm:grid-cols-2", children: [
|
|
2465
|
+
/* @__PURE__ */ jsx(
|
|
2466
|
+
Select,
|
|
2467
|
+
{
|
|
2468
|
+
"aria-label": "Prompt Langfuse",
|
|
2469
|
+
value: showPromptFreeText ? CUSTOM_PROMPT_VALUE : agent === "new" && form.promptName === "" ? DERIVED_PROMPT_VALUE : form.promptName,
|
|
2470
|
+
onValueChange: pickPrompt,
|
|
2471
|
+
items: [
|
|
2472
|
+
...agent === "new" ? [
|
|
2473
|
+
{
|
|
2474
|
+
value: DERIVED_PROMPT_VALUE,
|
|
2475
|
+
label: "Nouveau prompt \u2014 agent/<g\xE9n\xE9r\xE9 automatiquement>"
|
|
2476
|
+
}
|
|
2477
|
+
] : [],
|
|
2478
|
+
// The agent's stored prompt, listed so the trigger can print it
|
|
2479
|
+
// while the catalogue is still loading.
|
|
2480
|
+
...!showPromptFreeText && form.promptName !== "" && !knownPrompt ? [{ value: form.promptName, label: form.promptName }] : [],
|
|
2481
|
+
...prompts.map((entry) => ({ value: entry.name, label: entry.name })),
|
|
2482
|
+
{ value: CUSTOM_PROMPT_VALUE, label: "Autre \u2014 saisir un nom de prompt" }
|
|
2483
|
+
],
|
|
2484
|
+
disabled: promptsLoading
|
|
2485
|
+
}
|
|
2486
|
+
),
|
|
2487
|
+
/* @__PURE__ */ jsx(
|
|
2488
|
+
Select,
|
|
2489
|
+
{
|
|
2490
|
+
"aria-label": "Tag du prompt",
|
|
2491
|
+
value: form.promptLabel === "" ? DEFAULT_LABEL_VALUE : form.promptLabel,
|
|
2492
|
+
onValueChange: (next) => setForm({ ...form, promptLabel: next === DEFAULT_LABEL_VALUE ? "" : next }),
|
|
2493
|
+
items: [
|
|
2494
|
+
{ value: DEFAULT_LABEL_VALUE, label: "production (par d\xE9faut)" },
|
|
2495
|
+
...promptLabels.filter((label) => label !== DEFAULT_PROMPT_LABEL).map((label) => ({ value: label, label })),
|
|
2496
|
+
...form.promptLabel !== "" && !promptLabels.includes(form.promptLabel) ? [{ value: form.promptLabel, label: form.promptLabel }] : []
|
|
2497
|
+
],
|
|
2498
|
+
disabled: promptsLoading || form.promptName === "" && !showPromptFreeText
|
|
2499
|
+
}
|
|
2500
|
+
)
|
|
2501
|
+
] }),
|
|
2502
|
+
showPromptFreeText && /* @__PURE__ */ jsxs("div", { className: "mt-2", children: [
|
|
2503
|
+
/* @__PURE__ */ jsx("label", { htmlFor: promptInputId, className: "mb-1 block text-sm font-medium", children: "Nom du prompt Langfuse" }),
|
|
2504
|
+
/* @__PURE__ */ jsx(
|
|
2505
|
+
Input,
|
|
2506
|
+
{
|
|
2507
|
+
id: promptInputId,
|
|
2508
|
+
value: form.promptName,
|
|
2509
|
+
onChange: (e) => setForm({ ...form, promptName: e.target.value })
|
|
2510
|
+
}
|
|
2511
|
+
)
|
|
2512
|
+
] }),
|
|
2513
|
+
/* @__PURE__ */ 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." })
|
|
2514
|
+
] }),
|
|
2515
|
+
agent === "new" && !showPromptFreeText && /* @__PURE__ */ jsxs("div", { children: [
|
|
2516
|
+
/* @__PURE__ */ jsx("label", { htmlFor: snapshotId, className: "mb-1 block text-sm font-medium", children: "Prompt de l'agent" }),
|
|
2354
2517
|
/* @__PURE__ */ jsx(
|
|
2355
|
-
|
|
2518
|
+
PromptTextarea,
|
|
2356
2519
|
{
|
|
2357
|
-
id:
|
|
2358
|
-
value:
|
|
2359
|
-
onChange: (e) => setForm({ ...form,
|
|
2520
|
+
id: snapshotId,
|
|
2521
|
+
value: effectiveSnapshot,
|
|
2522
|
+
onChange: (e) => setForm({ ...form, systemPromptSnapshot: e.target.value }),
|
|
2523
|
+
readOnly: previewName !== null,
|
|
2524
|
+
className: "min-h-[40vh]"
|
|
2360
2525
|
}
|
|
2361
|
-
)
|
|
2526
|
+
),
|
|
2527
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: previewName !== null ? "Contenu actuel du prompt s\xE9lectionn\xE9 \u2014 l\u2019agent l\u2019utilisera tel quel ; ses versions se g\xE8rent apr\xE8s la cr\xE9ation." : "Devient la premi\xE8re version du nouveau prompt Langfuse, promue en production \xE0 la cr\xE9ation." })
|
|
2362
2528
|
] }),
|
|
2363
|
-
/* @__PURE__ */
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
/* @__PURE__ */ jsx(
|
|
2368
|
-
Textarea,
|
|
2369
|
-
{
|
|
2370
|
-
id: snapshotId,
|
|
2371
|
-
value: form.systemPromptSnapshot,
|
|
2372
|
-
onChange: (e) => setForm({ ...form, systemPromptSnapshot: e.target.value })
|
|
2373
|
-
}
|
|
2374
|
-
)
|
|
2529
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2 border-t pt-3", children: [
|
|
2530
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: "Annuler" }),
|
|
2531
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", disabled: isSaving || !isValid, children: isSaving ? "Enregistrement\u2026" : "Enregistrer" })
|
|
2532
|
+
] })
|
|
2375
2533
|
] }),
|
|
2376
|
-
/* @__PURE__ */ jsxs("
|
|
2377
|
-
/* @__PURE__ */
|
|
2378
|
-
|
|
2534
|
+
agent !== "new" && /* @__PURE__ */ jsxs("section", { className: "mt-6 space-y-4 border-t pt-4", children: [
|
|
2535
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2536
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold", children: "Versions du prompt Langfuse" }),
|
|
2537
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: agent.promptName })
|
|
2538
|
+
] }),
|
|
2539
|
+
/* @__PURE__ */ jsx(PromptVersionsSection, { agent, canWrite: true })
|
|
2379
2540
|
] })
|
|
2380
2541
|
] })
|
|
2381
2542
|
}
|
|
2382
2543
|
);
|
|
2383
2544
|
}
|
|
2384
|
-
function
|
|
2385
|
-
agent,
|
|
2386
|
-
canWrite,
|
|
2387
|
-
onClose
|
|
2388
|
-
}) {
|
|
2545
|
+
function PromptVersionsSection({ agent, canWrite }) {
|
|
2389
2546
|
const { appSlug } = useAppContext();
|
|
2390
2547
|
const { versions, error, refresh, promote, deleteVersion, createVersion } = usePromptVersions(
|
|
2391
2548
|
agent.promptName
|
|
@@ -2393,7 +2550,7 @@ function PromptVersionsPanel({
|
|
|
2393
2550
|
const [suggestMessage, setSuggestMessage] = useState(null);
|
|
2394
2551
|
const [isSuggesting, setIsSuggesting] = useState(false);
|
|
2395
2552
|
const isSuggestingRef = useRef(false);
|
|
2396
|
-
const
|
|
2553
|
+
const draft = useNewVersionDraft();
|
|
2397
2554
|
const [isCreatingVersion, setIsCreatingVersion] = useState(false);
|
|
2398
2555
|
const [deletingVersion, setDeletingVersion] = useState(null);
|
|
2399
2556
|
const [isComparing, setIsComparing] = useState(false);
|
|
@@ -2402,6 +2559,7 @@ function PromptVersionsPanel({
|
|
|
2402
2559
|
const newVersionId = useId();
|
|
2403
2560
|
const api = useAppApi();
|
|
2404
2561
|
const toast = useToast();
|
|
2562
|
+
const expandedVersion = defaultExpandedVersion(versions);
|
|
2405
2563
|
function openCompare() {
|
|
2406
2564
|
const sorted = [...versions].sort((a, b) => a.version - b.version);
|
|
2407
2565
|
setCompareLeft(sorted[0]?.version ?? null);
|
|
@@ -2442,8 +2600,8 @@ function PromptVersionsPanel({
|
|
|
2442
2600
|
async function runCreateVersion() {
|
|
2443
2601
|
setIsCreatingVersion(true);
|
|
2444
2602
|
try {
|
|
2445
|
-
await createVersion(
|
|
2446
|
-
|
|
2603
|
+
await createVersion(draft.content);
|
|
2604
|
+
draft.setContent("");
|
|
2447
2605
|
toast({ title: "Nouvelle version cr\xE9\xE9e.", variant: "success" });
|
|
2448
2606
|
} catch (err) {
|
|
2449
2607
|
toast({
|
|
@@ -2471,94 +2629,93 @@ function PromptVersionsPanel({
|
|
|
2471
2629
|
setDeletingVersion(null);
|
|
2472
2630
|
}
|
|
2473
2631
|
}
|
|
2474
|
-
return /* @__PURE__ */ jsxs(
|
|
2632
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2633
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
2634
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2635
|
+
/* @__PURE__ */ jsx(Link, { href: qualityHref(appSlug, agent), children: "Voir dans Qualit\xE9" }),
|
|
2636
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
2637
|
+
versions.length >= 2 && /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: openCompare, children: "Comparer" }),
|
|
2638
|
+
canWrite && /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => void suggest(), disabled: isSuggesting, children: isSuggesting ? "Suggestion en cours\u2026" : "Sugg\xE9rer une am\xE9lioration" })
|
|
2639
|
+
] })
|
|
2640
|
+
] }),
|
|
2641
|
+
suggestMessage && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: suggestMessage }),
|
|
2642
|
+
error !== void 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du chargement des versions." }),
|
|
2643
|
+
versions.length > 0 && !versions.some((v) => v.labels.includes(PRODUCTION_LABEL)) && /* @__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. Promouvez-en une pour que l'agent l'utilise." }),
|
|
2644
|
+
isComparing && compareLeft !== null && compareRight !== null && /* @__PURE__ */ jsx(
|
|
2645
|
+
VersionCompareView,
|
|
2646
|
+
{
|
|
2647
|
+
versions,
|
|
2648
|
+
leftVersion: compareLeft,
|
|
2649
|
+
rightVersion: compareRight,
|
|
2650
|
+
onSelectLeft: setCompareLeft,
|
|
2651
|
+
onSelectRight: setCompareRight
|
|
2652
|
+
}
|
|
2653
|
+
),
|
|
2654
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-3", children: versions.map((v) => /* @__PURE__ */ jsx(
|
|
2655
|
+
VersionCard,
|
|
2656
|
+
{
|
|
2657
|
+
version: v,
|
|
2658
|
+
defaultOpen: v.version === expandedVersion,
|
|
2659
|
+
onEditFrom: canWrite ? () => draft.prefill(v.content) : void 0,
|
|
2660
|
+
onPromote: canWrite ? () => void runPromote(v.version) : void 0,
|
|
2661
|
+
onDelete: canWrite ? () => setDeletingVersion(v.version) : void 0
|
|
2662
|
+
},
|
|
2663
|
+
v.version
|
|
2664
|
+
)) }),
|
|
2665
|
+
canWrite && /* @__PURE__ */ jsxs("div", { className: "space-y-2 border-t pt-3", children: [
|
|
2666
|
+
/* @__PURE__ */ jsx("label", { htmlFor: newVersionId, className: "block text-sm font-medium", children: "Nouvelle version" }),
|
|
2667
|
+
/* @__PURE__ */ jsx(
|
|
2668
|
+
PromptTextarea,
|
|
2669
|
+
{
|
|
2670
|
+
id: newVersionId,
|
|
2671
|
+
ref: draft.editorRef,
|
|
2672
|
+
value: draft.content,
|
|
2673
|
+
onChange: (e) => draft.setContent(e.target.value)
|
|
2674
|
+
}
|
|
2675
|
+
),
|
|
2676
|
+
/* @__PURE__ */ jsx(
|
|
2677
|
+
Button,
|
|
2678
|
+
{
|
|
2679
|
+
onClick: () => void runCreateVersion(),
|
|
2680
|
+
disabled: draft.content.trim() === "" || isCreatingVersion,
|
|
2681
|
+
children: isCreatingVersion ? "Cr\xE9ation\u2026" : "Cr\xE9er la version"
|
|
2682
|
+
}
|
|
2683
|
+
)
|
|
2684
|
+
] })
|
|
2685
|
+
] }),
|
|
2686
|
+
draft.pendingPrefill !== null && /* @__PURE__ */ jsx(ReplaceDraftConfirmModal, { onConfirm: draft.confirmPrefill, onCancel: draft.cancelPrefill }),
|
|
2687
|
+
deletingVersion !== null && /* @__PURE__ */ jsx(
|
|
2688
|
+
ConfirmModal,
|
|
2689
|
+
{
|
|
2690
|
+
title: "Supprimer la version ?",
|
|
2691
|
+
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2692
|
+
"La version ",
|
|
2693
|
+
deletingVersion,
|
|
2694
|
+
" de ",
|
|
2695
|
+
/* @__PURE__ */ jsx("code", { children: agent.promptName }),
|
|
2696
|
+
" sera supprim\xE9e d\xE9finitivement. Impossible si elle porte le label \xAB production \xBB ou s'il s'agit de la derni\xE8re version restante."
|
|
2697
|
+
] }),
|
|
2698
|
+
confirmLabel: "Supprimer la version",
|
|
2699
|
+
onConfirm: confirmDeleteVersion,
|
|
2700
|
+
onCancel: () => setDeletingVersion(null)
|
|
2701
|
+
}
|
|
2702
|
+
)
|
|
2703
|
+
] });
|
|
2704
|
+
}
|
|
2705
|
+
function PromptVersionsPanel({
|
|
2706
|
+
agent,
|
|
2707
|
+
canWrite,
|
|
2708
|
+
onClose
|
|
2709
|
+
}) {
|
|
2710
|
+
return /* @__PURE__ */ jsx(
|
|
2475
2711
|
SidePanel,
|
|
2476
2712
|
{
|
|
2477
2713
|
open: true,
|
|
2478
2714
|
onClose,
|
|
2479
2715
|
title: `Versions du prompt \u2014 ${agent.name}`,
|
|
2480
2716
|
description: agent.promptName,
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2484
|
-
/* @__PURE__ */ jsx(Link, { href: qualityHref(appSlug, agent), children: "Voir dans Qualit\xE9" }),
|
|
2485
|
-
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
2486
|
-
versions.length >= 2 && /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: openCompare, children: "Comparer" }),
|
|
2487
|
-
canWrite && /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => void suggest(), disabled: isSuggesting, children: isSuggesting ? "Suggestion en cours\u2026" : "Sugg\xE9rer une am\xE9lioration" })
|
|
2488
|
-
] })
|
|
2489
|
-
] }),
|
|
2490
|
-
suggestMessage && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: suggestMessage }),
|
|
2491
|
-
error !== void 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du chargement des versions." }),
|
|
2492
|
-
isComparing && compareLeft !== null && compareRight !== null && /* @__PURE__ */ jsx(
|
|
2493
|
-
VersionCompareView,
|
|
2494
|
-
{
|
|
2495
|
-
versions,
|
|
2496
|
-
leftVersion: compareLeft,
|
|
2497
|
-
rightVersion: compareRight,
|
|
2498
|
-
onSelectLeft: setCompareLeft,
|
|
2499
|
-
onSelectRight: setCompareRight
|
|
2500
|
-
}
|
|
2501
|
-
),
|
|
2502
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-3", children: versions.map((v) => /* @__PURE__ */ jsxs("div", { className: "rounded-md border p-3", children: [
|
|
2503
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2504
|
-
/* @__PURE__ */ jsxs("div", { className: "text-sm font-medium", children: [
|
|
2505
|
-
"v",
|
|
2506
|
-
v.version,
|
|
2507
|
-
" ",
|
|
2508
|
-
v.label && /* @__PURE__ */ jsx(Badge, { variant: "brand", children: v.label })
|
|
2509
|
-
] }),
|
|
2510
|
-
canWrite && /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
2511
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => void runPromote(v.version), children: "Promouvoir" }),
|
|
2512
|
-
/* @__PURE__ */ jsx(
|
|
2513
|
-
Button,
|
|
2514
|
-
{
|
|
2515
|
-
variant: "outline",
|
|
2516
|
-
size: "sm",
|
|
2517
|
-
onClick: () => setDeletingVersion(v.version),
|
|
2518
|
-
children: "Supprimer la version"
|
|
2519
|
-
}
|
|
2520
|
-
)
|
|
2521
|
-
] })
|
|
2522
|
-
] }),
|
|
2523
|
-
/* @__PURE__ */ jsx("pre", { className: "mt-2 whitespace-pre-wrap text-xs text-muted-foreground", children: v.content })
|
|
2524
|
-
] }, v.version)) }),
|
|
2525
|
-
canWrite && /* @__PURE__ */ jsxs("div", { className: "space-y-2 border-t pt-3", children: [
|
|
2526
|
-
/* @__PURE__ */ jsx("label", { htmlFor: newVersionId, className: "block text-sm font-medium", children: "Nouvelle version" }),
|
|
2527
|
-
/* @__PURE__ */ jsx(
|
|
2528
|
-
Textarea,
|
|
2529
|
-
{
|
|
2530
|
-
id: newVersionId,
|
|
2531
|
-
value: newVersionContent,
|
|
2532
|
-
onChange: (e) => setNewVersionContent(e.target.value)
|
|
2533
|
-
}
|
|
2534
|
-
),
|
|
2535
|
-
/* @__PURE__ */ jsx(
|
|
2536
|
-
Button,
|
|
2537
|
-
{
|
|
2538
|
-
onClick: () => void runCreateVersion(),
|
|
2539
|
-
disabled: newVersionContent.trim() === "" || isCreatingVersion,
|
|
2540
|
-
children: isCreatingVersion ? "Cr\xE9ation\u2026" : "Cr\xE9er la version"
|
|
2541
|
-
}
|
|
2542
|
-
)
|
|
2543
|
-
] })
|
|
2544
|
-
] }),
|
|
2545
|
-
deletingVersion !== null && /* @__PURE__ */ jsx(
|
|
2546
|
-
ConfirmModal,
|
|
2547
|
-
{
|
|
2548
|
-
title: "Supprimer la version ?",
|
|
2549
|
-
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2550
|
-
"La version ",
|
|
2551
|
-
deletingVersion,
|
|
2552
|
-
" de ",
|
|
2553
|
-
/* @__PURE__ */ jsx("code", { children: agent.promptName }),
|
|
2554
|
-
" sera supprim\xE9e d\xE9finitivement. Impossible si elle porte le label \xAB production \xBB ou s'il s'agit de la derni\xE8re version restante."
|
|
2555
|
-
] }),
|
|
2556
|
-
confirmLabel: "Supprimer la version",
|
|
2557
|
-
onConfirm: confirmDeleteVersion,
|
|
2558
|
-
onCancel: () => setDeletingVersion(null)
|
|
2559
|
-
}
|
|
2560
|
-
)
|
|
2561
|
-
]
|
|
2717
|
+
className: PROMPT_PANEL_CLASS,
|
|
2718
|
+
children: /* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx(PromptVersionsSection, { agent, canWrite }) })
|
|
2562
2719
|
}
|
|
2563
2720
|
);
|
|
2564
2721
|
}
|
|
@@ -2648,7 +2805,6 @@ function AgentsPage() {
|
|
|
2648
2805
|
name: form.name,
|
|
2649
2806
|
modelId: form.modelId,
|
|
2650
2807
|
provider: form.provider,
|
|
2651
|
-
systemPromptSnapshot: form.systemPromptSnapshot,
|
|
2652
2808
|
promptName: form.promptName.trim(),
|
|
2653
2809
|
promptLabel: form.promptLabel.trim() || null,
|
|
2654
2810
|
...formAgent.status !== "default" ? { status: form.status } : {}
|
|
@@ -2727,14 +2883,15 @@ function AgentsPage() {
|
|
|
2727
2883
|
}
|
|
2728
2884
|
),
|
|
2729
2885
|
formAgent && /* @__PURE__ */ jsx(
|
|
2730
|
-
|
|
2886
|
+
AgentFormPanel,
|
|
2731
2887
|
{
|
|
2732
2888
|
agent: formAgent,
|
|
2733
2889
|
prompts,
|
|
2734
2890
|
promptsLoading,
|
|
2735
2891
|
onClose: () => setFormAgent(null),
|
|
2736
2892
|
onSave: save
|
|
2737
|
-
}
|
|
2893
|
+
},
|
|
2894
|
+
formAgent === "new" ? "new" : formAgent.id
|
|
2738
2895
|
),
|
|
2739
2896
|
versionsAgent && /* @__PURE__ */ jsx(
|
|
2740
2897
|
PromptVersionsPanel,
|
|
@@ -2742,7 +2899,8 @@ function AgentsPage() {
|
|
|
2742
2899
|
agent: versionsAgent,
|
|
2743
2900
|
canWrite,
|
|
2744
2901
|
onClose: () => setVersionsAgent(null)
|
|
2745
|
-
}
|
|
2902
|
+
},
|
|
2903
|
+
versionsAgent.promptName
|
|
2746
2904
|
),
|
|
2747
2905
|
deletingAgent && /* @__PURE__ */ jsx(
|
|
2748
2906
|
ConfirmModal,
|
|
@@ -5165,13 +5323,12 @@ function useSharedPrompts() {
|
|
|
5165
5323
|
}, [load]);
|
|
5166
5324
|
return { prompts, isLoading, error, refresh: load };
|
|
5167
5325
|
}
|
|
5168
|
-
var PRODUCTION_LABEL = "production";
|
|
5169
5326
|
var SHARED_PREFIX2 = "shared/";
|
|
5170
5327
|
var SLUG_RE = /^[a-z0-9-]{1,64}$/;
|
|
5171
5328
|
var SLUG_ERROR = "Le nom doit contenir 1 \xE0 64 minuscules, chiffres ou tirets.";
|
|
5172
5329
|
function VersionsPanel({ name, canWrite, onClose }) {
|
|
5173
5330
|
const { versions, error, promote, deleteVersion, refresh } = usePromptVersions(name);
|
|
5174
|
-
const
|
|
5331
|
+
const draft = useNewVersionDraft();
|
|
5175
5332
|
const [isCreating, setIsCreating] = useState(false);
|
|
5176
5333
|
const [createError, setCreateError] = useState(null);
|
|
5177
5334
|
const [deletingVersion, setDeletingVersion] = useState(null);
|
|
@@ -5183,6 +5340,7 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5183
5340
|
const api = useAppApi();
|
|
5184
5341
|
const toast = useToast();
|
|
5185
5342
|
const sorted = [...versions].sort((a, b) => b.version - a.version);
|
|
5343
|
+
const expandedVersion = defaultExpandedVersion(versions);
|
|
5186
5344
|
const hasActiveVersion = versions.some((v) => v.labels.includes(PRODUCTION_LABEL));
|
|
5187
5345
|
function openCompare() {
|
|
5188
5346
|
const byVersionAsc = [...versions].sort((a, b) => a.version - b.version);
|
|
@@ -5220,14 +5378,14 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5220
5378
|
async function runCreateVersion() {
|
|
5221
5379
|
setIsCreating(true);
|
|
5222
5380
|
setCreateError(null);
|
|
5223
|
-
const payload = { name, content:
|
|
5381
|
+
const payload = { name, content: draft.content };
|
|
5224
5382
|
try {
|
|
5225
5383
|
await api.invoke(
|
|
5226
5384
|
"create-shared-prompt-version",
|
|
5227
5385
|
payload,
|
|
5228
5386
|
{ idempotencyKey: idempotencyKeyFor("create-shared-prompt-version", payload) }
|
|
5229
5387
|
);
|
|
5230
|
-
|
|
5388
|
+
draft.setContent("");
|
|
5231
5389
|
await refresh();
|
|
5232
5390
|
} catch (err) {
|
|
5233
5391
|
setCreateError(describeInvokeError(err));
|
|
@@ -5235,7 +5393,7 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5235
5393
|
setIsCreating(false);
|
|
5236
5394
|
}
|
|
5237
5395
|
}
|
|
5238
|
-
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.", children: [
|
|
5396
|
+
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: [
|
|
5239
5397
|
/* @__PURE__ */ jsxs("div", { "data-testid": "shared-prompt-versions", className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto", children: [
|
|
5240
5398
|
error !== void 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du chargement des versions." }),
|
|
5241
5399
|
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." }),
|
|
@@ -5251,34 +5409,35 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5251
5409
|
}
|
|
5252
5410
|
),
|
|
5253
5411
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
5254
|
-
sorted.map((v) => /* @__PURE__ */
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
] })
|
|
5266
|
-
] }),
|
|
5267
|
-
/* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs text-muted-foreground", children: [
|
|
5268
|
-
"Cr\xE9\xE9e le ",
|
|
5269
|
-
formatDate(v.createdAt)
|
|
5270
|
-
] }),
|
|
5271
|
-
/* @__PURE__ */ jsx("pre", { className: "mt-2 whitespace-pre-wrap text-xs text-muted-foreground", children: v.content })
|
|
5272
|
-
] }, v.version)),
|
|
5412
|
+
sorted.map((v) => /* @__PURE__ */ jsx(
|
|
5413
|
+
VersionCard,
|
|
5414
|
+
{
|
|
5415
|
+
version: v,
|
|
5416
|
+
defaultOpen: v.version === expandedVersion,
|
|
5417
|
+
onEditFrom: canWrite ? () => draft.prefill(v.content) : void 0,
|
|
5418
|
+
onPromote: canWrite ? () => setPromotingVersion(v.version) : void 0,
|
|
5419
|
+
onDelete: canWrite ? () => setDeletingVersion(v.version) : void 0
|
|
5420
|
+
},
|
|
5421
|
+
v.version
|
|
5422
|
+
)),
|
|
5273
5423
|
sorted.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune version pour l'instant." })
|
|
5274
5424
|
] }),
|
|
5275
5425
|
canWrite && /* @__PURE__ */ jsxs("div", { className: "space-y-2 border-t pt-3", children: [
|
|
5276
5426
|
/* @__PURE__ */ jsx("label", { htmlFor: newVersionId, className: "block text-sm font-medium", children: "Nouvelle version" }),
|
|
5277
|
-
/* @__PURE__ */ jsx(
|
|
5427
|
+
/* @__PURE__ */ jsx(
|
|
5428
|
+
PromptTextarea,
|
|
5429
|
+
{
|
|
5430
|
+
id: newVersionId,
|
|
5431
|
+
ref: draft.editorRef,
|
|
5432
|
+
value: draft.content,
|
|
5433
|
+
onChange: (e) => draft.setContent(e.target.value)
|
|
5434
|
+
}
|
|
5435
|
+
),
|
|
5278
5436
|
createError && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: createError }),
|
|
5279
|
-
/* @__PURE__ */ jsx(Button, { onClick: () => void runCreateVersion(), disabled:
|
|
5437
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => void runCreateVersion(), disabled: draft.content.trim() === "" || isCreating, children: isCreating ? "Cr\xE9ation\u2026" : "Cr\xE9er la version" })
|
|
5280
5438
|
] })
|
|
5281
5439
|
] }),
|
|
5440
|
+
draft.pendingPrefill !== null && /* @__PURE__ */ jsx(ReplaceDraftConfirmModal, { onConfirm: draft.confirmPrefill, onCancel: draft.cancelPrefill }),
|
|
5282
5441
|
promotingVersion !== null && /* @__PURE__ */ jsx(
|
|
5283
5442
|
ConfirmModal,
|
|
5284
5443
|
{
|
|
@@ -5363,7 +5522,7 @@ function NewSharedPromptModal({ onClose, onCreated }) {
|
|
|
5363
5522
|
setIsCreating(false);
|
|
5364
5523
|
}
|
|
5365
5524
|
}
|
|
5366
|
-
return /* @__PURE__ */ jsx(Modal, { open: true, onClose, title: "Nouveau prompt partag\xE9", children: /* @__PURE__ */ jsxs("form", { className: "space-y-3", onSubmit: (e) => void handleSubmit(e), children: [
|
|
5525
|
+
return /* @__PURE__ */ jsx(Modal, { open: true, onClose, title: "Nouveau prompt partag\xE9", className: "max-h-[85vh] max-w-2xl overflow-y-auto", children: /* @__PURE__ */ jsxs("form", { className: "space-y-3", onSubmit: (e) => void handleSubmit(e), children: [
|
|
5367
5526
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
5368
5527
|
/* @__PURE__ */ jsx("label", { htmlFor: nameId, className: "mb-1 block text-sm font-medium", children: "Nom" }),
|
|
5369
5528
|
/* @__PURE__ */ jsx(Input, { id: nameId, value: slug, onChange: (e) => handleSlugChange(e.target.value), placeholder: "tone-of-voice" }),
|
|
@@ -5375,7 +5534,7 @@ function NewSharedPromptModal({ onClose, onCreated }) {
|
|
|
5375
5534
|
] }),
|
|
5376
5535
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
5377
5536
|
/* @__PURE__ */ jsx("label", { htmlFor: contentId, className: "mb-1 block text-sm font-medium", children: "Contenu" }),
|
|
5378
|
-
/* @__PURE__ */ jsx(
|
|
5537
|
+
/* @__PURE__ */ jsx(PromptTextarea, { id: contentId, value: content, onChange: (e) => setContent(e.target.value), rows: 12 })
|
|
5379
5538
|
] }),
|
|
5380
5539
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "La premi\xE8re version est activ\xE9e imm\xE9diatement (production)." }),
|
|
5381
5540
|
error && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: error }),
|
|
@@ -5426,7 +5585,7 @@ function SharedPromptsPage() {
|
|
|
5426
5585
|
empty: "Aucun prompt \xAB shared/* \xBB accessible depuis cette app."
|
|
5427
5586
|
}
|
|
5428
5587
|
),
|
|
5429
|
-
selected && /* @__PURE__ */ jsx(VersionsPanel, { name: selected, canWrite, onClose: () => setSelected(null) }),
|
|
5588
|
+
selected && /* @__PURE__ */ jsx(VersionsPanel, { name: selected, canWrite, onClose: () => setSelected(null) }, selected),
|
|
5430
5589
|
isCreateOpen && /* @__PURE__ */ jsx(
|
|
5431
5590
|
NewSharedPromptModal,
|
|
5432
5591
|
{
|