@apotech-os/support-kit 6.2.0 → 7.0.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-W2QU5367.js → chunk-CQJJZA4F.js} +46 -16
- package/dist/chunk-CQJJZA4F.js.map +1 -0
- package/dist/index.cjs +66 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +23 -2
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +595 -363
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +224 -27
- package/dist/ui/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-W2QU5367.js.map +0 -1
package/dist/ui/index.cjs
CHANGED
|
@@ -7,6 +7,41 @@ var appKit = require('@apotech-os/app-kit');
|
|
|
7
7
|
|
|
8
8
|
// src/ui/dashboard/dashboard-page.tsx
|
|
9
9
|
|
|
10
|
+
// src/graph/state.ts
|
|
11
|
+
var OUTCOMES = [
|
|
12
|
+
"sent",
|
|
13
|
+
// reply posted to the customer
|
|
14
|
+
"ready",
|
|
15
|
+
// servable to the extension, NO tag (nominal path)
|
|
16
|
+
"needs_human",
|
|
17
|
+
// unsendable verdict → ready + needs-review tag
|
|
18
|
+
"guardrail_hold",
|
|
19
|
+
// a guardrail fired → ready + escalation tag
|
|
20
|
+
"awaiting_approval",
|
|
21
|
+
// an action awaits human sign-off (P3)
|
|
22
|
+
"escalated",
|
|
23
|
+
// escalated upstream, no generation happened
|
|
24
|
+
"triaged_only",
|
|
25
|
+
// tenant/ticket has no draft step to run
|
|
26
|
+
"no_reply_needed",
|
|
27
|
+
// triage read the thread as already closed → NO tag, like 'ready' (whatsapp spec §5.2)
|
|
28
|
+
"failed"
|
|
29
|
+
];
|
|
30
|
+
function isOutcome(value) {
|
|
31
|
+
return typeof value === "string" && OUTCOMES.includes(value);
|
|
32
|
+
}
|
|
33
|
+
var NODE_NAMES = [
|
|
34
|
+
"fetchContext",
|
|
35
|
+
"triage",
|
|
36
|
+
"escalate",
|
|
37
|
+
"draft",
|
|
38
|
+
"evaluate",
|
|
39
|
+
"revise",
|
|
40
|
+
"guardrails",
|
|
41
|
+
"authorize",
|
|
42
|
+
"act"
|
|
43
|
+
];
|
|
44
|
+
|
|
10
45
|
// src/domain/evaluation-verdict.ts
|
|
11
46
|
var EVALUATION_VERDICTS = ["send", "send_and_escalate", "hold"];
|
|
12
47
|
function isEvaluationVerdict(value) {
|
|
@@ -15,6 +50,9 @@ function isEvaluationVerdict(value) {
|
|
|
15
50
|
function isSendableVerdict(verdict) {
|
|
16
51
|
return verdict === "send" || verdict === "send_and_escalate";
|
|
17
52
|
}
|
|
53
|
+
function requiresFollowup(verdict) {
|
|
54
|
+
return verdict === "send_and_escalate";
|
|
55
|
+
}
|
|
18
56
|
|
|
19
57
|
// src/functions/records.ts
|
|
20
58
|
function toAgent(record) {
|
|
@@ -108,6 +146,7 @@ function toGeneratedResponse(record) {
|
|
|
108
146
|
sources: Array.isArray(data.sources) ? data.sources : [],
|
|
109
147
|
verdict: toVerdict(data.verdict),
|
|
110
148
|
guardrailHits: data.guardrailHits ?? [],
|
|
149
|
+
outcome: isOutcome(data.outcome) ? data.outcome : null,
|
|
111
150
|
triageDecisionId: data.triageDecisionId ?? null,
|
|
112
151
|
channel: data.channel ?? null,
|
|
113
152
|
autoSendDecision: data.autoSendDecision ?? null,
|
|
@@ -1241,6 +1280,245 @@ function responseOutcome(job) {
|
|
|
1241
1280
|
return { label, variant: "neutral" };
|
|
1242
1281
|
}
|
|
1243
1282
|
|
|
1283
|
+
// src/domain/profile.ts
|
|
1284
|
+
var DEFAULT_PROFILE_KEY = "customer";
|
|
1285
|
+
var WHATSAPP_MODES = ["escalate_only", "draft_only", "auto_reply"];
|
|
1286
|
+
var AGENT_FIELD_NAME_UID = "e9cfec6f-15c6-4d02-8f79-0667f64b9eb5";
|
|
1287
|
+
var AGENT_FIELD_PROVIDER_UID = "e522b809-e8a7-4439-a2df-936158d04389";
|
|
1288
|
+
var AGENT_FIELD_MODEL_ID_UID = "d95977ba-362c-44d6-a2f0-24156c76cf8a";
|
|
1289
|
+
var AGENT_FIELD_STATUS_UID = "348725a0-a896-4f8d-8a56-86f4193234a8";
|
|
1290
|
+
var AGENT_FIELD_DEFAULT_KEY_UID = "0134491a-c969-4c42-894c-36ad4880fed3";
|
|
1291
|
+
var AGENT_FIELD_PROMPT_NAME_UID = "32e7f234-00bb-44d2-917b-be28f32f7214";
|
|
1292
|
+
var AGENT_FIELD_PROMPT_LABEL_UID = "bdee53ff-571a-4df6-91ec-00b513a70fe0";
|
|
1293
|
+
var AGENT_FIELD_PROMPT_VERSION_UID = "e7c66f99-e1e0-4fc2-9f9e-3bafe3af8e88";
|
|
1294
|
+
var AGENT_FIELD_SYSTEM_PROMPT_SNAPSHOT_UID = "710b73c6-929b-48b7-abc0-792849adf1c2";
|
|
1295
|
+
var AGENT_FIELD_REASONING_EFFORT_UID = "aa57fc6e-c989-47d3-9fc8-e04184b1e67c";
|
|
1296
|
+
var AGENT_FIELD_MAX_TOOL_CALLS_UID = "6948a5ca-48ef-45d7-9118-c7ab195343a3";
|
|
1297
|
+
|
|
1298
|
+
// src/records/agent.ts
|
|
1299
|
+
var AGENT_STATUSES = ["default", "available", "archived"];
|
|
1300
|
+
var REASONING_EFFORT_OPTIONS = ["off", "low", "medium", "high"];
|
|
1301
|
+
var DEFAULT_LLM_PROVIDER = "openai";
|
|
1302
|
+
({
|
|
1303
|
+
fields: [
|
|
1304
|
+
{
|
|
1305
|
+
universalIdentifier: AGENT_FIELD_NAME_UID,
|
|
1306
|
+
name: "name",
|
|
1307
|
+
type: appKit.FieldType.TEXT,
|
|
1308
|
+
label: "Name",
|
|
1309
|
+
isNullable: false
|
|
1310
|
+
},
|
|
1311
|
+
{
|
|
1312
|
+
universalIdentifier: AGENT_FIELD_PROVIDER_UID,
|
|
1313
|
+
name: "provider",
|
|
1314
|
+
type: appKit.FieldType.TEXT,
|
|
1315
|
+
label: "Provider",
|
|
1316
|
+
description: "Free text (spec \xA73.4) \u2014 a new provider must not need a kit release.",
|
|
1317
|
+
isNullable: false,
|
|
1318
|
+
defaultValue: DEFAULT_LLM_PROVIDER
|
|
1319
|
+
},
|
|
1320
|
+
{
|
|
1321
|
+
universalIdentifier: AGENT_FIELD_MODEL_ID_UID,
|
|
1322
|
+
name: "modelId",
|
|
1323
|
+
type: appKit.FieldType.TEXT,
|
|
1324
|
+
label: "Model id",
|
|
1325
|
+
isNullable: false
|
|
1326
|
+
},
|
|
1327
|
+
{
|
|
1328
|
+
universalIdentifier: AGENT_FIELD_STATUS_UID,
|
|
1329
|
+
name: "status",
|
|
1330
|
+
type: appKit.FieldType.SELECT,
|
|
1331
|
+
label: "Status",
|
|
1332
|
+
isNullable: false,
|
|
1333
|
+
options: [...AGENT_STATUSES],
|
|
1334
|
+
defaultValue: "available"
|
|
1335
|
+
},
|
|
1336
|
+
{
|
|
1337
|
+
universalIdentifier: AGENT_FIELD_DEFAULT_KEY_UID,
|
|
1338
|
+
name: "defaultKey",
|
|
1339
|
+
type: appKit.FieldType.TEXT,
|
|
1340
|
+
label: "Default key",
|
|
1341
|
+
description: "Equals 'default' when status='default', absent otherwise. Unique.",
|
|
1342
|
+
isNullable: true
|
|
1343
|
+
},
|
|
1344
|
+
{
|
|
1345
|
+
universalIdentifier: AGENT_FIELD_PROMPT_NAME_UID,
|
|
1346
|
+
name: "promptName",
|
|
1347
|
+
type: appKit.FieldType.TEXT,
|
|
1348
|
+
label: "Prompt name",
|
|
1349
|
+
description: "Free Langfuse prompt name (ETL keeps legacy agent/<old id> names).",
|
|
1350
|
+
isNullable: false
|
|
1351
|
+
},
|
|
1352
|
+
{
|
|
1353
|
+
universalIdentifier: AGENT_FIELD_PROMPT_LABEL_UID,
|
|
1354
|
+
name: "promptLabel",
|
|
1355
|
+
type: appKit.FieldType.TEXT,
|
|
1356
|
+
label: "Prompt label",
|
|
1357
|
+
isNullable: true
|
|
1358
|
+
},
|
|
1359
|
+
{
|
|
1360
|
+
universalIdentifier: AGENT_FIELD_PROMPT_VERSION_UID,
|
|
1361
|
+
name: "promptVersion",
|
|
1362
|
+
type: appKit.FieldType.NUMBER,
|
|
1363
|
+
label: "Prompt version",
|
|
1364
|
+
description: 'Pinning; absent means "follow the label".',
|
|
1365
|
+
isNullable: true
|
|
1366
|
+
},
|
|
1367
|
+
{
|
|
1368
|
+
universalIdentifier: AGENT_FIELD_SYSTEM_PROMPT_SNAPSHOT_UID,
|
|
1369
|
+
name: "systemPromptSnapshot",
|
|
1370
|
+
type: appKit.FieldType.TEXT,
|
|
1371
|
+
label: "System prompt snapshot",
|
|
1372
|
+
description: "Level-3 fallback of the prompt ladder (\xA73.7).",
|
|
1373
|
+
isNullable: true
|
|
1374
|
+
},
|
|
1375
|
+
{
|
|
1376
|
+
universalIdentifier: AGENT_FIELD_REASONING_EFFORT_UID,
|
|
1377
|
+
name: "reasoningEffort",
|
|
1378
|
+
type: appKit.FieldType.SELECT,
|
|
1379
|
+
label: "Reasoning effort",
|
|
1380
|
+
isNullable: true,
|
|
1381
|
+
options: [...REASONING_EFFORT_OPTIONS]
|
|
1382
|
+
},
|
|
1383
|
+
{
|
|
1384
|
+
universalIdentifier: AGENT_FIELD_MAX_TOOL_CALLS_UID,
|
|
1385
|
+
name: "maxToolCalls",
|
|
1386
|
+
type: appKit.FieldType.NUMBER,
|
|
1387
|
+
label: "Max tool calls",
|
|
1388
|
+
isNullable: true
|
|
1389
|
+
}
|
|
1390
|
+
]});
|
|
1391
|
+
|
|
1392
|
+
// src/settings/to-profile.ts
|
|
1393
|
+
var DEFAULT_REASONING = "off";
|
|
1394
|
+
var DEFAULT_MAX_TOOL_CALLS = 5;
|
|
1395
|
+
function toAuditTags(settings) {
|
|
1396
|
+
return {
|
|
1397
|
+
unknownTag: settings.unknownTag,
|
|
1398
|
+
handledTag: settings.handledTag,
|
|
1399
|
+
escalationTag: settings.escalationTag,
|
|
1400
|
+
sentTag: settings.autoRepliedTag,
|
|
1401
|
+
needsHumanTag: settings.needsReviewTag,
|
|
1402
|
+
followupTag: settings.followupTag
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
var DEFAULT_MIN_CONFIDENCE = 0.8;
|
|
1406
|
+
var DEFAULT_ESCALATION_ENABLED = false;
|
|
1407
|
+
var JUDGEME_ESCALATE_ONLY = true;
|
|
1408
|
+
var TRIAGE_CONCURRENCY = 1;
|
|
1409
|
+
var FAST_RESPONSE_CONCURRENCY = 3;
|
|
1410
|
+
var FAST_RESPONSE_INTERVAL_SECONDS = 0;
|
|
1411
|
+
var FAST_RESPONSE_BATCH_LIMIT = 1;
|
|
1412
|
+
function settingsToProfile(settings, prompts) {
|
|
1413
|
+
const evaluate = toEvaluateNode(settings.nodes.evaluate);
|
|
1414
|
+
return {
|
|
1415
|
+
key: DEFAULT_PROFILE_KEY,
|
|
1416
|
+
// One app installs one kit, so its profile is that app's only tenant —
|
|
1417
|
+
// the multi-tenant `key` of the legacy is now the app boundary itself.
|
|
1418
|
+
isDefault: true,
|
|
1419
|
+
enabled: settings.triageEnabled,
|
|
1420
|
+
source: { channel: "gorgias", viewOrTag: settings.sourceViewId },
|
|
1421
|
+
schedule: {
|
|
1422
|
+
triageIntervalMinutes: settings.triageIntervalMinutes,
|
|
1423
|
+
triageBatchLimit: settings.batchLimit,
|
|
1424
|
+
triageConcurrency: TRIAGE_CONCURRENCY,
|
|
1425
|
+
fastResponseIntervalSeconds: FAST_RESPONSE_INTERVAL_SECONDS,
|
|
1426
|
+
fastResponseBatchLimit: FAST_RESPONSE_BATCH_LIMIT,
|
|
1427
|
+
fastResponseConcurrency: FAST_RESPONSE_CONCURRENCY,
|
|
1428
|
+
fastResponseTtlMinutes: settings.responseTtlMinutes
|
|
1429
|
+
},
|
|
1430
|
+
nodes: {
|
|
1431
|
+
triage: baseNode(settings.nodes.triage),
|
|
1432
|
+
escalate: settings.nodes.escalate ? baseNode(settings.nodes.escalate) : null,
|
|
1433
|
+
draft: settings.nodes.draft ? {
|
|
1434
|
+
...baseNode(settings.nodes.draft),
|
|
1435
|
+
maxToolCalls: settings.nodes.draft.maxToolCalls ?? DEFAULT_MAX_TOOL_CALLS
|
|
1436
|
+
} : null,
|
|
1437
|
+
evaluate,
|
|
1438
|
+
revise: settings.nodes.revise ? baseNode(settings.nodes.revise) : null
|
|
1439
|
+
},
|
|
1440
|
+
prompts,
|
|
1441
|
+
// No settings surface for the §6.2 tool allowlist yet (the registry
|
|
1442
|
+
// already refuses every write tool on its own). Default-deny until
|
|
1443
|
+
// T22 has a real list to pass; an empty list only costs the `draft`
|
|
1444
|
+
// node its optional lookups, it never opens anything.
|
|
1445
|
+
tools: [],
|
|
1446
|
+
guardrails: {
|
|
1447
|
+
active: [...settings.guardrailsActive],
|
|
1448
|
+
params: {
|
|
1449
|
+
noreplySenders: [...settings.noreplySenders],
|
|
1450
|
+
blocklist: [...settings.blocklist],
|
|
1451
|
+
whatsappMode: settings.whatsappMode,
|
|
1452
|
+
judgemeEscalateOnly: JUDGEME_ESCALATE_ONLY,
|
|
1453
|
+
channelPromptEmail: settings.channelPromptEmail,
|
|
1454
|
+
channelPromptWhatsapp: settings.channelPromptWhatsapp
|
|
1455
|
+
}
|
|
1456
|
+
},
|
|
1457
|
+
// `authorize` is DEFAULT DENY on an absent kind, so the one action kind
|
|
1458
|
+
// that exists must be stated: auto-send on ⇒ the graph may send, off ⇒
|
|
1459
|
+
// a human approves. Nothing here can reach 'forbidden' — that decision
|
|
1460
|
+
// belongs to P3's per-role policy, which needs a runtime context this
|
|
1461
|
+
// pure mapper does not have.
|
|
1462
|
+
authorization: { send_reply: settings.autoSendEnabled ? "auto" : "needs_approval" },
|
|
1463
|
+
audit: toAuditTags(settings),
|
|
1464
|
+
autoSend: {
|
|
1465
|
+
enabled: settings.autoSendEnabled,
|
|
1466
|
+
senderEmail: settings.senderEmail === "" ? null : settings.senderEmail,
|
|
1467
|
+
// The auto-send floor is the evaluation floor: a second, independent
|
|
1468
|
+
// threshold would be a silent way to send below the one an operator set.
|
|
1469
|
+
minConfidence: evaluate?.minConfidence ?? DEFAULT_MIN_CONFIDENCE,
|
|
1470
|
+
requireHighTriage: settings.requireHighTriageConfidence
|
|
1471
|
+
},
|
|
1472
|
+
rename: settings.renameEnabled ? { enabled: true, from: settings.renameFrom, to: settings.renameTo } : null,
|
|
1473
|
+
// Locks and run stamps are per-run state: they live in the
|
|
1474
|
+
// `pipeline-state` record (§3.4), never in settings.
|
|
1475
|
+
runtime: {
|
|
1476
|
+
triageLock: { acquiredAt: null, owner: null },
|
|
1477
|
+
fastResponseLock: { acquiredAt: null, owner: null },
|
|
1478
|
+
triageLastRun: { startedAt: null, completedAt: null, status: null },
|
|
1479
|
+
fastResponseLastRun: { startedAt: null, completedAt: null, status: null },
|
|
1480
|
+
lastAutoSendDecisionAt: null
|
|
1481
|
+
}
|
|
1482
|
+
};
|
|
1483
|
+
}
|
|
1484
|
+
function baseNode(node) {
|
|
1485
|
+
return {
|
|
1486
|
+
model: node.model,
|
|
1487
|
+
provider: node.provider ?? DEFAULT_LLM_PROVIDER,
|
|
1488
|
+
reasoning: node.reasoning ?? DEFAULT_REASONING
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
function toEvaluateNode(node) {
|
|
1492
|
+
if (!node) return null;
|
|
1493
|
+
return {
|
|
1494
|
+
...baseNode(node),
|
|
1495
|
+
minConfidence: node.minConfidence ?? DEFAULT_MIN_CONFIDENCE,
|
|
1496
|
+
escalationEnabled: node.escalationEnabled ?? DEFAULT_ESCALATION_ENABLED
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
// src/ui/tickets/delivery-policy.ts
|
|
1501
|
+
function evaluateNode(settings) {
|
|
1502
|
+
const node = settings.nodes?.evaluate;
|
|
1503
|
+
return node && typeof node === "object" ? node : null;
|
|
1504
|
+
}
|
|
1505
|
+
function toDeliveryPolicy(raw) {
|
|
1506
|
+
if (!raw || typeof raw !== "object") return null;
|
|
1507
|
+
const settings = raw;
|
|
1508
|
+
const evaluate = evaluateNode(settings);
|
|
1509
|
+
const senderEmail = typeof settings.senderEmail === "string" ? settings.senderEmail : "";
|
|
1510
|
+
return {
|
|
1511
|
+
followupSendable: typeof evaluate?.escalationEnabled === "boolean" ? evaluate.escalationEnabled : DEFAULT_ESCALATION_ENABLED,
|
|
1512
|
+
minConfidence: typeof evaluate?.minConfidence === "number" ? evaluate.minConfidence : DEFAULT_MIN_CONFIDENCE,
|
|
1513
|
+
evaluateConfigured: evaluate !== null,
|
|
1514
|
+
autoSendEnabled: settings.autoSendEnabled === true,
|
|
1515
|
+
senderEmail: senderEmail === "" ? null : senderEmail,
|
|
1516
|
+
whatsappMode: typeof settings.whatsappMode === "string" ? settings.whatsappMode : null,
|
|
1517
|
+
dryRun: settings.dryRun === true,
|
|
1518
|
+
audit: toAuditTags(settings)
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1244
1522
|
// src/functions/response-comparison-diff.ts
|
|
1245
1523
|
function tokenize(text) {
|
|
1246
1524
|
return (text ?? "").split(/(\s+)/).filter((token) => token.length > 0);
|
|
@@ -1400,7 +1678,8 @@ function evaluationReason({ job, decision }) {
|
|
|
1400
1678
|
if (job.status === "pending") return "L'\xE9valuation n'a pas encore tourn\xE9.";
|
|
1401
1679
|
return "Aucun verdict : l'\xE9valuation n'a pas \xE9t\xE9 atteinte.";
|
|
1402
1680
|
}
|
|
1403
|
-
function deliveryReason(
|
|
1681
|
+
function deliveryReason(input) {
|
|
1682
|
+
const { job, decision } = input;
|
|
1404
1683
|
if (!job) return noResponseCause(decision);
|
|
1405
1684
|
switch (job.status) {
|
|
1406
1685
|
case "sent":
|
|
@@ -1408,15 +1687,88 @@ function deliveryReason({ job, decision }) {
|
|
|
1408
1687
|
case "pending":
|
|
1409
1688
|
return "La r\xE9ponse est encore en file.";
|
|
1410
1689
|
case "ready":
|
|
1411
|
-
return
|
|
1412
|
-
case "expired":
|
|
1413
|
-
|
|
1690
|
+
return notSentReason(input);
|
|
1691
|
+
case "expired": {
|
|
1692
|
+
const why = notSentReason(input);
|
|
1693
|
+
return why === GENERIC_NOT_SENT ? "La r\xE9ponse a expir\xE9 avant son envoi." : `La r\xE9ponse a expir\xE9 avant son envoi. ${why}`;
|
|
1694
|
+
}
|
|
1414
1695
|
case "failed":
|
|
1415
1696
|
return job.error ?? "La r\xE9ponse a \xE9chou\xE9 avant son envoi.";
|
|
1416
1697
|
default:
|
|
1417
1698
|
return `La r\xE9ponse n'a pas \xE9t\xE9 envoy\xE9e (statut : ${job.status}).`;
|
|
1418
1699
|
}
|
|
1419
1700
|
}
|
|
1701
|
+
var GENERIC_NOT_SENT = "R\xE9dig\xE9e, en attente d'un envoi.";
|
|
1702
|
+
function notSentReason({ job, policy, category }) {
|
|
1703
|
+
if (!job) return GENERIC_NOT_SENT;
|
|
1704
|
+
if (job.autoSendDecision === "hold") {
|
|
1705
|
+
return "Mise en attente d\xE9finitive : cette r\xE9ponse ne repartira pas toute seule (refus d\u2019approbation, contr\xF4le de derni\xE8re minute, ou envoi interrompu puis repris).";
|
|
1706
|
+
}
|
|
1707
|
+
switch (job.outcome) {
|
|
1708
|
+
case "needs_human":
|
|
1709
|
+
return notSendableReason(job, policy);
|
|
1710
|
+
case "guardrail_hold":
|
|
1711
|
+
return guardrailReason(job);
|
|
1712
|
+
case "awaiting_approval":
|
|
1713
|
+
return "En attente d'une approbation humaine avant envoi.";
|
|
1714
|
+
case "ready":
|
|
1715
|
+
return notEligibleReason(job, policy, category);
|
|
1716
|
+
case "sent":
|
|
1717
|
+
return "Mode essai : la r\xE9ponse aurait \xE9t\xE9 envoy\xE9e, mais rien n'a \xE9t\xE9 transmis au client.";
|
|
1718
|
+
case null:
|
|
1719
|
+
return legacyNotSentReason(job, policy, category);
|
|
1720
|
+
default:
|
|
1721
|
+
return GENERIC_NOT_SENT;
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
function notSendableReason(job, policy) {
|
|
1725
|
+
const verdict = job.verdict;
|
|
1726
|
+
if (!verdict) return "L'\xE9valuation n'a produit aucun verdict \u2014 par s\xE9curit\xE9, la r\xE9ponse part en revue humaine.";
|
|
1727
|
+
if (verdict.status === "error") return "L'\xE9valuation a \xE9chou\xE9 \u2014 par s\xE9curit\xE9, la r\xE9ponse part en revue humaine.";
|
|
1728
|
+
if (verdict.verdict === "hold") return "Le juge a retenu la r\xE9ponse (verdict \xAB Retenir \xBB) \u2014 elle demande une relecture.";
|
|
1729
|
+
if (!policy) return "Le juge n'a pas autoris\xE9 l'envoi automatique.";
|
|
1730
|
+
if ((verdict.confidence ?? 0) < policy.minConfidence) {
|
|
1731
|
+
return `Confiance de ${asPercent(verdict.confidence ?? 0)} %, sous le seuil de ${asPercent(policy.minConfidence)} % fix\xE9 sur l'\xE9tape \xC9valuation.`;
|
|
1732
|
+
}
|
|
1733
|
+
if (requiresFollowup(verdict.verdict) && !policy.followupSendable) {
|
|
1734
|
+
return "Le juge a valid\xE9 la r\xE9ponse mais demand\xE9 un suivi humain (verdict \xAB Envoyer et escalader \xBB). L'option \xAB Envoyer les r\xE9ponses qui demandent un suivi humain \xBB est d\xE9sactiv\xE9e sur l'\xE9tape \xC9valuation : la r\xE9ponse n'est donc pas envoy\xE9e.";
|
|
1735
|
+
}
|
|
1736
|
+
return "Le juge n'a pas autoris\xE9 l'envoi automatique.";
|
|
1737
|
+
}
|
|
1738
|
+
function notEligibleReason(job, policy, category) {
|
|
1739
|
+
if (!policy) return GENERIC_NOT_SENT;
|
|
1740
|
+
if (!policy.evaluateConfigured) {
|
|
1741
|
+
return "L'\xE9tape \xC9valuation est coup\xE9e : sans verdict, l'envoi automatique est impossible.";
|
|
1742
|
+
}
|
|
1743
|
+
if (!policy.autoSendEnabled) return "L'envoi automatique est d\xE9sactiv\xE9 dans les r\xE9glages.";
|
|
1744
|
+
if (category && !category.autoReplyEnabled) {
|
|
1745
|
+
return `La cat\xE9gorie \xAB ${category.name} \xBB n'a pas l'auto-r\xE9ponse activ\xE9e.`;
|
|
1746
|
+
}
|
|
1747
|
+
const isWhatsapp = job.channel === "whatsapp";
|
|
1748
|
+
if (isWhatsapp && policy.whatsappMode === "draft_only") {
|
|
1749
|
+
return "Mode WhatsApp \xAB brouillon seul \xBB : la r\xE9ponse est r\xE9dig\xE9e, jamais envoy\xE9e automatiquement.";
|
|
1750
|
+
}
|
|
1751
|
+
if (!policy.senderEmail && !(isWhatsapp && policy.whatsappMode === "auto_reply")) {
|
|
1752
|
+
return "Aucune adresse d'exp\xE9dition n'est configur\xE9e dans les r\xE9glages.";
|
|
1753
|
+
}
|
|
1754
|
+
return GENERIC_NOT_SENT;
|
|
1755
|
+
}
|
|
1756
|
+
function guardrailReason(job) {
|
|
1757
|
+
if (job.guardrailHits.length === 0) return "Un garde-fou a bloqu\xE9 l'envoi.";
|
|
1758
|
+
return `Garde-fou d\xE9clench\xE9 : ${job.guardrailHits.map(guardrailHitLabel).join(", ")}.`;
|
|
1759
|
+
}
|
|
1760
|
+
function legacyNotSentReason(job, policy, category) {
|
|
1761
|
+
if (job.guardrailHits.length > 0) return guardrailReason(job);
|
|
1762
|
+
const verdict = job.verdict;
|
|
1763
|
+
if (policy && verdict && verdict.status === "success" && requiresFollowup(verdict.verdict) && !policy.followupSendable) {
|
|
1764
|
+
return "Probablement : le juge a valid\xE9 la r\xE9ponse en demandant un suivi humain, et l'option \xAB Envoyer les r\xE9ponses qui demandent un suivi humain \xBB est d\xE9sactiv\xE9e sur l'\xE9tape \xC9valuation. (R\xE9ponse ant\xE9rieure \xE0 l'enregistrement des sorties de run \u2014 lecture faite avec les r\xE9glages actuels.)";
|
|
1765
|
+
}
|
|
1766
|
+
if (verdict && (verdict.status === "error" || verdict.verdict === "hold")) return notSendableReason(job, policy);
|
|
1767
|
+
return notEligibleReason(job, policy, category);
|
|
1768
|
+
}
|
|
1769
|
+
function asPercent(ratio) {
|
|
1770
|
+
return Math.round(ratio * 100);
|
|
1771
|
+
}
|
|
1420
1772
|
function correctionReason({ comparisons }) {
|
|
1421
1773
|
if (comparisons.length > 0) return null;
|
|
1422
1774
|
return "Aucune correction captur\xE9e : l'agent n'a pas r\xE9\xE9crit de r\xE9ponse sur ce ticket.";
|
|
@@ -1427,16 +1779,84 @@ function noResponseCause(decision) {
|
|
|
1427
1779
|
if (decision.status === "error") return decision.error ?? "Le triage a \xE9chou\xE9.";
|
|
1428
1780
|
return "La cat\xE9gorie n'a pas la r\xE9ponse rapide activ\xE9e, ou n'a pas d'agent r\xE9dacteur.";
|
|
1429
1781
|
}
|
|
1782
|
+
var AGENT_GUARDRAILS = [
|
|
1783
|
+
"whatsapp",
|
|
1784
|
+
"whatsapp_stop",
|
|
1785
|
+
"not_customer_turn",
|
|
1786
|
+
"judgeme",
|
|
1787
|
+
"noreply_sender",
|
|
1788
|
+
"triage_not_high",
|
|
1789
|
+
"escalated",
|
|
1790
|
+
"blocklist",
|
|
1791
|
+
"attachment",
|
|
1792
|
+
"short_answer",
|
|
1793
|
+
"uncertainty_marker",
|
|
1794
|
+
"evaluation_missing"
|
|
1795
|
+
];
|
|
1796
|
+
|
|
1797
|
+
// src/graph/run-ticket.ts
|
|
1798
|
+
function outcomeTags(outcome, verdict, audit) {
|
|
1799
|
+
if (outcome === "needs_human") return [audit.needsHumanTag];
|
|
1800
|
+
if (outcome === "guardrail_hold") return [audit.escalationTag];
|
|
1801
|
+
if (outcome !== "sent") return [];
|
|
1802
|
+
return requiresFollowup(verdict?.verdict ?? null) ? [audit.sentTag, audit.followupTag] : [audit.sentTag];
|
|
1803
|
+
}
|
|
1804
|
+
function hasNoDraftNode(profile) {
|
|
1805
|
+
return !profile.nodes.draft;
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
// src/ui/tickets/ticket-actions.ts
|
|
1809
|
+
function dedupe(names) {
|
|
1810
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1811
|
+
const out = [];
|
|
1812
|
+
for (const name of names) {
|
|
1813
|
+
const trimmed = (name ?? "").trim();
|
|
1814
|
+
if (!trimmed || seen.has(trimmed)) continue;
|
|
1815
|
+
seen.add(trimmed);
|
|
1816
|
+
out.push(trimmed);
|
|
1817
|
+
}
|
|
1818
|
+
return out;
|
|
1819
|
+
}
|
|
1820
|
+
function triageTagNames(input) {
|
|
1821
|
+
const { decision, category, policy } = input;
|
|
1822
|
+
return [decision.tag, ...category?.extraTags ?? [], policy?.audit.handledTag];
|
|
1823
|
+
}
|
|
1824
|
+
function wasSimulated(job, policy) {
|
|
1825
|
+
if (!job) return false;
|
|
1826
|
+
if (job.outcome === "sent" && job.status !== "sent") return true;
|
|
1827
|
+
return policy?.dryRun === true;
|
|
1828
|
+
}
|
|
1829
|
+
function ticketActions(input) {
|
|
1830
|
+
const { job, policy, notSentReason: notSentReason2 } = input;
|
|
1831
|
+
const simulated = wasSimulated(job, policy);
|
|
1832
|
+
const tags = dedupe([
|
|
1833
|
+
...triageTagNames(input),
|
|
1834
|
+
...policy ? outcomeTags(job?.outcome ?? null, job?.verdict ?? null, policy.audit) : []
|
|
1835
|
+
]);
|
|
1836
|
+
const taken = [];
|
|
1837
|
+
const skipped = [];
|
|
1838
|
+
if (job?.status === "sent") {
|
|
1839
|
+
taken.push("R\xE9ponse envoy\xE9e au client.");
|
|
1840
|
+
} else if (job) {
|
|
1841
|
+
skipped.push(`R\xE9ponse non envoy\xE9e \u2014 ${notSentReason2 ?? "raison inconnue."}`);
|
|
1842
|
+
}
|
|
1843
|
+
if (job?.outcome === "needs_human") taken.push("Alerte lev\xE9e dans la bo\xEEte de r\xE9ception.");
|
|
1844
|
+
if (job?.outcome === "awaiting_approval" && !simulated) taken.push("Demande d'approbation cr\xE9\xE9e.");
|
|
1845
|
+
return { tags, taken, skipped, simulated, unrecorded: job !== void 0 && job.outcome === null };
|
|
1846
|
+
}
|
|
1430
1847
|
function TimelinePanel(props) {
|
|
1431
|
-
const { decision, job, comparisons, conversation, conversationLoading, categoryName, onClose, onInvalidate, isInvalidating } = props;
|
|
1432
|
-
const steps = buildTimeline({ decision, job, comparisons, conversation, conversationLoading });
|
|
1848
|
+
const { decision, job, comparisons, conversation, conversationLoading, categoryName, policy, category, onClose, onInvalidate, isInvalidating } = props;
|
|
1849
|
+
const steps = buildTimeline({ decision, job, comparisons, conversation, conversationLoading, policy, category });
|
|
1850
|
+
const notSentReason2 = steps.find((step2) => step2.key === "delivery")?.reason ?? null;
|
|
1851
|
+
const actions = ticketActions({ decision, job, policy, category, notSentReason: notSentReason2 });
|
|
1433
1852
|
const canInvalidate = job !== void 0 && isGeneratedResponseStatus(job.status) && isInvalidatableStatus(job.status);
|
|
1434
1853
|
return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.SidePanel, { open: true, onClose, title: `Ticket ${decision.ticketId}`, description: categoryName, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-h-0 flex-1 space-y-1 overflow-y-auto text-sm", children: [
|
|
1435
1854
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-3 pb-3", children: [
|
|
1436
1855
|
/* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }),
|
|
1437
1856
|
onInvalidate && canInvalidate && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: onInvalidate, disabled: isInvalidating, children: isInvalidating ? "Invalidation\u2026" : "Invalider la r\xE9ponse" })
|
|
1438
1857
|
] }),
|
|
1439
|
-
steps.map((step2, index) => /* @__PURE__ */ jsxRuntime.jsx(StepBlock, { step: step2, index, last: index === steps.length - 1, children: step2.reached ? renderStep(step2.key, props) : null }, step2.key))
|
|
1858
|
+
steps.map((step2, index) => /* @__PURE__ */ jsxRuntime.jsx(StepBlock, { step: step2, index, last: index === steps.length - 1, children: step2.reached ? renderStep(step2.key, props) : null }, step2.key)),
|
|
1859
|
+
/* @__PURE__ */ jsxRuntime.jsx(ActionsBlock, { actions })
|
|
1440
1860
|
] }) });
|
|
1441
1861
|
}
|
|
1442
1862
|
function StepBlock({
|
|
@@ -1630,6 +2050,21 @@ function PromptAttribution({ name, version }) {
|
|
|
1630
2050
|
version !== null ? ` v${version}` : ""
|
|
1631
2051
|
] });
|
|
1632
2052
|
}
|
|
2053
|
+
function ActionsBlock({ actions }) {
|
|
2054
|
+
const { tags, taken, skipped, simulated, unrecorded } = actions;
|
|
2055
|
+
if (tags.length === 0 && taken.length === 0 && skipped.length === 0) return null;
|
|
2056
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-4 space-y-2 rounded-md border p-3", children: [
|
|
2057
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[10px] font-semibold uppercase tracking-wider text-muted-foreground", children: simulated ? "Actions simul\xE9es (mode essai)" : "Actions sur le ticket" }),
|
|
2058
|
+
simulated && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs italic text-muted-foreground", children: "Rien n\u2019a \xE9t\xE9 envoy\xE9 \xE0 Gorgias : en mode essai, le graphe tourne en entier mais n\u2019atteint aucune action externe." }),
|
|
2059
|
+
tags.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
2060
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: simulated ? "Tags qui auraient \xE9t\xE9 pos\xE9s :" : "Tags pos\xE9s :" }),
|
|
2061
|
+
tags.map((tag) => /* @__PURE__ */ jsxRuntime.jsx("code", { className: "rounded bg-muted px-1.5 py-0.5 text-xs", children: tag }, tag))
|
|
2062
|
+
] }),
|
|
2063
|
+
taken.map((action) => /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs", children: action }, action)),
|
|
2064
|
+
skipped.map((action) => /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-status-warning", children: action }, action)),
|
|
2065
|
+
unrecorded && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs italic text-muted-foreground", children: "La sortie de ce run n\u2019a pas \xE9t\xE9 enregistr\xE9e : les tags d\u2019issue ne peuvent pas \xEAtre list\xE9s avec certitude." })
|
|
2066
|
+
] });
|
|
2067
|
+
}
|
|
1633
2068
|
var DECISIONS_PAGE_SIZE = 50;
|
|
1634
2069
|
var JOIN_WINDOW_SIZE = 500;
|
|
1635
2070
|
var OUTCOME_BADGE_VARIANT = {
|
|
@@ -1673,6 +2108,7 @@ function TicketsPage() {
|
|
|
1673
2108
|
const api = uiSdk.useAppApi();
|
|
1674
2109
|
const toast = uiSdk.useToast();
|
|
1675
2110
|
const { settings } = uiSdk.useAppSettings();
|
|
2111
|
+
const deliveryPolicy = react.useMemo(() => toDeliveryPolicy(settings), [settings]);
|
|
1676
2112
|
const [period, setPeriod] = react.useState(() => defaultPeriod());
|
|
1677
2113
|
const [categoryFilter, setCategoryFilter] = react.useState("");
|
|
1678
2114
|
const [escalatedFilter, setEscalatedFilter] = react.useState("");
|
|
@@ -1909,203 +2345,100 @@ function TicketsPage() {
|
|
|
1909
2345
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.DateRangeCompare, { value: period, onChange: setPeriod, presets: DASHBOARD_PRESETS, align: "end" }),
|
|
1910
2346
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: () => void refreshAll(), children: "Actualiser" }),
|
|
1911
2347
|
canWrite && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => void runTriageNow(), disabled: isTriaging, children: isTriaging ? "Triage en cours\u2026" : "Lancer le triage maintenant" })
|
|
1912
|
-
] })
|
|
1913
|
-
}
|
|
1914
|
-
),
|
|
1915
|
-
joinWindowMayBeIncomplete && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
1916
|
-
"Les jointures ne lisent que les ",
|
|
1917
|
-
JOIN_WINDOW_SIZE,
|
|
1918
|
-
" derni\xE8res r\xE9ponses g\xE9n\xE9r\xE9es et corrections de la p\xE9riode \u2014 au-del\xE0, une r\xE9ponse ou une correction absente ici peut \xEAtre un simple effet de fen\xEAtre, pas un fait."
|
|
1919
|
-
] }),
|
|
1920
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
1921
|
-
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: categoryOptions, value: categoryFilter, onValueChange: setCategoryFilter, placeholder: "Toutes cat\xE9gories", "aria-label": "Filtrer par cat\xE9gorie" }),
|
|
1922
|
-
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: ESCALATED_OPTIONS, value: escalatedFilter, onValueChange: setEscalatedFilter, placeholder: "Toutes d\xE9cisions", "aria-label": "Filtrer par d\xE9cision" }),
|
|
1923
|
-
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: CONFIDENCE_OPTIONS, value: confidenceFilter, onValueChange: setConfidenceFilter, placeholder: "Toutes confiances", "aria-label": "Filtrer par confiance" }),
|
|
1924
|
-
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: OUTCOME_FILTER_OPTIONS, value: outcomeFilter, onValueChange: setOutcomeFilter, placeholder: "Tous les r\xE9sultats", "aria-label": "Filtrer par r\xE9sultat de r\xE9ponse" }),
|
|
1925
|
-
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: VERDICT_OPTIONS, value: verdictFilter, onValueChange: setVerdictFilter, placeholder: "Tous les verdicts", "aria-label": "Filtrer par verdict" }),
|
|
1926
|
-
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: promptVersionOptions, value: promptVersionFilter, onValueChange: setPromptVersionFilter, placeholder: "Toutes versions de prompt", "aria-label": "Filtrer par version de prompt" }),
|
|
1927
|
-
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: CORRECTED_OPTIONS, value: correctedFilter, onValueChange: setCorrectedFilter, placeholder: "Corrig\xE9s ou non", "aria-label": "Filtrer par correction humaine" }),
|
|
1928
|
-
rows.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-auto text-sm text-muted-foreground", children: [
|
|
1929
|
-
rows.length,
|
|
1930
|
-
" ticket",
|
|
1931
|
-
rows.length > 1 ? "s" : "",
|
|
1932
|
-
" sur cette page"
|
|
1933
|
-
] })
|
|
1934
|
-
] }),
|
|
1935
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1936
|
-
uiSdk.DataTable,
|
|
1937
|
-
{
|
|
1938
|
-
columns,
|
|
1939
|
-
rows,
|
|
1940
|
-
rowId: (row) => row.decision.id,
|
|
1941
|
-
manual: true,
|
|
1942
|
-
loading: isLoading,
|
|
1943
|
-
onRowClick: (row) => setDetailDecision(row.decision),
|
|
1944
|
-
pagination: {
|
|
1945
|
-
hasNext: hasNextPage,
|
|
1946
|
-
hasPrevious: hasPreviousPage,
|
|
1947
|
-
onNext: goToNextPage,
|
|
1948
|
-
onPrevious: goToPreviousPage
|
|
1949
|
-
},
|
|
1950
|
-
error: combinedError !== void 0 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-3", children: [
|
|
1951
|
-
"Erreur lors du chargement des tickets.",
|
|
1952
|
-
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: () => void refreshAll(), children: "R\xE9essayer" })
|
|
1953
|
-
] }) : void 0,
|
|
1954
|
-
empty: "Aucun ticket tri\xE9 sur cette p\xE9riode."
|
|
1955
|
-
}
|
|
1956
|
-
),
|
|
1957
|
-
detailDecision && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1958
|
-
TimelinePanel,
|
|
1959
|
-
{
|
|
1960
|
-
decision: detailDecision,
|
|
1961
|
-
job: detailRow?.job,
|
|
1962
|
-
comparisons: detailRow?.comparisons ?? [],
|
|
1963
|
-
conversation: resolveConversation({
|
|
1964
|
-
tracedInput: detailRow?.job?.tracedInput ?? [],
|
|
1965
|
-
comparisonMessages: detailRow?.comparisons[0]?.conversationMessages ?? [],
|
|
1966
|
-
liveMessages: liveConversation.messages
|
|
1967
|
-
}),
|
|
1968
|
-
conversationLoading: liveConversation.isLoading,
|
|
1969
|
-
categoryName: detailDecision.categoryId && categoryNames.get(detailDecision.categoryId) || "\u2014",
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
setState({ ticketId, messages: null, isLoading: true });
|
|
1993
|
-
api.invoke("get-ticket-conversation", { ticketId }).then((result) => {
|
|
1994
|
-
if (!cancelled) setState({ ticketId, messages: result.messages, isLoading: false });
|
|
1995
|
-
}).catch(() => {
|
|
1996
|
-
if (!cancelled) setState({ ticketId, messages: null, isLoading: false });
|
|
1997
|
-
});
|
|
1998
|
-
return () => {
|
|
1999
|
-
cancelled = true;
|
|
2000
|
-
};
|
|
2001
|
-
}, [api, ticketId]);
|
|
2002
|
-
return { messages: state.messages, isLoading: state.isLoading };
|
|
2003
|
-
}
|
|
2004
|
-
var AGENT_FIELD_NAME_UID = "e9cfec6f-15c6-4d02-8f79-0667f64b9eb5";
|
|
2005
|
-
var AGENT_FIELD_PROVIDER_UID = "e522b809-e8a7-4439-a2df-936158d04389";
|
|
2006
|
-
var AGENT_FIELD_MODEL_ID_UID = "d95977ba-362c-44d6-a2f0-24156c76cf8a";
|
|
2007
|
-
var AGENT_FIELD_STATUS_UID = "348725a0-a896-4f8d-8a56-86f4193234a8";
|
|
2008
|
-
var AGENT_FIELD_DEFAULT_KEY_UID = "0134491a-c969-4c42-894c-36ad4880fed3";
|
|
2009
|
-
var AGENT_FIELD_PROMPT_NAME_UID = "32e7f234-00bb-44d2-917b-be28f32f7214";
|
|
2010
|
-
var AGENT_FIELD_PROMPT_LABEL_UID = "bdee53ff-571a-4df6-91ec-00b513a70fe0";
|
|
2011
|
-
var AGENT_FIELD_PROMPT_VERSION_UID = "e7c66f99-e1e0-4fc2-9f9e-3bafe3af8e88";
|
|
2012
|
-
var AGENT_FIELD_SYSTEM_PROMPT_SNAPSHOT_UID = "710b73c6-929b-48b7-abc0-792849adf1c2";
|
|
2013
|
-
var AGENT_FIELD_REASONING_EFFORT_UID = "aa57fc6e-c989-47d3-9fc8-e04184b1e67c";
|
|
2014
|
-
var AGENT_FIELD_MAX_TOOL_CALLS_UID = "6948a5ca-48ef-45d7-9118-c7ab195343a3";
|
|
2015
|
-
|
|
2016
|
-
// src/records/agent.ts
|
|
2017
|
-
var AGENT_STATUSES = ["default", "available", "archived"];
|
|
2018
|
-
var REASONING_EFFORT_OPTIONS = ["off", "low", "medium", "high"];
|
|
2019
|
-
var DEFAULT_LLM_PROVIDER = "openai";
|
|
2020
|
-
({
|
|
2021
|
-
fields: [
|
|
2022
|
-
{
|
|
2023
|
-
universalIdentifier: AGENT_FIELD_NAME_UID,
|
|
2024
|
-
name: "name",
|
|
2025
|
-
type: appKit.FieldType.TEXT,
|
|
2026
|
-
label: "Name",
|
|
2027
|
-
isNullable: false
|
|
2028
|
-
},
|
|
2029
|
-
{
|
|
2030
|
-
universalIdentifier: AGENT_FIELD_PROVIDER_UID,
|
|
2031
|
-
name: "provider",
|
|
2032
|
-
type: appKit.FieldType.TEXT,
|
|
2033
|
-
label: "Provider",
|
|
2034
|
-
description: "Free text (spec \xA73.4) \u2014 a new provider must not need a kit release.",
|
|
2035
|
-
isNullable: false,
|
|
2036
|
-
defaultValue: DEFAULT_LLM_PROVIDER
|
|
2037
|
-
},
|
|
2038
|
-
{
|
|
2039
|
-
universalIdentifier: AGENT_FIELD_MODEL_ID_UID,
|
|
2040
|
-
name: "modelId",
|
|
2041
|
-
type: appKit.FieldType.TEXT,
|
|
2042
|
-
label: "Model id",
|
|
2043
|
-
isNullable: false
|
|
2044
|
-
},
|
|
2045
|
-
{
|
|
2046
|
-
universalIdentifier: AGENT_FIELD_STATUS_UID,
|
|
2047
|
-
name: "status",
|
|
2048
|
-
type: appKit.FieldType.SELECT,
|
|
2049
|
-
label: "Status",
|
|
2050
|
-
isNullable: false,
|
|
2051
|
-
options: [...AGENT_STATUSES],
|
|
2052
|
-
defaultValue: "available"
|
|
2053
|
-
},
|
|
2054
|
-
{
|
|
2055
|
-
universalIdentifier: AGENT_FIELD_DEFAULT_KEY_UID,
|
|
2056
|
-
name: "defaultKey",
|
|
2057
|
-
type: appKit.FieldType.TEXT,
|
|
2058
|
-
label: "Default key",
|
|
2059
|
-
description: "Equals 'default' when status='default', absent otherwise. Unique.",
|
|
2060
|
-
isNullable: true
|
|
2061
|
-
},
|
|
2062
|
-
{
|
|
2063
|
-
universalIdentifier: AGENT_FIELD_PROMPT_NAME_UID,
|
|
2064
|
-
name: "promptName",
|
|
2065
|
-
type: appKit.FieldType.TEXT,
|
|
2066
|
-
label: "Prompt name",
|
|
2067
|
-
description: "Free Langfuse prompt name (ETL keeps legacy agent/<old id> names).",
|
|
2068
|
-
isNullable: false
|
|
2069
|
-
},
|
|
2070
|
-
{
|
|
2071
|
-
universalIdentifier: AGENT_FIELD_PROMPT_LABEL_UID,
|
|
2072
|
-
name: "promptLabel",
|
|
2073
|
-
type: appKit.FieldType.TEXT,
|
|
2074
|
-
label: "Prompt label",
|
|
2075
|
-
isNullable: true
|
|
2076
|
-
},
|
|
2077
|
-
{
|
|
2078
|
-
universalIdentifier: AGENT_FIELD_PROMPT_VERSION_UID,
|
|
2079
|
-
name: "promptVersion",
|
|
2080
|
-
type: appKit.FieldType.NUMBER,
|
|
2081
|
-
label: "Prompt version",
|
|
2082
|
-
description: 'Pinning; absent means "follow the label".',
|
|
2083
|
-
isNullable: true
|
|
2084
|
-
},
|
|
2085
|
-
{
|
|
2086
|
-
universalIdentifier: AGENT_FIELD_SYSTEM_PROMPT_SNAPSHOT_UID,
|
|
2087
|
-
name: "systemPromptSnapshot",
|
|
2088
|
-
type: appKit.FieldType.TEXT,
|
|
2089
|
-
label: "System prompt snapshot",
|
|
2090
|
-
description: "Level-3 fallback of the prompt ladder (\xA73.7).",
|
|
2091
|
-
isNullable: true
|
|
2092
|
-
},
|
|
2093
|
-
{
|
|
2094
|
-
universalIdentifier: AGENT_FIELD_REASONING_EFFORT_UID,
|
|
2095
|
-
name: "reasoningEffort",
|
|
2096
|
-
type: appKit.FieldType.SELECT,
|
|
2097
|
-
label: "Reasoning effort",
|
|
2098
|
-
isNullable: true,
|
|
2099
|
-
options: [...REASONING_EFFORT_OPTIONS]
|
|
2100
|
-
},
|
|
2101
|
-
{
|
|
2102
|
-
universalIdentifier: AGENT_FIELD_MAX_TOOL_CALLS_UID,
|
|
2103
|
-
name: "maxToolCalls",
|
|
2104
|
-
type: appKit.FieldType.NUMBER,
|
|
2105
|
-
label: "Max tool calls",
|
|
2106
|
-
isNullable: true
|
|
2348
|
+
] })
|
|
2349
|
+
}
|
|
2350
|
+
),
|
|
2351
|
+
joinWindowMayBeIncomplete && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
2352
|
+
"Les jointures ne lisent que les ",
|
|
2353
|
+
JOIN_WINDOW_SIZE,
|
|
2354
|
+
" derni\xE8res r\xE9ponses g\xE9n\xE9r\xE9es et corrections de la p\xE9riode \u2014 au-del\xE0, une r\xE9ponse ou une correction absente ici peut \xEAtre un simple effet de fen\xEAtre, pas un fait."
|
|
2355
|
+
] }),
|
|
2356
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
2357
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: categoryOptions, value: categoryFilter, onValueChange: setCategoryFilter, placeholder: "Toutes cat\xE9gories", "aria-label": "Filtrer par cat\xE9gorie" }),
|
|
2358
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: ESCALATED_OPTIONS, value: escalatedFilter, onValueChange: setEscalatedFilter, placeholder: "Toutes d\xE9cisions", "aria-label": "Filtrer par d\xE9cision" }),
|
|
2359
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: CONFIDENCE_OPTIONS, value: confidenceFilter, onValueChange: setConfidenceFilter, placeholder: "Toutes confiances", "aria-label": "Filtrer par confiance" }),
|
|
2360
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: OUTCOME_FILTER_OPTIONS, value: outcomeFilter, onValueChange: setOutcomeFilter, placeholder: "Tous les r\xE9sultats", "aria-label": "Filtrer par r\xE9sultat de r\xE9ponse" }),
|
|
2361
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: VERDICT_OPTIONS, value: verdictFilter, onValueChange: setVerdictFilter, placeholder: "Tous les verdicts", "aria-label": "Filtrer par verdict" }),
|
|
2362
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: promptVersionOptions, value: promptVersionFilter, onValueChange: setPromptVersionFilter, placeholder: "Toutes versions de prompt", "aria-label": "Filtrer par version de prompt" }),
|
|
2363
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: CORRECTED_OPTIONS, value: correctedFilter, onValueChange: setCorrectedFilter, placeholder: "Corrig\xE9s ou non", "aria-label": "Filtrer par correction humaine" }),
|
|
2364
|
+
rows.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-auto text-sm text-muted-foreground", children: [
|
|
2365
|
+
rows.length,
|
|
2366
|
+
" ticket",
|
|
2367
|
+
rows.length > 1 ? "s" : "",
|
|
2368
|
+
" sur cette page"
|
|
2369
|
+
] })
|
|
2370
|
+
] }),
|
|
2371
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2372
|
+
uiSdk.DataTable,
|
|
2373
|
+
{
|
|
2374
|
+
columns,
|
|
2375
|
+
rows,
|
|
2376
|
+
rowId: (row) => row.decision.id,
|
|
2377
|
+
manual: true,
|
|
2378
|
+
loading: isLoading,
|
|
2379
|
+
onRowClick: (row) => setDetailDecision(row.decision),
|
|
2380
|
+
pagination: {
|
|
2381
|
+
hasNext: hasNextPage,
|
|
2382
|
+
hasPrevious: hasPreviousPage,
|
|
2383
|
+
onNext: goToNextPage,
|
|
2384
|
+
onPrevious: goToPreviousPage
|
|
2385
|
+
},
|
|
2386
|
+
error: combinedError !== void 0 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-3", children: [
|
|
2387
|
+
"Erreur lors du chargement des tickets.",
|
|
2388
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: () => void refreshAll(), children: "R\xE9essayer" })
|
|
2389
|
+
] }) : void 0,
|
|
2390
|
+
empty: "Aucun ticket tri\xE9 sur cette p\xE9riode."
|
|
2391
|
+
}
|
|
2392
|
+
),
|
|
2393
|
+
detailDecision && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2394
|
+
TimelinePanel,
|
|
2395
|
+
{
|
|
2396
|
+
decision: detailDecision,
|
|
2397
|
+
job: detailRow?.job,
|
|
2398
|
+
comparisons: detailRow?.comparisons ?? [],
|
|
2399
|
+
conversation: resolveConversation({
|
|
2400
|
+
tracedInput: detailRow?.job?.tracedInput ?? [],
|
|
2401
|
+
comparisonMessages: detailRow?.comparisons[0]?.conversationMessages ?? [],
|
|
2402
|
+
liveMessages: liveConversation.messages
|
|
2403
|
+
}),
|
|
2404
|
+
conversationLoading: liveConversation.isLoading,
|
|
2405
|
+
categoryName: detailDecision.categoryId && categoryNames.get(detailDecision.categoryId) || "\u2014",
|
|
2406
|
+
policy: deliveryPolicy,
|
|
2407
|
+
category: categories.find((entry) => entry.id === detailDecision.categoryId) ?? null,
|
|
2408
|
+
agentName: detailRow?.job?.agentId && agentNames.get(detailRow.job.agentId) || "\u2014",
|
|
2409
|
+
langfuseConfig,
|
|
2410
|
+
onClose: () => setDetailDecision(null),
|
|
2411
|
+
onInvalidate: canWrite && detailRow?.job ? () => void invalidateResponse(detailRow.job.id) : void 0,
|
|
2412
|
+
isInvalidating
|
|
2413
|
+
}
|
|
2414
|
+
)
|
|
2415
|
+
] });
|
|
2416
|
+
}
|
|
2417
|
+
function useLiveConversation(decision, row) {
|
|
2418
|
+
const api = uiSdk.useAppApi();
|
|
2419
|
+
const [state, setState] = react.useState(
|
|
2420
|
+
{ ticketId: null, messages: null, isLoading: false }
|
|
2421
|
+
);
|
|
2422
|
+
const hasPersisted = (row?.job?.tracedInput.length ?? 0) > 0 || (row?.comparisons[0]?.conversationMessages.length ?? 0) > 0;
|
|
2423
|
+
const ticketId = decision && !hasPersisted ? decision.ticketId : null;
|
|
2424
|
+
react.useEffect(() => {
|
|
2425
|
+
if (!ticketId) {
|
|
2426
|
+
setState({ ticketId: null, messages: null, isLoading: false });
|
|
2427
|
+
return;
|
|
2107
2428
|
}
|
|
2108
|
-
|
|
2429
|
+
let cancelled = false;
|
|
2430
|
+
setState({ ticketId, messages: null, isLoading: true });
|
|
2431
|
+
api.invoke("get-ticket-conversation", { ticketId }).then((result) => {
|
|
2432
|
+
if (!cancelled) setState({ ticketId, messages: result.messages, isLoading: false });
|
|
2433
|
+
}).catch(() => {
|
|
2434
|
+
if (!cancelled) setState({ ticketId, messages: null, isLoading: false });
|
|
2435
|
+
});
|
|
2436
|
+
return () => {
|
|
2437
|
+
cancelled = true;
|
|
2438
|
+
};
|
|
2439
|
+
}, [api, ticketId]);
|
|
2440
|
+
return { messages: state.messages, isLoading: state.isLoading };
|
|
2441
|
+
}
|
|
2109
2442
|
|
|
2110
2443
|
// src/ui/settings/pipeline-nodes.ts
|
|
2111
2444
|
var PIPELINE_STEP_KEYS = ["triage", "escalate", "draft", "evaluate", "revise"];
|
|
@@ -3656,24 +3989,6 @@ function CategoriesPage() {
|
|
|
3656
3989
|
)
|
|
3657
3990
|
] });
|
|
3658
3991
|
}
|
|
3659
|
-
var AGENT_GUARDRAILS = [
|
|
3660
|
-
"whatsapp",
|
|
3661
|
-
"whatsapp_stop",
|
|
3662
|
-
"not_customer_turn",
|
|
3663
|
-
"judgeme",
|
|
3664
|
-
"noreply_sender",
|
|
3665
|
-
"triage_not_high",
|
|
3666
|
-
"escalated",
|
|
3667
|
-
"blocklist",
|
|
3668
|
-
"attachment",
|
|
3669
|
-
"short_answer",
|
|
3670
|
-
"uncertainty_marker",
|
|
3671
|
-
"evaluation_missing"
|
|
3672
|
-
];
|
|
3673
|
-
|
|
3674
|
-
// src/domain/profile.ts
|
|
3675
|
-
var DEFAULT_PROFILE_KEY = "customer";
|
|
3676
|
-
var WHATSAPP_MODES = ["escalate_only", "draft_only", "auto_reply"];
|
|
3677
3992
|
|
|
3678
3993
|
// src/settings/validate.ts
|
|
3679
3994
|
function validateSettings(settings) {
|
|
@@ -3729,111 +4044,6 @@ function isConfiguredNode(nodes) {
|
|
|
3729
4044
|
const triage = nodes.triage;
|
|
3730
4045
|
return typeof triage === "object" && triage !== null;
|
|
3731
4046
|
}
|
|
3732
|
-
|
|
3733
|
-
// src/settings/to-profile.ts
|
|
3734
|
-
var DEFAULT_REASONING = "off";
|
|
3735
|
-
var DEFAULT_MAX_TOOL_CALLS = 5;
|
|
3736
|
-
var DEFAULT_MIN_CONFIDENCE = 0.8;
|
|
3737
|
-
var DEFAULT_ESCALATION_ENABLED = false;
|
|
3738
|
-
var JUDGEME_ESCALATE_ONLY = true;
|
|
3739
|
-
var TRIAGE_CONCURRENCY = 1;
|
|
3740
|
-
var FAST_RESPONSE_CONCURRENCY = 3;
|
|
3741
|
-
var FAST_RESPONSE_INTERVAL_SECONDS = 0;
|
|
3742
|
-
var FAST_RESPONSE_BATCH_LIMIT = 1;
|
|
3743
|
-
function settingsToProfile(settings, prompts) {
|
|
3744
|
-
const evaluate = toEvaluateNode(settings.nodes.evaluate);
|
|
3745
|
-
return {
|
|
3746
|
-
key: DEFAULT_PROFILE_KEY,
|
|
3747
|
-
// One app installs one kit, so its profile is that app's only tenant —
|
|
3748
|
-
// the multi-tenant `key` of the legacy is now the app boundary itself.
|
|
3749
|
-
isDefault: true,
|
|
3750
|
-
enabled: settings.triageEnabled,
|
|
3751
|
-
source: { channel: "gorgias", viewOrTag: settings.sourceViewId },
|
|
3752
|
-
schedule: {
|
|
3753
|
-
triageIntervalMinutes: settings.triageIntervalMinutes,
|
|
3754
|
-
triageBatchLimit: settings.batchLimit,
|
|
3755
|
-
triageConcurrency: TRIAGE_CONCURRENCY,
|
|
3756
|
-
fastResponseIntervalSeconds: FAST_RESPONSE_INTERVAL_SECONDS,
|
|
3757
|
-
fastResponseBatchLimit: FAST_RESPONSE_BATCH_LIMIT,
|
|
3758
|
-
fastResponseConcurrency: FAST_RESPONSE_CONCURRENCY,
|
|
3759
|
-
fastResponseTtlMinutes: settings.responseTtlMinutes
|
|
3760
|
-
},
|
|
3761
|
-
nodes: {
|
|
3762
|
-
triage: baseNode(settings.nodes.triage),
|
|
3763
|
-
escalate: settings.nodes.escalate ? baseNode(settings.nodes.escalate) : null,
|
|
3764
|
-
draft: settings.nodes.draft ? {
|
|
3765
|
-
...baseNode(settings.nodes.draft),
|
|
3766
|
-
maxToolCalls: settings.nodes.draft.maxToolCalls ?? DEFAULT_MAX_TOOL_CALLS
|
|
3767
|
-
} : null,
|
|
3768
|
-
evaluate,
|
|
3769
|
-
revise: settings.nodes.revise ? baseNode(settings.nodes.revise) : null
|
|
3770
|
-
},
|
|
3771
|
-
prompts,
|
|
3772
|
-
// No settings surface for the §6.2 tool allowlist yet (the registry
|
|
3773
|
-
// already refuses every write tool on its own). Default-deny until
|
|
3774
|
-
// T22 has a real list to pass; an empty list only costs the `draft`
|
|
3775
|
-
// node its optional lookups, it never opens anything.
|
|
3776
|
-
tools: [],
|
|
3777
|
-
guardrails: {
|
|
3778
|
-
active: [...settings.guardrailsActive],
|
|
3779
|
-
params: {
|
|
3780
|
-
noreplySenders: [...settings.noreplySenders],
|
|
3781
|
-
blocklist: [...settings.blocklist],
|
|
3782
|
-
whatsappMode: settings.whatsappMode,
|
|
3783
|
-
judgemeEscalateOnly: JUDGEME_ESCALATE_ONLY,
|
|
3784
|
-
channelPromptEmail: settings.channelPromptEmail,
|
|
3785
|
-
channelPromptWhatsapp: settings.channelPromptWhatsapp
|
|
3786
|
-
}
|
|
3787
|
-
},
|
|
3788
|
-
// `authorize` is DEFAULT DENY on an absent kind, so the one action kind
|
|
3789
|
-
// that exists must be stated: auto-send on ⇒ the graph may send, off ⇒
|
|
3790
|
-
// a human approves. Nothing here can reach 'forbidden' — that decision
|
|
3791
|
-
// belongs to P3's per-role policy, which needs a runtime context this
|
|
3792
|
-
// pure mapper does not have.
|
|
3793
|
-
authorization: { send_reply: settings.autoSendEnabled ? "auto" : "needs_approval" },
|
|
3794
|
-
audit: {
|
|
3795
|
-
unknownTag: settings.unknownTag,
|
|
3796
|
-
handledTag: settings.handledTag,
|
|
3797
|
-
escalationTag: settings.escalationTag,
|
|
3798
|
-
sentTag: settings.autoRepliedTag,
|
|
3799
|
-
needsHumanTag: settings.needsReviewTag,
|
|
3800
|
-
followupTag: settings.followupTag
|
|
3801
|
-
},
|
|
3802
|
-
autoSend: {
|
|
3803
|
-
enabled: settings.autoSendEnabled,
|
|
3804
|
-
senderEmail: settings.senderEmail === "" ? null : settings.senderEmail,
|
|
3805
|
-
// The auto-send floor is the evaluation floor: a second, independent
|
|
3806
|
-
// threshold would be a silent way to send below the one an operator set.
|
|
3807
|
-
minConfidence: evaluate?.minConfidence ?? DEFAULT_MIN_CONFIDENCE,
|
|
3808
|
-
requireHighTriage: settings.requireHighTriageConfidence
|
|
3809
|
-
},
|
|
3810
|
-
rename: settings.renameEnabled ? { enabled: true, from: settings.renameFrom, to: settings.renameTo } : null,
|
|
3811
|
-
// Locks and run stamps are per-run state: they live in the
|
|
3812
|
-
// `pipeline-state` record (§3.4), never in settings.
|
|
3813
|
-
runtime: {
|
|
3814
|
-
triageLock: { acquiredAt: null, owner: null },
|
|
3815
|
-
fastResponseLock: { acquiredAt: null, owner: null },
|
|
3816
|
-
triageLastRun: { startedAt: null, completedAt: null, status: null },
|
|
3817
|
-
fastResponseLastRun: { startedAt: null, completedAt: null, status: null },
|
|
3818
|
-
lastAutoSendDecisionAt: null
|
|
3819
|
-
}
|
|
3820
|
-
};
|
|
3821
|
-
}
|
|
3822
|
-
function baseNode(node) {
|
|
3823
|
-
return {
|
|
3824
|
-
model: node.model,
|
|
3825
|
-
provider: node.provider ?? DEFAULT_LLM_PROVIDER,
|
|
3826
|
-
reasoning: node.reasoning ?? DEFAULT_REASONING
|
|
3827
|
-
};
|
|
3828
|
-
}
|
|
3829
|
-
function toEvaluateNode(node) {
|
|
3830
|
-
if (!node) return null;
|
|
3831
|
-
return {
|
|
3832
|
-
...baseNode(node),
|
|
3833
|
-
minConfidence: node.minConfidence ?? DEFAULT_MIN_CONFIDENCE,
|
|
3834
|
-
escalationEnabled: node.escalationEnabled ?? DEFAULT_ESCALATION_ENABLED
|
|
3835
|
-
};
|
|
3836
|
-
}
|
|
3837
4047
|
function NumberField({ id, label, value, onChange, disabled, min, max, integer, hint }) {
|
|
3838
4048
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
3839
4049
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: "mb-1 block text-sm font-medium", children: label }),
|
|
@@ -4104,18 +4314,14 @@ function StepOptions({
|
|
|
4104
4314
|
hint: "En dessous de ce seuil, la r\xE9ponse n'est jamais envoy\xE9e automatiquement."
|
|
4105
4315
|
}
|
|
4106
4316
|
),
|
|
4107
|
-
/* @__PURE__ */ jsxRuntime.
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
}
|
|
4116
|
-
),
|
|
4117
|
-
"Autoriser l'escalade \u2014 une \xE9valuation insuffisante est transmise \xE0 un humain"
|
|
4118
|
-
] })
|
|
4317
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4318
|
+
FollowupSendSwitch,
|
|
4319
|
+
{
|
|
4320
|
+
enabled: stepBoolean(settings, "escalationEnabled", DEFAULT_ESCALATION_ENABLED),
|
|
4321
|
+
onChange: (next) => onPatch({ escalationEnabled: next }),
|
|
4322
|
+
disabled
|
|
4323
|
+
}
|
|
4324
|
+
)
|
|
4119
4325
|
] })
|
|
4120
4326
|
] });
|
|
4121
4327
|
}
|
|
@@ -4187,6 +4393,27 @@ function useIds(stepKey) {
|
|
|
4187
4393
|
minConfidence: `${base2}-${stepKey}-min-confidence`
|
|
4188
4394
|
};
|
|
4189
4395
|
}
|
|
4396
|
+
function FollowupSendSwitch({
|
|
4397
|
+
enabled,
|
|
4398
|
+
onChange,
|
|
4399
|
+
disabled
|
|
4400
|
+
}) {
|
|
4401
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 text-sm sm:col-span-2", children: [
|
|
4402
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4403
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4404
|
+
uiSdk.Switch,
|
|
4405
|
+
{
|
|
4406
|
+
"aria-label": "Envoyer les r\xE9ponses qui demandent un suivi humain",
|
|
4407
|
+
checked: enabled,
|
|
4408
|
+
onCheckedChange: onChange,
|
|
4409
|
+
disabled
|
|
4410
|
+
}
|
|
4411
|
+
),
|
|
4412
|
+
"Envoyer les r\xE9ponses qui demandent un suivi humain"
|
|
4413
|
+
] }),
|
|
4414
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: enabled ? "Un verdict \xAB Envoyer et escalader \xBB part au client, et le ticket est tagu\xE9 pour qu\u2019un humain assure le suivi." : "Un verdict \xAB Envoyer et escalader \xBB n\u2019est jamais envoy\xE9 : la r\xE9ponse reste en attente et le ticket part en revue humaine." })
|
|
4415
|
+
] });
|
|
4416
|
+
}
|
|
4190
4417
|
function normalize(text) {
|
|
4191
4418
|
return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
4192
4419
|
}
|
|
@@ -4740,24 +4967,6 @@ function useQueryParam(name) {
|
|
|
4740
4967
|
return { value, setValue };
|
|
4741
4968
|
}
|
|
4742
4969
|
|
|
4743
|
-
// src/graph/state.ts
|
|
4744
|
-
var NODE_NAMES = [
|
|
4745
|
-
"fetchContext",
|
|
4746
|
-
"triage",
|
|
4747
|
-
"escalate",
|
|
4748
|
-
"draft",
|
|
4749
|
-
"evaluate",
|
|
4750
|
-
"revise",
|
|
4751
|
-
"guardrails",
|
|
4752
|
-
"authorize",
|
|
4753
|
-
"act"
|
|
4754
|
-
];
|
|
4755
|
-
|
|
4756
|
-
// src/graph/run-ticket.ts
|
|
4757
|
-
function hasNoDraftNode(profile) {
|
|
4758
|
-
return !profile.nodes.draft;
|
|
4759
|
-
}
|
|
4760
|
-
|
|
4761
4970
|
// src/ui/graph-canvas/reachability.ts
|
|
4762
4971
|
var EXIT_TONES = {
|
|
4763
4972
|
sent: "delivered",
|
|
@@ -4833,7 +5042,7 @@ var NODE_EXITS = {
|
|
|
4833
5042
|
evaluate: [
|
|
4834
5043
|
{
|
|
4835
5044
|
key: "evaluate-needs-human",
|
|
4836
|
-
condition: "verdict non envoyable
|
|
5045
|
+
condition: "verdict non envoyable ou confiance sous le seuil",
|
|
4837
5046
|
outcome: "needs_human"
|
|
4838
5047
|
},
|
|
4839
5048
|
READY_EXIT
|
|
@@ -4854,12 +5063,24 @@ var NODE_EXITS = {
|
|
|
4854
5063
|
{ key: "act-sent-whatsapp", condition: "note WhatsApp", outcome: "sent" }
|
|
4855
5064
|
]
|
|
4856
5065
|
};
|
|
4857
|
-
|
|
5066
|
+
var FOLLOWUP_BLOCKED_EXIT = {
|
|
5067
|
+
key: "evaluate-followup-blocked",
|
|
5068
|
+
condition: "verdict \xAB Envoyer et escalader \xBB, envoi des r\xE9ponses \xE0 suivre d\xE9sactiv\xE9",
|
|
5069
|
+
outcome: "needs_human"
|
|
5070
|
+
};
|
|
5071
|
+
function exitsFor(node, config) {
|
|
4858
5072
|
const raw = NODE_EXITS[node] ?? [];
|
|
4859
5073
|
const withTone = (exits) => exits.map((exit) => ({ ...exit, tone: EXIT_TONES[exit.outcome] }));
|
|
4860
|
-
if (
|
|
4861
|
-
|
|
4862
|
-
|
|
5074
|
+
if (!config.configured) {
|
|
5075
|
+
if (node === "evaluate") return [];
|
|
5076
|
+
if (node === "draft") return withTone([READY_EXIT]);
|
|
5077
|
+
return withTone(raw);
|
|
5078
|
+
}
|
|
5079
|
+
if (node === "evaluate" && !config.followupSendable) {
|
|
5080
|
+
return withTone(
|
|
5081
|
+
raw.flatMap((exit) => exit.key === "evaluate-needs-human" ? [exit, FOLLOWUP_BLOCKED_EXIT] : [exit])
|
|
5082
|
+
);
|
|
5083
|
+
}
|
|
4863
5084
|
return withTone(raw);
|
|
4864
5085
|
}
|
|
4865
5086
|
function deriveCause(state, reasons) {
|
|
@@ -4898,6 +5119,10 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
4898
5119
|
const settings = rawSettings;
|
|
4899
5120
|
const profile = settingsToProfile(settings, stubPrompts());
|
|
4900
5121
|
const evaluateConfigured = profile.nodes.evaluate !== null;
|
|
5122
|
+
const evaluateConfig = {
|
|
5123
|
+
configured: evaluateConfigured,
|
|
5124
|
+
followupSendable: profile.nodes.evaluate?.escalationEnabled ?? false
|
|
5125
|
+
};
|
|
4901
5126
|
const byNode = /* @__PURE__ */ new Map();
|
|
4902
5127
|
function set(node, state, reasons, notes = []) {
|
|
4903
5128
|
byNode.set(node, {
|
|
@@ -4907,7 +5132,7 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
4907
5132
|
reasons,
|
|
4908
5133
|
notes,
|
|
4909
5134
|
model: nodeModelOf(node, profile),
|
|
4910
|
-
exits: exitsFor(node,
|
|
5135
|
+
exits: exitsFor(node, evaluateConfig),
|
|
4911
5136
|
promptWarning: state === "on" && PROMPT_403_NODES.has(node)
|
|
4912
5137
|
});
|
|
4913
5138
|
}
|
|
@@ -5005,6 +5230,12 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
5005
5230
|
"\xC9tape coup\xE9e dans les r\xE9glages \u2014 aucun verdict, la r\xE9ponse reste \xAB Disponible \xBB.",
|
|
5006
5231
|
"nodes.evaluate est \xE0 null \u2014 la r\xE9ponse conserve l'issue \xAB ready \xBB."
|
|
5007
5232
|
);
|
|
5233
|
+
const followupNote = evaluateConfigured && !evaluateConfig.followupSendable ? [
|
|
5234
|
+
{
|
|
5235
|
+
message: "Les r\xE9ponses jug\xE9es \xAB Envoyer et escalader \xBB ne sont jamais envoy\xE9es : elles sortent en revue humaine, m\xEAme approuv\xE9es par le juge.",
|
|
5236
|
+
detail: "nodes.evaluate.escalationEnabled est \xE0 false \u2014 isSendable refuse tout verdict dont requiresFollowup est vrai (verdict/policy.ts)."
|
|
5237
|
+
}
|
|
5238
|
+
] : [];
|
|
5008
5239
|
set(
|
|
5009
5240
|
"evaluate",
|
|
5010
5241
|
deriveState(draftRuns, [], evaluateDisabled ? [evaluateOff] : []),
|
|
@@ -5018,7 +5249,8 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
5018
5249
|
"La r\xE9daction n'est jamais atteinte.",
|
|
5019
5250
|
"draft est inatteignable."
|
|
5020
5251
|
)
|
|
5021
|
-
]
|
|
5252
|
+
],
|
|
5253
|
+
followupNote
|
|
5022
5254
|
);
|
|
5023
5255
|
const evaluateRuns = passesControlOn("evaluate");
|
|
5024
5256
|
const reviseDisabled = profile.nodes.revise === null;
|