@apotech-os/support-kit 10.3.0 → 10.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/dist/{chunk-ZKFQ3DIY.js → chunk-CHOOLNZW.js} +65 -3
- package/dist/chunk-CHOOLNZW.js.map +1 -0
- package/dist/index.cjs +142 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -1
- package/dist/index.d.ts +73 -1
- package/dist/index.js +88 -29
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +503 -51
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +459 -54
- package/dist/ui/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-ZKFQ3DIY.js.map +0 -1
package/dist/ui/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EVALUATION_VERDICTS, WHATSAPP_MODES, foldOutcomes, foldDailyOutcomes, fillMissingDays, autonomyRate, settledCount, countFailed, dashboardSignals, foldHumanReasons, foldCategoryOutcomes, toDeliveryPolicy, validateSettings, settingsWarnings, SUPPORT_CHANNELS, AGENT_GUARDRAILS, periodBoundsOf, toCategory, OUTCOME_METRICS, OUTCOME_GROUP_BY, TRIAGE_HANDOFF_GROUP_BY, CATEGORY_TRIAGE_GROUP_BY, CATEGORY_OUTCOME_GROUP_BY, ratePoints, REPLY_TIMING_METRICS, REPLY_TIMING_GROUP_BY, foldReplyTimings, DELAY_BUCKETS, toGeneratedResponse, toTriageDecision, toAgent, toResponseComparison, isGeneratedResponseStatus, isInvalidatableStatus, toCategoryGroup, followupIntegrationName, FOLLOWUP_WEBHOOK_TRIGGER, followupWebhookPath, FOLLOWUP_WEBHOOK_FORM, readConversationEnd, DEFAULT_CONVERSATION_END_TAG, NODE_NAMES, settingsToProfile, hasNoDraftNode, buildTimelineSteps, conversationEndEffects, outcomeTags, DEFAULT_LLM_PROVIDER, computeWordDiff, isSendableVerdict, COLLISION_GUARDRAILS, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-
|
|
2
|
-
import { forwardRef,
|
|
3
|
-
import {
|
|
1
|
+
import { EVALUATION_VERDICTS, WHATSAPP_MODES, toSharedPromptUsages, promptUsageOf, REFERENCE_TAG_SOURCE, isPromptUsedIn, foldOutcomes, foldDailyOutcomes, fillMissingDays, autonomyRate, settledCount, countFailed, dashboardSignals, foldHumanReasons, foldCategoryOutcomes, toDeliveryPolicy, DEFAULT_PROMPT_USAGE, validateSettings, settingsWarnings, SUPPORT_CHANNELS, AGENT_GUARDRAILS, SYSTEM_PROMPTS, systemPromptOf, periodBoundsOf, toCategory, OUTCOME_METRICS, OUTCOME_GROUP_BY, TRIAGE_HANDOFF_GROUP_BY, CATEGORY_TRIAGE_GROUP_BY, CATEGORY_OUTCOME_GROUP_BY, ratePoints, REPLY_TIMING_METRICS, REPLY_TIMING_GROUP_BY, foldReplyTimings, DELAY_BUCKETS, toGeneratedResponse, toTriageDecision, toAgent, toResponseComparison, isGeneratedResponseStatus, isInvalidatableStatus, toCategoryGroup, followupIntegrationName, FOLLOWUP_WEBHOOK_TRIGGER, followupWebhookPath, FOLLOWUP_WEBHOOK_FORM, readConversationEnd, DEFAULT_CONVERSATION_END_TAG, NODE_NAMES, settingsToProfile, hasNoDraftNode, isPromptUsage, buildTimelineSteps, conversationEndEffects, outcomeTags, DEFAULT_LLM_PROVIDER, computeWordDiff, isSendableVerdict, COLLISION_GUARDRAILS, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-CHOOLNZW.js';
|
|
2
|
+
import { forwardRef, useMemo, useRef, useState, useEffect, useCallback, useId } from 'react';
|
|
3
|
+
import { cn, Textarea, useAppContext, useAppApi, useAppSettings, useAppPageHref, DateRangeCompare, Link, Card, CardHeader, CardTitle, CardContent, AreaChart, StackedBarChart, Badge, useToast, Button, Select, DataTable, Spinner, Switch, Checkbox, Input, comparisonRange, SidePanel, Modal, Tooltip, buttonVariants, useAppRun, AppInvokeError, CopyButton, relativeDelta, Table, TableHeader, TableRow, TableHead, TableBody, TableCell, downloadBlob } from '@apotech-os/ui-sdk';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
function useRecordList(objectKey, query, mapper) {
|
|
@@ -364,7 +364,7 @@ function dayLabel(day) {
|
|
|
364
364
|
return Number.isNaN(parsed.getTime()) ? day : parsed.toLocaleDateString("fr-FR", { day: "2-digit", month: "2-digit", timeZone: "UTC" });
|
|
365
365
|
}
|
|
366
366
|
function DashboardPage() {
|
|
367
|
-
const
|
|
367
|
+
const pageHref = useAppPageHref();
|
|
368
368
|
const [period, setPeriod] = useState(() => defaultPeriod());
|
|
369
369
|
const { settings } = useAppSettings();
|
|
370
370
|
const timezone = settings?.statsTimezone ?? "UTC";
|
|
@@ -466,7 +466,7 @@ function DashboardPage() {
|
|
|
466
466
|
align: "end"
|
|
467
467
|
}
|
|
468
468
|
),
|
|
469
|
-
/* @__PURE__ */ jsx(Link, { href:
|
|
469
|
+
/* @__PURE__ */ jsx(Link, { href: pageHref("tickets"), children: "Voir tous les tickets" })
|
|
470
470
|
] })
|
|
471
471
|
}
|
|
472
472
|
),
|
|
@@ -2286,13 +2286,13 @@ function applyPreset(value, preset, restore) {
|
|
|
2286
2286
|
}
|
|
2287
2287
|
|
|
2288
2288
|
// src/ui/shared/quality-href.ts
|
|
2289
|
-
function qualityHref(
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2289
|
+
function qualityHref(pageHref, agent) {
|
|
2290
|
+
if (!agent) return pageHref("quality");
|
|
2291
|
+
return pageHref("quality", {
|
|
2292
|
+
promptName: agent.promptName,
|
|
2293
|
+
promptVersion: agent.promptVersion,
|
|
2294
|
+
agentId: agent.id
|
|
2295
|
+
});
|
|
2296
2296
|
}
|
|
2297
2297
|
function usePromptCatalogue() {
|
|
2298
2298
|
const { appSlug } = useAppContext();
|
|
@@ -2380,29 +2380,254 @@ function ConfirmModal({
|
|
|
2380
2380
|
] })
|
|
2381
2381
|
] }) });
|
|
2382
2382
|
}
|
|
2383
|
+
|
|
2384
|
+
// src/prompts/syntax.ts
|
|
2385
|
+
var PROMPT_VARIABLES = {
|
|
2386
|
+
agent_name: { replacedBy: "le pr\xE9nom de la personne qui r\xE9pond, vide quand l'agent r\xE9pond seul", allowsSpaces: true },
|
|
2387
|
+
categories: { replacedBy: "la liste des cat\xE9gories, dans le prompt de tri uniquement", allowsSpaces: false },
|
|
2388
|
+
channel_prompt: { replacedBy: null, allowsSpaces: false }
|
|
2389
|
+
};
|
|
2390
|
+
var USAGE_SENTENCES = {
|
|
2391
|
+
always: "Inclus dans toutes les r\xE9ponses.",
|
|
2392
|
+
auto: "R\xE9ponse automatique seulement : ignor\xE9 quand un membre de l'\xE9quipe g\xE9n\xE8re une r\xE9ponse depuis l'extension.",
|
|
2393
|
+
operator: "Op\xE9rateur seulement : ignor\xE9 quand l'agent r\xE9pond seul."
|
|
2394
|
+
};
|
|
2395
|
+
var TAG_PREFIX = "@@@langfusePrompt:";
|
|
2396
|
+
var TAG_EXAMPLE = "@@@langfusePrompt:name=shared/nom|label=production@@@";
|
|
2397
|
+
var VARIABLE_RE = /\{\{([^{}\n]*)\}\}/g;
|
|
2398
|
+
var UNCLOSED_VARIABLE_RE = /\{\{(?![^{}\n]*\}\})[^\n]*/g;
|
|
2399
|
+
function referenceTokens(content, knowledge) {
|
|
2400
|
+
const tokens = [];
|
|
2401
|
+
const wellFormedStarts = /* @__PURE__ */ new Set();
|
|
2402
|
+
for (const match of content.matchAll(new RegExp(REFERENCE_TAG_SOURCE, "g"))) {
|
|
2403
|
+
const [raw, name, version, label] = match;
|
|
2404
|
+
const start = match.index ?? 0;
|
|
2405
|
+
wellFormedStarts.add(start);
|
|
2406
|
+
tokens.push({ start, end: start + raw.length, kind: "reference", ...describeReference(name, version, label, knowledge) });
|
|
2407
|
+
}
|
|
2408
|
+
let from = content.indexOf(TAG_PREFIX);
|
|
2409
|
+
while (from !== -1) {
|
|
2410
|
+
if (!wellFormedStarts.has(from)) {
|
|
2411
|
+
tokens.push({
|
|
2412
|
+
start: from,
|
|
2413
|
+
end: malformedEnd(content, from),
|
|
2414
|
+
kind: "malformed",
|
|
2415
|
+
status: "error",
|
|
2416
|
+
message: `R\xE9f\xE9rence mal form\xE9e, elle sera envoy\xE9e telle quelle au mod\xE8le. Forme attendue : ${TAG_EXAMPLE}`
|
|
2417
|
+
});
|
|
2418
|
+
}
|
|
2419
|
+
from = content.indexOf(TAG_PREFIX, from + TAG_PREFIX.length);
|
|
2420
|
+
}
|
|
2421
|
+
return tokens;
|
|
2422
|
+
}
|
|
2423
|
+
function malformedEnd(content, start) {
|
|
2424
|
+
const lineEnd = content.indexOf("\n", start);
|
|
2425
|
+
const limit = lineEnd === -1 ? content.length : lineEnd;
|
|
2426
|
+
const closing = content.indexOf("@@@", start + TAG_PREFIX.length);
|
|
2427
|
+
return closing !== -1 && closing < limit ? closing + 3 : limit;
|
|
2428
|
+
}
|
|
2429
|
+
function describeReference(name, version, label, knowledge) {
|
|
2430
|
+
const entry = knowledge.catalogue?.find((prompt) => prompt.name === name);
|
|
2431
|
+
if (knowledge.catalogue && !entry) {
|
|
2432
|
+
return { status: "error", message: `Prompt introuvable : \xAB ${name} \xBB n'existe pas ou n'est pas accessible depuis cette app.` };
|
|
2433
|
+
}
|
|
2434
|
+
if (entry && version !== void 0 && Number(version) > entry.latestVersion) {
|
|
2435
|
+
return { status: "error", message: `La version ${version} de \xAB ${name} \xBB n'existe pas (derni\xE8re version : ${entry.latestVersion}).` };
|
|
2436
|
+
}
|
|
2437
|
+
if (entry && label !== void 0 && !entry.labels.includes(label)) {
|
|
2438
|
+
return { status: "error", message: `Aucune version de \xAB ${name} \xBB ne porte le label \xAB ${label} \xBB.` };
|
|
2439
|
+
}
|
|
2440
|
+
const usage = promptUsageOf(name, knowledge.usages);
|
|
2441
|
+
const target = version !== void 0 ? `version ${version}` : `label \xAB ${label} \xBB`;
|
|
2442
|
+
return {
|
|
2443
|
+
status: isPromptUsedIn("auto", usage) && isPromptUsedIn("operator", usage) ? "ok" : "restricted",
|
|
2444
|
+
message: `Prompt \xAB ${name} \xBB, ${target}. ${USAGE_SENTENCES[usage]}`
|
|
2445
|
+
};
|
|
2446
|
+
}
|
|
2447
|
+
function variableTokens(content) {
|
|
2448
|
+
const tokens = [];
|
|
2449
|
+
for (const match of content.matchAll(VARIABLE_RE)) {
|
|
2450
|
+
const start = match.index ?? 0;
|
|
2451
|
+
const inner = match[1] ?? "";
|
|
2452
|
+
tokens.push({ start, end: start + match[0].length, kind: "variable", ...describeVariable(inner) });
|
|
2453
|
+
}
|
|
2454
|
+
for (const match of content.matchAll(UNCLOSED_VARIABLE_RE)) {
|
|
2455
|
+
const start = match.index ?? 0;
|
|
2456
|
+
tokens.push({
|
|
2457
|
+
start,
|
|
2458
|
+
end: start + match[0].length,
|
|
2459
|
+
kind: "variable",
|
|
2460
|
+
status: "error",
|
|
2461
|
+
message: "Accolades \xAB {{ \xBB sans fermeture \xAB }} \xBB sur la m\xEAme ligne."
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
return tokens;
|
|
2465
|
+
}
|
|
2466
|
+
function describeVariable(inner) {
|
|
2467
|
+
const name = inner.trim();
|
|
2468
|
+
const known = PROMPT_VARIABLES[name];
|
|
2469
|
+
if (!known) {
|
|
2470
|
+
return {
|
|
2471
|
+
status: "error",
|
|
2472
|
+
message: `Variable inconnue : \xAB {{${name}}} \xBB ne sera pas remplac\xE9e. Variables disponibles : ${Object.keys(PROMPT_VARIABLES).join(", ")}.`
|
|
2473
|
+
};
|
|
2474
|
+
}
|
|
2475
|
+
if (known.replacedBy === null) {
|
|
2476
|
+
return { status: "error", message: `\xAB {{${name}}} \xBB n'est pas remplac\xE9e pour l'instant : elle arrive telle quelle au mod\xE8le.` };
|
|
2477
|
+
}
|
|
2478
|
+
if (inner !== name && !known.allowsSpaces) {
|
|
2479
|
+
return { status: "error", message: `\xC9crire \xAB {{${name}}} \xBB sans espaces, sinon la variable n'est pas remplac\xE9e.` };
|
|
2480
|
+
}
|
|
2481
|
+
return { status: "ok", message: `Variable remplac\xE9e par ${known.replacedBy}.` };
|
|
2482
|
+
}
|
|
2483
|
+
function readPromptSyntax(content, knowledge) {
|
|
2484
|
+
const drafts = [...referenceTokens(content, knowledge), ...variableTokens(content)].sort((a, b) => a.start - b.start);
|
|
2485
|
+
const tokens = [];
|
|
2486
|
+
let cursor = 0;
|
|
2487
|
+
let line = 1;
|
|
2488
|
+
let counted = 0;
|
|
2489
|
+
for (const draft of drafts) {
|
|
2490
|
+
if (draft.start < cursor) continue;
|
|
2491
|
+
for (; counted < draft.start; counted += 1) if (content[counted] === "\n") line += 1;
|
|
2492
|
+
tokens.push({ ...draft, line });
|
|
2493
|
+
cursor = draft.end;
|
|
2494
|
+
}
|
|
2495
|
+
return tokens;
|
|
2496
|
+
}
|
|
2497
|
+
var PROMPT_USAGE_LABELS = {
|
|
2498
|
+
always: "Toujours",
|
|
2499
|
+
auto: "R\xE9ponse automatique seulement",
|
|
2500
|
+
operator: "Op\xE9rateur seulement"
|
|
2501
|
+
};
|
|
2502
|
+
var PROMPT_USAGE_HINTS = {
|
|
2503
|
+
always: "Inclus dans toutes les r\xE9ponses.",
|
|
2504
|
+
auto: "Inclus seulement quand l'agent r\xE9pond seul. Ignor\xE9 quand un membre de l'\xE9quipe g\xE9n\xE8re une r\xE9ponse depuis l'extension.",
|
|
2505
|
+
operator: "Inclus seulement quand un membre de l'\xE9quipe g\xE9n\xE8re une r\xE9ponse depuis l'extension. Ignor\xE9 quand l'agent r\xE9pond seul."
|
|
2506
|
+
};
|
|
2507
|
+
var PROMPT_USAGE_OPTIONS = Object.keys(PROMPT_USAGE_LABELS).map((value) => ({
|
|
2508
|
+
value,
|
|
2509
|
+
label: PROMPT_USAGE_LABELS[value]
|
|
2510
|
+
}));
|
|
2511
|
+
function useSharedPromptUsages() {
|
|
2512
|
+
const { settings, error, save, isSaving, saveError } = useAppSettings();
|
|
2513
|
+
const usages = toSharedPromptUsages(settings?.sharedPromptUsages);
|
|
2514
|
+
const isReady = settings !== void 0 && error === void 0;
|
|
2515
|
+
return {
|
|
2516
|
+
usages,
|
|
2517
|
+
usageOf: (name) => promptUsageOf(name, usages),
|
|
2518
|
+
isReady,
|
|
2519
|
+
setUsage: (name, usage) => {
|
|
2520
|
+
if (!isReady) return Promise.resolve();
|
|
2521
|
+
const next = { ...usages };
|
|
2522
|
+
if (usage === DEFAULT_PROMPT_USAGE) delete next[name];
|
|
2523
|
+
else next[name] = usage;
|
|
2524
|
+
return save({ sharedPromptUsages: next });
|
|
2525
|
+
},
|
|
2526
|
+
isSaving,
|
|
2527
|
+
saveError
|
|
2528
|
+
};
|
|
2529
|
+
}
|
|
2383
2530
|
var PROMPT_PANEL_CLASS = "w-[min(92vw,64rem)] max-w-none";
|
|
2384
2531
|
var PRODUCTION_LABEL = "production";
|
|
2532
|
+
var TOKEN_CLASSES = {
|
|
2533
|
+
ok: "rounded-sm bg-status-info/15 text-status-info",
|
|
2534
|
+
restricted: "rounded-sm bg-status-pending/15 text-status-pending underline decoration-dashed underline-offset-2",
|
|
2535
|
+
error: "rounded-sm bg-status-blocked/15 text-status-blocked underline decoration-wavy underline-offset-2"
|
|
2536
|
+
};
|
|
2537
|
+
var EDITOR_BOX = "whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs leading-relaxed [scrollbar-gutter:stable]";
|
|
2385
2538
|
var PromptTextarea = forwardRef(
|
|
2386
|
-
function PromptTextarea2({ value, className, rows = 14, ...props }, ref) {
|
|
2539
|
+
function PromptTextarea2({ value, className, rows = 14, onScroll, ...props }, ref) {
|
|
2540
|
+
const knowledge = usePromptSyntaxKnowledge();
|
|
2541
|
+
const tokens = useMemo(() => readPromptSyntax(value, knowledge), [value, knowledge]);
|
|
2542
|
+
const layerRef = useRef(null);
|
|
2543
|
+
const [hovered, setHovered] = useState(null);
|
|
2544
|
+
const errors = tokens.filter((token) => token.status === "error");
|
|
2545
|
+
function hoverAt(event) {
|
|
2546
|
+
const index = document.elementsFromPoint?.(event.clientX, event.clientY).map((el) => el instanceof HTMLElement ? el.dataset.promptToken : void 0).find((found) => found !== void 0);
|
|
2547
|
+
const token = index === void 0 ? void 0 : tokens[Number(index)];
|
|
2548
|
+
const box = event.currentTarget.getBoundingClientRect();
|
|
2549
|
+
setHovered(token ? { token, x: event.clientX - box.left, y: event.clientY - box.top } : null);
|
|
2550
|
+
}
|
|
2387
2551
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
2388
|
-
/* @__PURE__ */
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2552
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
2553
|
+
/* @__PURE__ */ jsxs(
|
|
2554
|
+
"pre",
|
|
2555
|
+
{
|
|
2556
|
+
ref: layerRef,
|
|
2557
|
+
"aria-hidden": true,
|
|
2558
|
+
"data-testid": "prompt-syntax-layer",
|
|
2559
|
+
className: cn("absolute inset-0 m-0 overflow-hidden border border-transparent text-foreground", EDITOR_BOX),
|
|
2560
|
+
children: [
|
|
2561
|
+
renderSegments(value, tokens),
|
|
2562
|
+
value.endsWith("\n") ? " " : null
|
|
2563
|
+
]
|
|
2564
|
+
}
|
|
2565
|
+
),
|
|
2566
|
+
/* @__PURE__ */ jsx(
|
|
2567
|
+
Textarea,
|
|
2568
|
+
{
|
|
2569
|
+
ref,
|
|
2570
|
+
value,
|
|
2571
|
+
rows,
|
|
2572
|
+
spellCheck: false,
|
|
2573
|
+
className: cn("relative text-transparent caret-foreground", EDITOR_BOX, className),
|
|
2574
|
+
onScroll: (event) => {
|
|
2575
|
+
if (layerRef.current) layerRef.current.scrollTop = event.currentTarget.scrollTop;
|
|
2576
|
+
setHovered(null);
|
|
2577
|
+
onScroll?.(event);
|
|
2578
|
+
},
|
|
2579
|
+
onMouseMove: hoverAt,
|
|
2580
|
+
onMouseLeave: () => setHovered(null),
|
|
2581
|
+
...props
|
|
2582
|
+
}
|
|
2583
|
+
),
|
|
2584
|
+
hovered && /* @__PURE__ */ jsx(
|
|
2585
|
+
"div",
|
|
2586
|
+
{
|
|
2587
|
+
role: "tooltip",
|
|
2588
|
+
className: "pointer-events-none absolute z-50 max-w-sm rounded-md bg-foreground px-2 py-1 text-xs text-background shadow-md",
|
|
2589
|
+
style: { left: hovered.x + 12, top: hovered.y + 16 },
|
|
2590
|
+
children: hovered.token.message
|
|
2591
|
+
}
|
|
2592
|
+
)
|
|
2593
|
+
] }),
|
|
2398
2594
|
/* @__PURE__ */ jsxs("p", { className: "mt-1 text-right text-xs text-muted-foreground", children: [
|
|
2399
2595
|
value.length.toLocaleString("fr-FR"),
|
|
2400
2596
|
" caract\xE8re",
|
|
2401
2597
|
value.length > 1 ? "s" : ""
|
|
2402
|
-
] })
|
|
2598
|
+
] }),
|
|
2599
|
+
errors.length > 0 && /* @__PURE__ */ jsx("ul", { "aria-label": "Erreurs dans le prompt", className: "mt-1 space-y-1 text-xs", children: errors.map((token) => /* @__PURE__ */ jsxs("li", { className: "flex gap-2", children: [
|
|
2600
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "text-status-blocked", children: "\u2715" }),
|
|
2601
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
2602
|
+
"Ligne ",
|
|
2603
|
+
token.line,
|
|
2604
|
+
" : ",
|
|
2605
|
+
token.message
|
|
2606
|
+
] })
|
|
2607
|
+
] }, `${token.start}-${token.end}`)) })
|
|
2403
2608
|
] });
|
|
2404
2609
|
}
|
|
2405
2610
|
);
|
|
2611
|
+
function renderSegments(value, tokens) {
|
|
2612
|
+
const segments = [];
|
|
2613
|
+
let cursor = 0;
|
|
2614
|
+
tokens.forEach((token, index) => {
|
|
2615
|
+
if (token.start > cursor) segments.push(value.slice(cursor, token.start));
|
|
2616
|
+
segments.push(
|
|
2617
|
+
/* @__PURE__ */ jsx("span", { "data-prompt-token": index, "data-status": token.status, className: TOKEN_CLASSES[token.status], children: value.slice(token.start, token.end) }, token.start)
|
|
2618
|
+
);
|
|
2619
|
+
cursor = token.end;
|
|
2620
|
+
});
|
|
2621
|
+
if (cursor < value.length) segments.push(value.slice(cursor));
|
|
2622
|
+
return segments;
|
|
2623
|
+
}
|
|
2624
|
+
function usePromptSyntaxKnowledge() {
|
|
2625
|
+
const { prompts, isLoading, error } = usePromptCatalogue();
|
|
2626
|
+
const { usages } = useSharedPromptUsages();
|
|
2627
|
+
const catalogue = isLoading || error !== void 0 ? null : prompts;
|
|
2628
|
+
const usagesKey = JSON.stringify(usages);
|
|
2629
|
+
return useMemo(() => ({ catalogue, usages }), [catalogue, usagesKey]);
|
|
2630
|
+
}
|
|
2406
2631
|
function defaultExpandedVersion(versions) {
|
|
2407
2632
|
const production = versions.find((v) => v.labels.includes(PRODUCTION_LABEL));
|
|
2408
2633
|
if (production) return production.version;
|
|
@@ -2457,8 +2682,8 @@ function VersionCard({
|
|
|
2457
2682
|
] })
|
|
2458
2683
|
] });
|
|
2459
2684
|
}
|
|
2460
|
-
function useNewVersionDraft() {
|
|
2461
|
-
const [content, setContent] = useState(
|
|
2685
|
+
function useNewVersionDraft(initialContent = "") {
|
|
2686
|
+
const [content, setContent] = useState(initialContent);
|
|
2462
2687
|
const [pendingPrefill, setPendingPrefill] = useState(null);
|
|
2463
2688
|
const editorRef = useRef(null);
|
|
2464
2689
|
function loadIntoEditor(versionContent) {
|
|
@@ -2874,7 +3099,7 @@ function AgentFormPanel({
|
|
|
2874
3099
|
);
|
|
2875
3100
|
}
|
|
2876
3101
|
function PromptVersionsSection({ agent, canWrite }) {
|
|
2877
|
-
const
|
|
3102
|
+
const pageHref = useAppPageHref();
|
|
2878
3103
|
const { versions, error, refresh, promote, deleteVersion, createVersion } = usePromptVersions(
|
|
2879
3104
|
agent.promptName
|
|
2880
3105
|
);
|
|
@@ -2963,7 +3188,7 @@ function PromptVersionsSection({ agent, canWrite }) {
|
|
|
2963
3188
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2964
3189
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
2965
3190
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2966
|
-
/* @__PURE__ */ jsx(Link, { href: qualityHref(
|
|
3191
|
+
/* @__PURE__ */ jsx(Link, { href: qualityHref(pageHref, agent), children: "Voir dans Qualit\xE9" }),
|
|
2967
3192
|
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
2968
3193
|
versions.length >= 2 && /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: openCompare, children: "Comparer" }),
|
|
2969
3194
|
canWrite && /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => void suggest(), disabled: isSuggesting, children: isSuggesting ? "Suggestion en cours\u2026" : "Sugg\xE9rer une am\xE9lioration" })
|
|
@@ -4322,7 +4547,10 @@ var WHATSAPP_MODE_LABELS = {
|
|
|
4322
4547
|
draft_only: "Brouillon uniquement",
|
|
4323
4548
|
auto_reply: "R\xE9ponse automatique"
|
|
4324
4549
|
};
|
|
4325
|
-
var WHATSAPP_MODE_OPTIONS = WHATSAPP_MODES.map((value) => ({
|
|
4550
|
+
var WHATSAPP_MODE_OPTIONS = WHATSAPP_MODES.map((value) => ({
|
|
4551
|
+
value,
|
|
4552
|
+
label: WHATSAPP_MODE_LABELS[value]
|
|
4553
|
+
}));
|
|
4326
4554
|
function field(value) {
|
|
4327
4555
|
return typeof value === "string" ? value : "";
|
|
4328
4556
|
}
|
|
@@ -4341,7 +4569,10 @@ function parseList(value) {
|
|
|
4341
4569
|
function describeConnection(connections) {
|
|
4342
4570
|
if (connections === void 0) return { text: "Chargement\u2026", tone: "muted" };
|
|
4343
4571
|
if (connections === null) {
|
|
4344
|
-
return {
|
|
4572
|
+
return {
|
|
4573
|
+
text: "Ind\xE9termin\xE9e \u2014 les connexions de l\u2019instance n\u2019ont pas pu \xEAtre lues.",
|
|
4574
|
+
tone: "muted"
|
|
4575
|
+
};
|
|
4345
4576
|
}
|
|
4346
4577
|
if (connections.length === 0) {
|
|
4347
4578
|
return {
|
|
@@ -4358,13 +4589,17 @@ function describeConnection(connections) {
|
|
|
4358
4589
|
tone: "error"
|
|
4359
4590
|
};
|
|
4360
4591
|
}
|
|
4361
|
-
return {
|
|
4592
|
+
return {
|
|
4593
|
+
text: `${fallback.label} (par d\xE9faut, parmi ${connections.length} connexions)`,
|
|
4594
|
+
tone: "normal"
|
|
4595
|
+
};
|
|
4362
4596
|
}
|
|
4363
4597
|
function SettingsWarnings({ warnings }) {
|
|
4364
4598
|
return /* @__PURE__ */ jsx(Fragment, { children: warnings.map((warning) => /* @__PURE__ */ jsx("p", { className: "text-sm text-status-pending", children: warning.message }, warning.key)) });
|
|
4365
4599
|
}
|
|
4366
4600
|
function SettingsPage() {
|
|
4367
4601
|
const { appSlug, role } = useAppContext();
|
|
4602
|
+
const pageHref = useAppPageHref();
|
|
4368
4603
|
const canWrite = canWriteForRole(role);
|
|
4369
4604
|
const api = useAppApi();
|
|
4370
4605
|
const toast = useToast();
|
|
@@ -4387,7 +4622,12 @@ function SettingsPage() {
|
|
|
4387
4622
|
useEffect(() => {
|
|
4388
4623
|
if (wasSavingRef.current && !isSaving) {
|
|
4389
4624
|
if (saveError === void 0) toast({ title: "R\xE9glages enregistr\xE9s.", variant: "success" });
|
|
4390
|
-
else
|
|
4625
|
+
else
|
|
4626
|
+
toast({
|
|
4627
|
+
title: "\xC9chec de l'enregistrement",
|
|
4628
|
+
description: describeApiError(saveError),
|
|
4629
|
+
variant: "error"
|
|
4630
|
+
});
|
|
4391
4631
|
}
|
|
4392
4632
|
wasSavingRef.current = isSaving;
|
|
4393
4633
|
}, [isSaving, saveError, toast]);
|
|
@@ -4398,7 +4638,9 @@ function SettingsPage() {
|
|
|
4398
4638
|
(async () => {
|
|
4399
4639
|
let checkAppSlugs = [];
|
|
4400
4640
|
try {
|
|
4401
|
-
const installed = await apiRef.current.get(
|
|
4641
|
+
const installed = await apiRef.current.get(
|
|
4642
|
+
"/platform/apps/installed"
|
|
4643
|
+
);
|
|
4402
4644
|
checkAppSlugs = installed.apps.map((a) => a.slug).filter((slug) => slug !== appSlug);
|
|
4403
4645
|
if (!cancelled) setInstalledAppsUnavailable(false);
|
|
4404
4646
|
} catch {
|
|
@@ -4406,7 +4648,9 @@ function SettingsPage() {
|
|
|
4406
4648
|
if (!cancelled) setInstalledAppsUnavailable(true);
|
|
4407
4649
|
}
|
|
4408
4650
|
try {
|
|
4409
|
-
const result = await apiRef.current.invoke("list-gorgias-views", {
|
|
4651
|
+
const result = await apiRef.current.invoke("list-gorgias-views", {
|
|
4652
|
+
checkAppSlugs
|
|
4653
|
+
});
|
|
4410
4654
|
if (!cancelled) {
|
|
4411
4655
|
setViews(result.views);
|
|
4412
4656
|
setUncheckedAppSlugs(result.uncheckedAppSlugs);
|
|
@@ -4637,7 +4881,15 @@ function SettingsPage() {
|
|
|
4637
4881
|
["appScopeTag", "Tag des tickets de l'application"]
|
|
4638
4882
|
].map(([key, label]) => /* @__PURE__ */ jsxs("div", { children: [
|
|
4639
4883
|
/* @__PURE__ */ jsx("label", { htmlFor: key, className: "mb-1 block text-sm font-medium", children: label }),
|
|
4640
|
-
/* @__PURE__ */ jsx(
|
|
4884
|
+
/* @__PURE__ */ jsx(
|
|
4885
|
+
Input,
|
|
4886
|
+
{
|
|
4887
|
+
id: key,
|
|
4888
|
+
value: field(form[key]),
|
|
4889
|
+
onChange: (e) => set(key, e.target.value),
|
|
4890
|
+
disabled: !canWrite
|
|
4891
|
+
}
|
|
4892
|
+
)
|
|
4641
4893
|
] }, key)),
|
|
4642
4894
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Le tag des tickets de l\u2019application est obligatoire. Il est pos\xE9 sur chaque ticket que le triage examine, et c\u2019est lui qui dit qu\u2019un ticket appartient \xE0 cette app : les r\xE9ponses aux messages suivants et l\u2019agent par d\xE9faut propos\xE9 dans l\u2019extension Gorgias s\u2019appuient dessus. Il doit \xEAtre propre \xE0 cette app, distinct de celui d\u2019une autre app install\xE9e sur le m\xEAme compte Gorgias." }),
|
|
4643
4895
|
/* @__PURE__ */ jsx(SettingsWarnings, { warnings: tagWarnings })
|
|
@@ -4793,7 +5045,7 @@ function SettingsPage() {
|
|
|
4793
5045
|
"Catalogue de prompts indisponible \u2014 ",
|
|
4794
5046
|
describeApiError(promptCatalogue.error)
|
|
4795
5047
|
] }),
|
|
4796
|
-
/* @__PURE__ */ jsx(Link, { href:
|
|
5048
|
+
/* @__PURE__ */ jsx(Link, { href: pageHref("graph-canvas"), children: "Visualiser dans Graphe" })
|
|
4797
5049
|
] }) }),
|
|
4798
5050
|
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-3 p-4", children: [
|
|
4799
5051
|
/* @__PURE__ */ jsx("h2", { className: "font-medium", children: "Agents support" }),
|
|
@@ -5893,9 +6145,23 @@ function useSharedPrompts() {
|
|
|
5893
6145
|
var SHARED_PREFIX2 = "shared/";
|
|
5894
6146
|
var SLUG_RE = /^[a-z0-9-]{1,64}$/;
|
|
5895
6147
|
var SLUG_ERROR = "Le nom doit contenir 1 \xE0 64 minuscules, chiffres ou tirets.";
|
|
5896
|
-
function VersionsPanel({
|
|
5897
|
-
|
|
5898
|
-
|
|
6148
|
+
function VersionsPanel({
|
|
6149
|
+
name,
|
|
6150
|
+
canWrite,
|
|
6151
|
+
usage,
|
|
6152
|
+
isAdmin,
|
|
6153
|
+
canEditUsage,
|
|
6154
|
+
isSavingUsage,
|
|
6155
|
+
onUsageChange,
|
|
6156
|
+
system,
|
|
6157
|
+
isPublished,
|
|
6158
|
+
servesDefault,
|
|
6159
|
+
onPublished,
|
|
6160
|
+
onClose
|
|
6161
|
+
}) {
|
|
6162
|
+
const [exists, setExists] = useState(isPublished);
|
|
6163
|
+
const { versions, error, promote, deleteVersion, refresh } = usePromptVersions(exists ? name : null);
|
|
6164
|
+
const draft = useNewVersionDraft(servesDefault ? system?.defaultContent ?? "" : "");
|
|
5899
6165
|
const [isCreating, setIsCreating] = useState(false);
|
|
5900
6166
|
const [createError, setCreateError] = useState(null);
|
|
5901
6167
|
const [deletingVersion, setDeletingVersion] = useState(null);
|
|
@@ -5905,6 +6171,7 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5905
6171
|
const [compareRight, setCompareRight] = useState(null);
|
|
5906
6172
|
const newVersionId = useId();
|
|
5907
6173
|
const api = useAppApi();
|
|
6174
|
+
const { appSlug } = useAppContext();
|
|
5908
6175
|
const toast = useToast();
|
|
5909
6176
|
const sorted = [...versions].sort((a, b) => b.version - a.version);
|
|
5910
6177
|
const expandedVersion = defaultExpandedVersion(versions);
|
|
@@ -5922,6 +6189,7 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5922
6189
|
const version = promotingVersion;
|
|
5923
6190
|
try {
|
|
5924
6191
|
await promote(version);
|
|
6192
|
+
onPublished();
|
|
5925
6193
|
toast({ title: `Version ${version} promue en production.`, variant: "success" });
|
|
5926
6194
|
} catch (err) {
|
|
5927
6195
|
toast({ title: "\xC9chec de la promotion", description: describeApiError(err), variant: "error" });
|
|
@@ -5947,13 +6215,21 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5947
6215
|
setCreateError(null);
|
|
5948
6216
|
const payload = { name, content: draft.content };
|
|
5949
6217
|
try {
|
|
5950
|
-
await api.invoke(
|
|
6218
|
+
const result = await api.invoke(
|
|
5951
6219
|
"create-shared-prompt-version",
|
|
5952
6220
|
payload,
|
|
5953
6221
|
{ idempotencyKey: idempotencyKeyFor("create-shared-prompt-version", payload) }
|
|
5954
6222
|
);
|
|
5955
6223
|
draft.setContent("");
|
|
5956
|
-
|
|
6224
|
+
if (exists) {
|
|
6225
|
+
await refresh();
|
|
6226
|
+
} else {
|
|
6227
|
+
await api.post(`/data/apps/${appSlug}/prompts/promote`, { name, version: result.version, label: PRODUCTION_LABEL }).catch(() => {
|
|
6228
|
+
toast({ title: "Version cr\xE9\xE9e, mais pas encore en production", description: "Promouvez-la pour qu'elle soit utilis\xE9e.", variant: "error" });
|
|
6229
|
+
});
|
|
6230
|
+
setExists(true);
|
|
6231
|
+
onPublished();
|
|
6232
|
+
}
|
|
5957
6233
|
} catch (err) {
|
|
5958
6234
|
setCreateError(describeInvokeError(err));
|
|
5959
6235
|
} finally {
|
|
@@ -5963,6 +6239,37 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5963
6239
|
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: [
|
|
5964
6240
|
/* @__PURE__ */ jsxs("div", { "data-testid": "shared-prompt-versions", className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto", children: [
|
|
5965
6241
|
error !== void 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du chargement des versions." }),
|
|
6242
|
+
system && /* @__PURE__ */ jsxs("div", { className: "space-y-1 rounded-md border bg-muted/40 p-3 text-sm", children: [
|
|
6243
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium", children: "Prompt syst\xE8me" }),
|
|
6244
|
+
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground", children: [
|
|
6245
|
+
system.description,
|
|
6246
|
+
" Il existe toujours et son nom ne peut pas changer : seul son texte se modifie."
|
|
6247
|
+
] }),
|
|
6248
|
+
(!exists || versions.length > 0 && !hasActiveVersion) && /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground", children: [
|
|
6249
|
+
"Aucune version en production : le texte par d\xE9faut est utilis\xE9.",
|
|
6250
|
+
exists ? " Promouvez une version pour la mettre en service." : " Cr\xE9ez une version pour le modifier."
|
|
6251
|
+
] })
|
|
6252
|
+
] }),
|
|
6253
|
+
!system && /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
6254
|
+
/* @__PURE__ */ jsx("p", { className: "block text-sm font-medium", children: "Utilisation" }),
|
|
6255
|
+
/* @__PURE__ */ jsx(
|
|
6256
|
+
Select,
|
|
6257
|
+
{
|
|
6258
|
+
"aria-label": "Utilisation",
|
|
6259
|
+
value: usage,
|
|
6260
|
+
onValueChange: (value) => {
|
|
6261
|
+
if (isPromptUsage(value)) onUsageChange(value);
|
|
6262
|
+
},
|
|
6263
|
+
items: PROMPT_USAGE_OPTIONS,
|
|
6264
|
+
disabled: !canEditUsage || isSavingUsage
|
|
6265
|
+
}
|
|
6266
|
+
),
|
|
6267
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
6268
|
+
PROMPT_USAGE_HINTS[usage],
|
|
6269
|
+
" Ce r\xE9glage ne vaut que pour cette app.",
|
|
6270
|
+
!isAdmin && " Seul un administrateur de l'app peut le changer."
|
|
6271
|
+
] })
|
|
6272
|
+
] }),
|
|
5966
6273
|
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." }),
|
|
5967
6274
|
versions.length >= 2 && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: openCompare, children: "Comparer" }) }),
|
|
5968
6275
|
isComparing && compareLeft !== null && compareRight !== null && /* @__PURE__ */ jsx(
|
|
@@ -5987,7 +6294,7 @@ function VersionsPanel({ name, canWrite, onClose }) {
|
|
|
5987
6294
|
},
|
|
5988
6295
|
v.version
|
|
5989
6296
|
)),
|
|
5990
|
-
sorted.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune version pour l'instant." })
|
|
6297
|
+
sorted.length === 0 && exists && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune version pour l'instant." })
|
|
5991
6298
|
] }),
|
|
5992
6299
|
canWrite && /* @__PURE__ */ jsxs("div", { className: "space-y-2 border-t pt-3", children: [
|
|
5993
6300
|
/* @__PURE__ */ jsx("label", { htmlFor: newVersionId, className: "block text-sm font-medium", children: "Nouvelle version" }),
|
|
@@ -6115,16 +6422,61 @@ function SharedPromptsPage() {
|
|
|
6115
6422
|
const { role } = useAppContext();
|
|
6116
6423
|
const canWrite = canWriteForRole(role);
|
|
6117
6424
|
const { prompts, isLoading, error, refresh } = useSharedPrompts();
|
|
6425
|
+
const { usageOf, setUsage, isReady: areUsagesReady, isSaving: isSavingUsage, saveError: usageSaveError } = useSharedPromptUsages();
|
|
6426
|
+
const toast = useToast();
|
|
6118
6427
|
const [selected, setSelected] = useState(null);
|
|
6119
6428
|
const [isCreateOpen, setIsCreateOpen] = useState(false);
|
|
6429
|
+
const wasSavingUsageRef = useRef(false);
|
|
6430
|
+
useEffect(() => {
|
|
6431
|
+
if (wasSavingUsageRef.current && !isSavingUsage) {
|
|
6432
|
+
if (usageSaveError === void 0) toast({ title: "Utilisation enregistr\xE9e.", variant: "success" });
|
|
6433
|
+
else toast({ title: "\xC9chec de l'enregistrement", description: describeApiError(usageSaveError), variant: "error" });
|
|
6434
|
+
}
|
|
6435
|
+
wasSavingUsageRef.current = isSavingUsage;
|
|
6436
|
+
}, [isSavingUsage, usageSaveError, toast]);
|
|
6437
|
+
const publishedNames = new Set(prompts.map((prompt) => prompt.name));
|
|
6438
|
+
const rows = isLoading || error ? prompts : [
|
|
6439
|
+
...prompts,
|
|
6440
|
+
...SYSTEM_PROMPTS.filter((system) => !publishedNames.has(system.name)).map((system) => ({
|
|
6441
|
+
name: system.name,
|
|
6442
|
+
labels: [],
|
|
6443
|
+
latestVersion: 0,
|
|
6444
|
+
isUnpublished: true
|
|
6445
|
+
}))
|
|
6446
|
+
].sort((a, b) => a.name.localeCompare(b.name));
|
|
6447
|
+
const selectedSystem = selected ? systemPromptOf(selected) : void 0;
|
|
6120
6448
|
const columns = [
|
|
6121
|
-
{
|
|
6449
|
+
{
|
|
6450
|
+
key: "name",
|
|
6451
|
+
header: "Nom",
|
|
6452
|
+
cell: (row) => systemPromptOf(row.name) ? /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-2", children: [
|
|
6453
|
+
row.name,
|
|
6454
|
+
/* @__PURE__ */ jsx(Badge, { children: "Syst\xE8me" })
|
|
6455
|
+
] }) : row.name
|
|
6456
|
+
},
|
|
6457
|
+
{
|
|
6458
|
+
key: "usage",
|
|
6459
|
+
header: "Utilisation",
|
|
6460
|
+
cell: (row) => {
|
|
6461
|
+
const usage = systemPromptOf(row.name)?.usage ?? usageOf(row.name);
|
|
6462
|
+
return usage === DEFAULT_PROMPT_USAGE ? PROMPT_USAGE_LABELS[usage] : /* @__PURE__ */ jsx(Badge, { variant: "info", children: PROMPT_USAGE_LABELS[usage] });
|
|
6463
|
+
}
|
|
6464
|
+
},
|
|
6122
6465
|
{
|
|
6123
6466
|
key: "labels",
|
|
6124
6467
|
header: "Labels",
|
|
6125
6468
|
cell: (row) => row.labels.length > 0 ? row.labels.map((l) => /* @__PURE__ */ jsx(Badge, { children: l }, l)) : "\u2014"
|
|
6126
6469
|
},
|
|
6127
|
-
{
|
|
6470
|
+
{
|
|
6471
|
+
key: "latestVersion",
|
|
6472
|
+
header: "Derni\xE8re version",
|
|
6473
|
+
align: "right",
|
|
6474
|
+
cell: (row) => {
|
|
6475
|
+
if (row.isUnpublished) return "Texte par d\xE9faut";
|
|
6476
|
+
const servesDefault = systemPromptOf(row.name) && !row.labels.includes(PRODUCTION_LABEL);
|
|
6477
|
+
return servesDefault ? `v${row.latestVersion} \xB7 texte par d\xE9faut utilis\xE9` : `v${row.latestVersion}`;
|
|
6478
|
+
}
|
|
6479
|
+
}
|
|
6128
6480
|
];
|
|
6129
6481
|
return /* @__PURE__ */ jsxs(PageShell, { children: [
|
|
6130
6482
|
/* @__PURE__ */ jsx(
|
|
@@ -6140,7 +6492,7 @@ function SharedPromptsPage() {
|
|
|
6140
6492
|
DataTable,
|
|
6141
6493
|
{
|
|
6142
6494
|
columns,
|
|
6143
|
-
rows
|
|
6495
|
+
rows,
|
|
6144
6496
|
rowId: (row) => row.name,
|
|
6145
6497
|
manual: true,
|
|
6146
6498
|
loading: isLoading,
|
|
@@ -6152,7 +6504,24 @@ function SharedPromptsPage() {
|
|
|
6152
6504
|
empty: "Aucun prompt \xAB shared/* \xBB accessible depuis cette app."
|
|
6153
6505
|
}
|
|
6154
6506
|
),
|
|
6155
|
-
selected && /* @__PURE__ */ jsx(
|
|
6507
|
+
selected && /* @__PURE__ */ jsx(
|
|
6508
|
+
VersionsPanel,
|
|
6509
|
+
{
|
|
6510
|
+
name: selected,
|
|
6511
|
+
canWrite,
|
|
6512
|
+
usage: usageOf(selected),
|
|
6513
|
+
isAdmin: role === "ADMIN",
|
|
6514
|
+
canEditUsage: role === "ADMIN" && areUsagesReady,
|
|
6515
|
+
isSavingUsage,
|
|
6516
|
+
onUsageChange: (usage) => void setUsage(selected, usage),
|
|
6517
|
+
system: selectedSystem,
|
|
6518
|
+
isPublished: !rows.some((row) => row.name === selected && row.isUnpublished),
|
|
6519
|
+
servesDefault: selectedSystem !== void 0 && !rows.some((row) => row.name === selected && row.labels.includes(PRODUCTION_LABEL)),
|
|
6520
|
+
onPublished: () => void refresh(),
|
|
6521
|
+
onClose: () => setSelected(null)
|
|
6522
|
+
},
|
|
6523
|
+
selected
|
|
6524
|
+
),
|
|
6156
6525
|
isCreateOpen && /* @__PURE__ */ jsx(
|
|
6157
6526
|
NewSharedPromptModal,
|
|
6158
6527
|
{
|
|
@@ -6429,7 +6798,8 @@ function parseRunResult(result) {
|
|
|
6429
6798
|
};
|
|
6430
6799
|
}
|
|
6431
6800
|
function describeRunDecision(result, mode) {
|
|
6432
|
-
if (result.stoppedAt === "FC" && result.outcome === "no_reply_needed")
|
|
6801
|
+
if (result.stoppedAt === "FC" && result.outcome === "no_reply_needed")
|
|
6802
|
+
return "Conversation finie \u2014 aucune r\xE9ponse.";
|
|
6433
6803
|
if (result.stoppedAt !== null) return `Arr\xEAt en ${result.stoppedAt}.`;
|
|
6434
6804
|
const category = result.categoryName ? ` (cat\xE9gorie \xAB ${result.categoryName} \xBB)` : "";
|
|
6435
6805
|
if (result.outcome === "sent") {
|
|
@@ -6441,6 +6811,7 @@ function describeRunDecision(result, mode) {
|
|
|
6441
6811
|
function FollowupWebhookCard2() {
|
|
6442
6812
|
const api = useAppApi();
|
|
6443
6813
|
const { appSlug } = useAppContext();
|
|
6814
|
+
const pageHref = useAppPageHref();
|
|
6444
6815
|
const toast = useToast();
|
|
6445
6816
|
const ticketId = useId();
|
|
6446
6817
|
const [ticket, setTicket] = useState("");
|
|
@@ -6470,7 +6841,9 @@ function FollowupWebhookCard2() {
|
|
|
6470
6841
|
setIsTesting(true);
|
|
6471
6842
|
setTest(null);
|
|
6472
6843
|
try {
|
|
6473
|
-
setTest(
|
|
6844
|
+
setTest(
|
|
6845
|
+
await api.invoke("test-gorgias-webhook", { ticketId: ticket.trim(), mode })
|
|
6846
|
+
);
|
|
6474
6847
|
} catch (err) {
|
|
6475
6848
|
toast({ title: "\xC9chec du test", description: describeInvokeError(err), variant: "error" });
|
|
6476
6849
|
} finally {
|
|
@@ -6498,9 +6871,36 @@ function FollowupWebhookCard2() {
|
|
|
6498
6871
|
className: "max-w-48"
|
|
6499
6872
|
}
|
|
6500
6873
|
),
|
|
6501
|
-
/* @__PURE__ */ jsx(
|
|
6502
|
-
|
|
6503
|
-
|
|
6874
|
+
/* @__PURE__ */ jsx(
|
|
6875
|
+
Button,
|
|
6876
|
+
{
|
|
6877
|
+
type: "button",
|
|
6878
|
+
variant: "outline",
|
|
6879
|
+
onClick: () => void runTest("diagnostic"),
|
|
6880
|
+
disabled,
|
|
6881
|
+
children: "Diagnostic"
|
|
6882
|
+
}
|
|
6883
|
+
),
|
|
6884
|
+
/* @__PURE__ */ jsx(
|
|
6885
|
+
Button,
|
|
6886
|
+
{
|
|
6887
|
+
type: "button",
|
|
6888
|
+
variant: "outline",
|
|
6889
|
+
onClick: () => void runTest("generate"),
|
|
6890
|
+
disabled,
|
|
6891
|
+
children: "G\xE9n\xE9rer sans envoyer"
|
|
6892
|
+
}
|
|
6893
|
+
),
|
|
6894
|
+
/* @__PURE__ */ jsx(
|
|
6895
|
+
Button,
|
|
6896
|
+
{
|
|
6897
|
+
type: "button",
|
|
6898
|
+
variant: "outline",
|
|
6899
|
+
onClick: () => setConfirmingRealRun(true),
|
|
6900
|
+
disabled,
|
|
6901
|
+
children: "Ex\xE9cution r\xE9elle"
|
|
6902
|
+
}
|
|
6903
|
+
)
|
|
6504
6904
|
] }),
|
|
6505
6905
|
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
6506
6906
|
"Le diagnostic \xE9value les m\xEAmes conditions que le webhook, sans aucun effet de bord.",
|
|
@@ -6540,7 +6940,13 @@ function FollowupWebhookCard2() {
|
|
|
6540
6940
|
/* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap rounded border bg-muted/30 p-2 text-xs", children: draftText })
|
|
6541
6941
|
] }),
|
|
6542
6942
|
/* @__PURE__ */ jsxs("p", { className: "text-xs", children: [
|
|
6543
|
-
/* @__PURE__ */ jsx(
|
|
6943
|
+
/* @__PURE__ */ jsx(
|
|
6944
|
+
Link,
|
|
6945
|
+
{
|
|
6946
|
+
href: pageHref("tickets", { ticket: runResult.ticketId ?? test.ticketId }),
|
|
6947
|
+
children: "Ouvrir la fiche du ticket"
|
|
6948
|
+
}
|
|
6949
|
+
),
|
|
6544
6950
|
runResult.ticketUrl !== null && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6545
6951
|
" \xB7 ",
|
|
6546
6952
|
/* @__PURE__ */ jsx(Link, { href: runResult.ticketUrl, target: "_blank", rel: "noopener noreferrer", children: "Ouvrir dans Gorgias" })
|
|
@@ -6561,8 +6967,7 @@ function FollowupWebhookCard2() {
|
|
|
6561
6967
|
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6562
6968
|
"Le ticket ",
|
|
6563
6969
|
ticket.trim(),
|
|
6564
|
-
" va \xEAtre trait\xE9 comme un vrai message suivant : g\xE9n\xE9ration, garde-fous, et",
|
|
6565
|
-
" ",
|
|
6970
|
+
" va \xEAtre trait\xE9 comme un vrai message suivant : g\xE9n\xE9ration, garde-fous, et ",
|
|
6566
6971
|
/* @__PURE__ */ jsx("strong", { children: "envoi r\xE9el au client" }),
|
|
6567
6972
|
" si sa cat\xE9gorie est en r\xE9ponse automatique. Pour tout voir sans rien envoyer, utilisez \xAB G\xE9n\xE9rer sans envoyer \xBB."
|
|
6568
6973
|
] }),
|