@apotech-os/support-kit 6.0.0 → 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-CRFNVCS7.js → chunk-W2QU5367.js} +9 -5
- package/dist/chunk-W2QU5367.js.map +1 -0
- package/dist/index.cjs +21 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +384 -244
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +387 -247
- package/dist/ui/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-CRFNVCS7.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, isInvalidatableStatus, 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) {
|
|
@@ -2049,6 +2049,131 @@ function ConfirmModal({
|
|
|
2049
2049
|
] })
|
|
2050
2050
|
] }) });
|
|
2051
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
|
+
}
|
|
2052
2177
|
function usePromptVersions(promptName) {
|
|
2053
2178
|
const { appSlug } = useAppContext();
|
|
2054
2179
|
const api = useAppApi();
|
|
@@ -2206,7 +2331,7 @@ function formFromAgent(agent) {
|
|
|
2206
2331
|
var DERIVED_PROMPT_VALUE = "__derived__";
|
|
2207
2332
|
var CUSTOM_PROMPT_VALUE = "__custom-prompt__";
|
|
2208
2333
|
var DEFAULT_LABEL_VALUE = "__production__";
|
|
2209
|
-
function
|
|
2334
|
+
function AgentFormPanel({
|
|
2210
2335
|
agent,
|
|
2211
2336
|
prompts,
|
|
2212
2337
|
promptsLoading,
|
|
@@ -2230,13 +2355,17 @@ function AgentFormModal({
|
|
|
2230
2355
|
const knownPrompt = prompts.find((entry) => entry.name === form.promptName);
|
|
2231
2356
|
const showPromptFreeText = freeTextPrompt || agent !== "new" && form.promptName !== "" && !knownPrompt && !promptsLoading;
|
|
2232
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;
|
|
2233
2362
|
const isValid = form.name.trim() !== "" && form.modelId.trim() !== "" && (agent === "new" || form.promptName.trim() !== "");
|
|
2234
2363
|
async function submit(event) {
|
|
2235
2364
|
event.preventDefault();
|
|
2236
2365
|
if (isSaving || !isValid) return;
|
|
2237
2366
|
setIsSaving(true);
|
|
2238
2367
|
try {
|
|
2239
|
-
await onSave(form);
|
|
2368
|
+
await onSave({ ...form, systemPromptSnapshot: effectiveSnapshot });
|
|
2240
2369
|
} finally {
|
|
2241
2370
|
setIsSaving(false);
|
|
2242
2371
|
}
|
|
@@ -2250,161 +2379,170 @@ function AgentFormModal({
|
|
|
2250
2379
|
setForm({ ...form, promptName: next === DERIVED_PROMPT_VALUE ? "" : next, promptLabel: "" });
|
|
2251
2380
|
}
|
|
2252
2381
|
return /* @__PURE__ */ jsx(
|
|
2253
|
-
|
|
2382
|
+
SidePanel,
|
|
2254
2383
|
{
|
|
2255
2384
|
open: true,
|
|
2256
2385
|
onClose,
|
|
2257
2386
|
title: agent === "new" ? "Nouvel agent" : `Modifier ${form.name}`,
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
/* @__PURE__ */
|
|
2262
|
-
|
|
2263
|
-
{
|
|
2264
|
-
id: nameId,
|
|
2265
|
-
value: form.name,
|
|
2266
|
-
onChange: (e) => setForm({ ...form, name: e.target.value })
|
|
2267
|
-
}
|
|
2268
|
-
)
|
|
2269
|
-
] }),
|
|
2270
|
-
agent !== "new" && agent.status !== "default" && /* @__PURE__ */ jsxs("div", { children: [
|
|
2271
|
-
/* @__PURE__ */ jsx("p", { className: "mb-1 text-sm font-medium", children: "Statut" }),
|
|
2272
|
-
/* @__PURE__ */ jsx(
|
|
2273
|
-
Select,
|
|
2274
|
-
{
|
|
2275
|
-
"aria-label": "Statut",
|
|
2276
|
-
value: form.status,
|
|
2277
|
-
onValueChange: (next) => setForm({ ...form, status: next }),
|
|
2278
|
-
items: [
|
|
2279
|
-
{ value: "available", label: STATUS_LABELS.available },
|
|
2280
|
-
{ value: "archived", label: STATUS_LABELS.archived }
|
|
2281
|
-
]
|
|
2282
|
-
}
|
|
2283
|
-
)
|
|
2284
|
-
] }),
|
|
2285
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2286
|
-
/* @__PURE__ */ jsx("p", { className: "mb-1 text-sm font-medium", children: "Mod\xE8le" }),
|
|
2287
|
-
/* @__PURE__ */ jsx(
|
|
2288
|
-
Select,
|
|
2289
|
-
{
|
|
2290
|
-
"aria-label": "Mod\xE8le",
|
|
2291
|
-
value: showModelFreeText ? CUSTOM_MODEL_VALUE : form.modelId,
|
|
2292
|
-
onValueChange: (next) => {
|
|
2293
|
-
if (next === CUSTOM_MODEL_VALUE) {
|
|
2294
|
-
setFreeTextModel(true);
|
|
2295
|
-
return;
|
|
2296
|
-
}
|
|
2297
|
-
setFreeTextModel(false);
|
|
2298
|
-
setForm({ ...form, modelId: next, provider: DEFAULT_STEP_PROVIDER });
|
|
2299
|
-
},
|
|
2300
|
-
items: [
|
|
2301
|
-
// The stored model, listed so the trigger can print it while the
|
|
2302
|
-
// provider's own list is still loading.
|
|
2303
|
-
...!showModelFreeText && form.modelId !== "" && !knownModel ? [{ value: form.modelId, label: form.modelId }] : [],
|
|
2304
|
-
...models.map((name) => ({ value: name, label: name })),
|
|
2305
|
-
{ value: CUSTOM_MODEL_VALUE, label: "Autre \u2014 saisir un identifiant de mod\xE8le" }
|
|
2306
|
-
],
|
|
2307
|
-
disabled: modelsLoading
|
|
2308
|
-
}
|
|
2309
|
-
),
|
|
2310
|
-
showModelFreeText && /* @__PURE__ */ jsxs("div", { className: "mt-2 space-y-2", children: [
|
|
2311
|
-
/* @__PURE__ */ jsx("label", { htmlFor: modelInputId, className: "mb-1 block text-sm font-medium", children: "Identifiant de mod\xE8le" }),
|
|
2312
|
-
/* @__PURE__ */ jsx(
|
|
2313
|
-
Input,
|
|
2314
|
-
{
|
|
2315
|
-
id: modelInputId,
|
|
2316
|
-
value: form.modelId,
|
|
2317
|
-
onChange: (e) => setForm({ ...form, modelId: e.target.value })
|
|
2318
|
-
}
|
|
2319
|
-
),
|
|
2320
|
-
/* @__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" }),
|
|
2321
2392
|
/* @__PURE__ */ jsx(
|
|
2322
2393
|
Input,
|
|
2323
2394
|
{
|
|
2324
|
-
id:
|
|
2325
|
-
value: form.
|
|
2326
|
-
onChange: (e) => setForm({ ...form,
|
|
2395
|
+
id: nameId,
|
|
2396
|
+
value: form.name,
|
|
2397
|
+
onChange: (e) => setForm({ ...form, name: e.target.value })
|
|
2327
2398
|
}
|
|
2328
2399
|
)
|
|
2329
|
-
] })
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
/* @__PURE__ */ jsx("p", { className: "mb-1 text-sm font-medium", children: "Prompt Langfuse" }),
|
|
2333
|
-
/* @__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" }),
|
|
2334
2403
|
/* @__PURE__ */ jsx(
|
|
2335
2404
|
Select,
|
|
2336
2405
|
{
|
|
2337
|
-
"aria-label": "
|
|
2338
|
-
value:
|
|
2339
|
-
onValueChange:
|
|
2406
|
+
"aria-label": "Statut",
|
|
2407
|
+
value: form.status,
|
|
2408
|
+
onValueChange: (next) => setForm({ ...form, status: next }),
|
|
2340
2409
|
items: [
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
label: "Nouveau prompt \u2014 agent/<g\xE9n\xE9r\xE9 automatiquement>"
|
|
2345
|
-
}
|
|
2346
|
-
] : [],
|
|
2347
|
-
// The agent's stored prompt, listed so the trigger can print it
|
|
2348
|
-
// while the catalogue is still loading.
|
|
2349
|
-
...!showPromptFreeText && form.promptName !== "" && !knownPrompt ? [{ value: form.promptName, label: form.promptName }] : [],
|
|
2350
|
-
...prompts.map((entry) => ({ value: entry.name, label: entry.name })),
|
|
2351
|
-
{ value: CUSTOM_PROMPT_VALUE, label: "Autre \u2014 saisir un nom de prompt" }
|
|
2352
|
-
],
|
|
2353
|
-
disabled: promptsLoading
|
|
2410
|
+
{ value: "available", label: STATUS_LABELS.available },
|
|
2411
|
+
{ value: "archived", label: STATUS_LABELS.archived }
|
|
2412
|
+
]
|
|
2354
2413
|
}
|
|
2355
|
-
)
|
|
2414
|
+
)
|
|
2415
|
+
] }),
|
|
2416
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2417
|
+
/* @__PURE__ */ jsx("p", { className: "mb-1 text-sm font-medium", children: "Mod\xE8le" }),
|
|
2356
2418
|
/* @__PURE__ */ jsx(
|
|
2357
2419
|
Select,
|
|
2358
2420
|
{
|
|
2359
|
-
"aria-label": "
|
|
2360
|
-
value:
|
|
2361
|
-
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
|
+
},
|
|
2362
2431
|
items: [
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
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" }
|
|
2366
2437
|
],
|
|
2367
|
-
disabled:
|
|
2438
|
+
disabled: modelsLoading
|
|
2368
2439
|
}
|
|
2369
|
-
)
|
|
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
|
+
] })
|
|
2370
2461
|
] }),
|
|
2371
|
-
|
|
2372
|
-
/* @__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" }),
|
|
2373
2517
|
/* @__PURE__ */ jsx(
|
|
2374
|
-
|
|
2518
|
+
PromptTextarea,
|
|
2375
2519
|
{
|
|
2376
|
-
id:
|
|
2377
|
-
value:
|
|
2378
|
-
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]"
|
|
2379
2525
|
}
|
|
2380
|
-
)
|
|
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." })
|
|
2381
2528
|
] }),
|
|
2382
|
-
/* @__PURE__ */
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
/* @__PURE__ */ jsx(
|
|
2387
|
-
Textarea,
|
|
2388
|
-
{
|
|
2389
|
-
id: snapshotId,
|
|
2390
|
-
value: form.systemPromptSnapshot,
|
|
2391
|
-
onChange: (e) => setForm({ ...form, systemPromptSnapshot: e.target.value })
|
|
2392
|
-
}
|
|
2393
|
-
)
|
|
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
|
+
] })
|
|
2394
2533
|
] }),
|
|
2395
|
-
/* @__PURE__ */ jsxs("
|
|
2396
|
-
/* @__PURE__ */
|
|
2397
|
-
|
|
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 })
|
|
2398
2540
|
] })
|
|
2399
2541
|
] })
|
|
2400
2542
|
}
|
|
2401
2543
|
);
|
|
2402
2544
|
}
|
|
2403
|
-
function
|
|
2404
|
-
agent,
|
|
2405
|
-
canWrite,
|
|
2406
|
-
onClose
|
|
2407
|
-
}) {
|
|
2545
|
+
function PromptVersionsSection({ agent, canWrite }) {
|
|
2408
2546
|
const { appSlug } = useAppContext();
|
|
2409
2547
|
const { versions, error, refresh, promote, deleteVersion, createVersion } = usePromptVersions(
|
|
2410
2548
|
agent.promptName
|
|
@@ -2412,7 +2550,7 @@ function PromptVersionsPanel({
|
|
|
2412
2550
|
const [suggestMessage, setSuggestMessage] = useState(null);
|
|
2413
2551
|
const [isSuggesting, setIsSuggesting] = useState(false);
|
|
2414
2552
|
const isSuggestingRef = useRef(false);
|
|
2415
|
-
const
|
|
2553
|
+
const draft = useNewVersionDraft();
|
|
2416
2554
|
const [isCreatingVersion, setIsCreatingVersion] = useState(false);
|
|
2417
2555
|
const [deletingVersion, setDeletingVersion] = useState(null);
|
|
2418
2556
|
const [isComparing, setIsComparing] = useState(false);
|
|
@@ -2421,6 +2559,7 @@ function PromptVersionsPanel({
|
|
|
2421
2559
|
const newVersionId = useId();
|
|
2422
2560
|
const api = useAppApi();
|
|
2423
2561
|
const toast = useToast();
|
|
2562
|
+
const expandedVersion = defaultExpandedVersion(versions);
|
|
2424
2563
|
function openCompare() {
|
|
2425
2564
|
const sorted = [...versions].sort((a, b) => a.version - b.version);
|
|
2426
2565
|
setCompareLeft(sorted[0]?.version ?? null);
|
|
@@ -2461,8 +2600,8 @@ function PromptVersionsPanel({
|
|
|
2461
2600
|
async function runCreateVersion() {
|
|
2462
2601
|
setIsCreatingVersion(true);
|
|
2463
2602
|
try {
|
|
2464
|
-
await createVersion(
|
|
2465
|
-
|
|
2603
|
+
await createVersion(draft.content);
|
|
2604
|
+
draft.setContent("");
|
|
2466
2605
|
toast({ title: "Nouvelle version cr\xE9\xE9e.", variant: "success" });
|
|
2467
2606
|
} catch (err) {
|
|
2468
2607
|
toast({
|
|
@@ -2490,94 +2629,93 @@ function PromptVersionsPanel({
|
|
|
2490
2629
|
setDeletingVersion(null);
|
|
2491
2630
|
}
|
|
2492
2631
|
}
|
|
2493
|
-
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(
|
|
2494
2711
|
SidePanel,
|
|
2495
2712
|
{
|
|
2496
2713
|
open: true,
|
|
2497
2714
|
onClose,
|
|
2498
2715
|
title: `Versions du prompt \u2014 ${agent.name}`,
|
|
2499
2716
|
description: agent.promptName,
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2503
|
-
/* @__PURE__ */ jsx(Link, { href: qualityHref(appSlug, agent), children: "Voir dans Qualit\xE9" }),
|
|
2504
|
-
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
2505
|
-
versions.length >= 2 && /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: openCompare, children: "Comparer" }),
|
|
2506
|
-
canWrite && /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => void suggest(), disabled: isSuggesting, children: isSuggesting ? "Suggestion en cours\u2026" : "Sugg\xE9rer une am\xE9lioration" })
|
|
2507
|
-
] })
|
|
2508
|
-
] }),
|
|
2509
|
-
suggestMessage && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: suggestMessage }),
|
|
2510
|
-
error !== void 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du chargement des versions." }),
|
|
2511
|
-
isComparing && compareLeft !== null && compareRight !== null && /* @__PURE__ */ jsx(
|
|
2512
|
-
VersionCompareView,
|
|
2513
|
-
{
|
|
2514
|
-
versions,
|
|
2515
|
-
leftVersion: compareLeft,
|
|
2516
|
-
rightVersion: compareRight,
|
|
2517
|
-
onSelectLeft: setCompareLeft,
|
|
2518
|
-
onSelectRight: setCompareRight
|
|
2519
|
-
}
|
|
2520
|
-
),
|
|
2521
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-3", children: versions.map((v) => /* @__PURE__ */ jsxs("div", { className: "rounded-md border p-3", children: [
|
|
2522
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2523
|
-
/* @__PURE__ */ jsxs("div", { className: "text-sm font-medium", children: [
|
|
2524
|
-
"v",
|
|
2525
|
-
v.version,
|
|
2526
|
-
" ",
|
|
2527
|
-
v.label && /* @__PURE__ */ jsx(Badge, { variant: "brand", children: v.label })
|
|
2528
|
-
] }),
|
|
2529
|
-
canWrite && /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
2530
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => void runPromote(v.version), children: "Promouvoir" }),
|
|
2531
|
-
/* @__PURE__ */ jsx(
|
|
2532
|
-
Button,
|
|
2533
|
-
{
|
|
2534
|
-
variant: "outline",
|
|
2535
|
-
size: "sm",
|
|
2536
|
-
onClick: () => setDeletingVersion(v.version),
|
|
2537
|
-
children: "Supprimer la version"
|
|
2538
|
-
}
|
|
2539
|
-
)
|
|
2540
|
-
] })
|
|
2541
|
-
] }),
|
|
2542
|
-
/* @__PURE__ */ jsx("pre", { className: "mt-2 whitespace-pre-wrap text-xs text-muted-foreground", children: v.content })
|
|
2543
|
-
] }, v.version)) }),
|
|
2544
|
-
canWrite && /* @__PURE__ */ jsxs("div", { className: "space-y-2 border-t pt-3", children: [
|
|
2545
|
-
/* @__PURE__ */ jsx("label", { htmlFor: newVersionId, className: "block text-sm font-medium", children: "Nouvelle version" }),
|
|
2546
|
-
/* @__PURE__ */ jsx(
|
|
2547
|
-
Textarea,
|
|
2548
|
-
{
|
|
2549
|
-
id: newVersionId,
|
|
2550
|
-
value: newVersionContent,
|
|
2551
|
-
onChange: (e) => setNewVersionContent(e.target.value)
|
|
2552
|
-
}
|
|
2553
|
-
),
|
|
2554
|
-
/* @__PURE__ */ jsx(
|
|
2555
|
-
Button,
|
|
2556
|
-
{
|
|
2557
|
-
onClick: () => void runCreateVersion(),
|
|
2558
|
-
disabled: newVersionContent.trim() === "" || isCreatingVersion,
|
|
2559
|
-
children: isCreatingVersion ? "Cr\xE9ation\u2026" : "Cr\xE9er la version"
|
|
2560
|
-
}
|
|
2561
|
-
)
|
|
2562
|
-
] })
|
|
2563
|
-
] }),
|
|
2564
|
-
deletingVersion !== null && /* @__PURE__ */ jsx(
|
|
2565
|
-
ConfirmModal,
|
|
2566
|
-
{
|
|
2567
|
-
title: "Supprimer la version ?",
|
|
2568
|
-
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2569
|
-
"La version ",
|
|
2570
|
-
deletingVersion,
|
|
2571
|
-
" de ",
|
|
2572
|
-
/* @__PURE__ */ jsx("code", { children: agent.promptName }),
|
|
2573
|
-
" 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."
|
|
2574
|
-
] }),
|
|
2575
|
-
confirmLabel: "Supprimer la version",
|
|
2576
|
-
onConfirm: confirmDeleteVersion,
|
|
2577
|
-
onCancel: () => setDeletingVersion(null)
|
|
2578
|
-
}
|
|
2579
|
-
)
|
|
2580
|
-
]
|
|
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 }) })
|
|
2581
2719
|
}
|
|
2582
2720
|
);
|
|
2583
2721
|
}
|
|
@@ -2667,7 +2805,6 @@ function AgentsPage() {
|
|
|
2667
2805
|
name: form.name,
|
|
2668
2806
|
modelId: form.modelId,
|
|
2669
2807
|
provider: form.provider,
|
|
2670
|
-
systemPromptSnapshot: form.systemPromptSnapshot,
|
|
2671
2808
|
promptName: form.promptName.trim(),
|
|
2672
2809
|
promptLabel: form.promptLabel.trim() || null,
|
|
2673
2810
|
...formAgent.status !== "default" ? { status: form.status } : {}
|
|
@@ -2746,14 +2883,15 @@ function AgentsPage() {
|
|
|
2746
2883
|
}
|
|
2747
2884
|
),
|
|
2748
2885
|
formAgent && /* @__PURE__ */ jsx(
|
|
2749
|
-
|
|
2886
|
+
AgentFormPanel,
|
|
2750
2887
|
{
|
|
2751
2888
|
agent: formAgent,
|
|
2752
2889
|
prompts,
|
|
2753
2890
|
promptsLoading,
|
|
2754
2891
|
onClose: () => setFormAgent(null),
|
|
2755
2892
|
onSave: save
|
|
2756
|
-
}
|
|
2893
|
+
},
|
|
2894
|
+
formAgent === "new" ? "new" : formAgent.id
|
|
2757
2895
|
),
|
|
2758
2896
|
versionsAgent && /* @__PURE__ */ jsx(
|
|
2759
2897
|
PromptVersionsPanel,
|
|
@@ -2761,7 +2899,8 @@ function AgentsPage() {
|
|
|
2761
2899
|
agent: versionsAgent,
|
|
2762
2900
|
canWrite,
|
|
2763
2901
|
onClose: () => setVersionsAgent(null)
|
|
2764
|
-
}
|
|
2902
|
+
},
|
|
2903
|
+
versionsAgent.promptName
|
|
2765
2904
|
),
|
|
2766
2905
|
deletingAgent && /* @__PURE__ */ jsx(
|
|
2767
2906
|
ConfirmModal,
|
|
@@ -5184,13 +5323,12 @@ function useSharedPrompts() {
|
|
|
5184
5323
|
}, [load]);
|
|
5185
5324
|
return { prompts, isLoading, error, refresh: load };
|
|
5186
5325
|
}
|
|
5187
|
-
var PRODUCTION_LABEL = "production";
|
|
5188
5326
|
var SHARED_PREFIX2 = "shared/";
|
|
5189
5327
|
var SLUG_RE = /^[a-z0-9-]{1,64}$/;
|
|
5190
5328
|
var SLUG_ERROR = "Le nom doit contenir 1 \xE0 64 minuscules, chiffres ou tirets.";
|
|
5191
5329
|
function VersionsPanel({ name, canWrite, onClose }) {
|
|
5192
5330
|
const { versions, error, promote, deleteVersion, refresh } = usePromptVersions(name);
|
|
5193
|
-
const
|
|
5331
|
+
const draft = useNewVersionDraft();
|
|
5194
5332
|
const [isCreating, setIsCreating] = useState(false);
|
|
5195
5333
|
const [createError, setCreateError] = useState(null);
|
|
5196
5334
|
const [deletingVersion, setDeletingVersion] = useState(null);
|
|
@@ -5202,6 +5340,7 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5202
5340
|
const api = useAppApi();
|
|
5203
5341
|
const toast = useToast();
|
|
5204
5342
|
const sorted = [...versions].sort((a, b) => b.version - a.version);
|
|
5343
|
+
const expandedVersion = defaultExpandedVersion(versions);
|
|
5205
5344
|
const hasActiveVersion = versions.some((v) => v.labels.includes(PRODUCTION_LABEL));
|
|
5206
5345
|
function openCompare() {
|
|
5207
5346
|
const byVersionAsc = [...versions].sort((a, b) => a.version - b.version);
|
|
@@ -5239,14 +5378,14 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5239
5378
|
async function runCreateVersion() {
|
|
5240
5379
|
setIsCreating(true);
|
|
5241
5380
|
setCreateError(null);
|
|
5242
|
-
const payload = { name, content:
|
|
5381
|
+
const payload = { name, content: draft.content };
|
|
5243
5382
|
try {
|
|
5244
5383
|
await api.invoke(
|
|
5245
5384
|
"create-shared-prompt-version",
|
|
5246
5385
|
payload,
|
|
5247
5386
|
{ idempotencyKey: idempotencyKeyFor("create-shared-prompt-version", payload) }
|
|
5248
5387
|
);
|
|
5249
|
-
|
|
5388
|
+
draft.setContent("");
|
|
5250
5389
|
await refresh();
|
|
5251
5390
|
} catch (err) {
|
|
5252
5391
|
setCreateError(describeInvokeError(err));
|
|
@@ -5254,7 +5393,7 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5254
5393
|
setIsCreating(false);
|
|
5255
5394
|
}
|
|
5256
5395
|
}
|
|
5257
|
-
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: [
|
|
5258
5397
|
/* @__PURE__ */ jsxs("div", { "data-testid": "shared-prompt-versions", className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto", children: [
|
|
5259
5398
|
error !== void 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du chargement des versions." }),
|
|
5260
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." }),
|
|
@@ -5270,34 +5409,35 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5270
5409
|
}
|
|
5271
5410
|
),
|
|
5272
5411
|
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
5273
|
-
sorted.map((v) => /* @__PURE__ */
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
] })
|
|
5285
|
-
] }),
|
|
5286
|
-
/* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs text-muted-foreground", children: [
|
|
5287
|
-
"Cr\xE9\xE9e le ",
|
|
5288
|
-
formatDate(v.createdAt)
|
|
5289
|
-
] }),
|
|
5290
|
-
/* @__PURE__ */ jsx("pre", { className: "mt-2 whitespace-pre-wrap text-xs text-muted-foreground", children: v.content })
|
|
5291
|
-
] }, 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
|
+
)),
|
|
5292
5423
|
sorted.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune version pour l'instant." })
|
|
5293
5424
|
] }),
|
|
5294
5425
|
canWrite && /* @__PURE__ */ jsxs("div", { className: "space-y-2 border-t pt-3", children: [
|
|
5295
5426
|
/* @__PURE__ */ jsx("label", { htmlFor: newVersionId, className: "block text-sm font-medium", children: "Nouvelle version" }),
|
|
5296
|
-
/* @__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
|
+
),
|
|
5297
5436
|
createError && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: createError }),
|
|
5298
|
-
/* @__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" })
|
|
5299
5438
|
] })
|
|
5300
5439
|
] }),
|
|
5440
|
+
draft.pendingPrefill !== null && /* @__PURE__ */ jsx(ReplaceDraftConfirmModal, { onConfirm: draft.confirmPrefill, onCancel: draft.cancelPrefill }),
|
|
5301
5441
|
promotingVersion !== null && /* @__PURE__ */ jsx(
|
|
5302
5442
|
ConfirmModal,
|
|
5303
5443
|
{
|
|
@@ -5382,7 +5522,7 @@ function NewSharedPromptModal({ onClose, onCreated }) {
|
|
|
5382
5522
|
setIsCreating(false);
|
|
5383
5523
|
}
|
|
5384
5524
|
}
|
|
5385
|
-
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: [
|
|
5386
5526
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
5387
5527
|
/* @__PURE__ */ jsx("label", { htmlFor: nameId, className: "mb-1 block text-sm font-medium", children: "Nom" }),
|
|
5388
5528
|
/* @__PURE__ */ jsx(Input, { id: nameId, value: slug, onChange: (e) => handleSlugChange(e.target.value), placeholder: "tone-of-voice" }),
|
|
@@ -5394,7 +5534,7 @@ function NewSharedPromptModal({ onClose, onCreated }) {
|
|
|
5394
5534
|
] }),
|
|
5395
5535
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
5396
5536
|
/* @__PURE__ */ jsx("label", { htmlFor: contentId, className: "mb-1 block text-sm font-medium", children: "Contenu" }),
|
|
5397
|
-
/* @__PURE__ */ jsx(
|
|
5537
|
+
/* @__PURE__ */ jsx(PromptTextarea, { id: contentId, value: content, onChange: (e) => setContent(e.target.value), rows: 12 })
|
|
5398
5538
|
] }),
|
|
5399
5539
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "La premi\xE8re version est activ\xE9e imm\xE9diatement (production)." }),
|
|
5400
5540
|
error && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: error }),
|
|
@@ -5445,7 +5585,7 @@ function SharedPromptsPage() {
|
|
|
5445
5585
|
empty: "Aucun prompt \xAB shared/* \xBB accessible depuis cette app."
|
|
5446
5586
|
}
|
|
5447
5587
|
),
|
|
5448
|
-
selected && /* @__PURE__ */ jsx(VersionsPanel, { name: selected, canWrite, onClose: () => setSelected(null) }),
|
|
5588
|
+
selected && /* @__PURE__ */ jsx(VersionsPanel, { name: selected, canWrite, onClose: () => setSelected(null) }, selected),
|
|
5449
5589
|
isCreateOpen && /* @__PURE__ */ jsx(
|
|
5450
5590
|
NewSharedPromptModal,
|
|
5451
5591
|
{
|