@apotech-os/support-kit 10.4.0 → 10.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui/index.cjs CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  var react = require('react');
4
4
  var uiSdk = require('@apotech-os/ui-sdk');
5
- var jsxRuntime = require('react/jsx-runtime');
6
5
  var appKit = require('@apotech-os/app-kit');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
7
 
8
8
  // src/ui/dashboard/dashboard-page.tsx
9
9
 
@@ -41,6 +41,111 @@ var NODE_NAMES = [
41
41
  "authorize",
42
42
  "act"
43
43
  ];
44
+ var AGENT_FIELD_NAME_UID = "e9cfec6f-15c6-4d02-8f79-0667f64b9eb5";
45
+ var AGENT_FIELD_PROVIDER_UID = "e522b809-e8a7-4439-a2df-936158d04389";
46
+ var AGENT_FIELD_MODEL_ID_UID = "d95977ba-362c-44d6-a2f0-24156c76cf8a";
47
+ var AGENT_FIELD_STATUS_UID = "348725a0-a896-4f8d-8a56-86f4193234a8";
48
+ var AGENT_FIELD_DEFAULT_KEY_UID = "0134491a-c969-4c42-894c-36ad4880fed3";
49
+ var AGENT_FIELD_PROMPT_NAME_UID = "32e7f234-00bb-44d2-917b-be28f32f7214";
50
+ var AGENT_FIELD_PROMPT_LABEL_UID = "bdee53ff-571a-4df6-91ec-00b513a70fe0";
51
+ var AGENT_FIELD_PROMPT_VERSION_UID = "e7c66f99-e1e0-4fc2-9f9e-3bafe3af8e88";
52
+ var AGENT_FIELD_SYSTEM_PROMPT_SNAPSHOT_UID = "710b73c6-929b-48b7-abc0-792849adf1c2";
53
+ var AGENT_FIELD_REASONING_EFFORT_UID = "aa57fc6e-c989-47d3-9fc8-e04184b1e67c";
54
+ var AGENT_FIELD_MAX_TOOL_CALLS_UID = "6948a5ca-48ef-45d7-9118-c7ab195343a3";
55
+
56
+ // src/records/agent.ts
57
+ var AGENT_STATUSES = ["default", "available", "archived"];
58
+ var REASONING_EFFORT_OPTIONS = ["off", "low", "medium", "high"];
59
+ var DEFAULT_LLM_PROVIDER = "openai";
60
+ ({
61
+ fields: [
62
+ {
63
+ universalIdentifier: AGENT_FIELD_NAME_UID,
64
+ name: "name",
65
+ type: appKit.FieldType.TEXT,
66
+ label: "Name",
67
+ isNullable: false
68
+ },
69
+ {
70
+ universalIdentifier: AGENT_FIELD_PROVIDER_UID,
71
+ name: "provider",
72
+ type: appKit.FieldType.TEXT,
73
+ label: "Provider",
74
+ description: "Free text (spec \xA73.4) \u2014 a new provider must not need a kit release.",
75
+ isNullable: false,
76
+ defaultValue: DEFAULT_LLM_PROVIDER
77
+ },
78
+ {
79
+ universalIdentifier: AGENT_FIELD_MODEL_ID_UID,
80
+ name: "modelId",
81
+ type: appKit.FieldType.TEXT,
82
+ label: "Model id",
83
+ isNullable: false
84
+ },
85
+ {
86
+ universalIdentifier: AGENT_FIELD_STATUS_UID,
87
+ name: "status",
88
+ type: appKit.FieldType.SELECT,
89
+ label: "Status",
90
+ isNullable: false,
91
+ options: [...AGENT_STATUSES],
92
+ defaultValue: "available"
93
+ },
94
+ {
95
+ universalIdentifier: AGENT_FIELD_DEFAULT_KEY_UID,
96
+ name: "defaultKey",
97
+ type: appKit.FieldType.TEXT,
98
+ label: "Default key",
99
+ description: "Equals 'default' when status='default', absent otherwise. Unique.",
100
+ isNullable: true
101
+ },
102
+ {
103
+ universalIdentifier: AGENT_FIELD_PROMPT_NAME_UID,
104
+ name: "promptName",
105
+ type: appKit.FieldType.TEXT,
106
+ label: "Prompt name",
107
+ description: "Free Langfuse prompt name (ETL keeps legacy agent/<old id> names).",
108
+ isNullable: false
109
+ },
110
+ {
111
+ universalIdentifier: AGENT_FIELD_PROMPT_LABEL_UID,
112
+ name: "promptLabel",
113
+ type: appKit.FieldType.TEXT,
114
+ label: "Prompt label",
115
+ isNullable: true
116
+ },
117
+ {
118
+ universalIdentifier: AGENT_FIELD_PROMPT_VERSION_UID,
119
+ name: "promptVersion",
120
+ type: appKit.FieldType.NUMBER,
121
+ label: "Prompt version",
122
+ description: 'Pinning; absent means "follow the label".',
123
+ isNullable: true
124
+ },
125
+ {
126
+ universalIdentifier: AGENT_FIELD_SYSTEM_PROMPT_SNAPSHOT_UID,
127
+ name: "systemPromptSnapshot",
128
+ type: appKit.FieldType.TEXT,
129
+ label: "System prompt snapshot",
130
+ description: "Level-3 fallback of the prompt ladder (\xA73.7).",
131
+ isNullable: true
132
+ },
133
+ {
134
+ universalIdentifier: AGENT_FIELD_REASONING_EFFORT_UID,
135
+ name: "reasoningEffort",
136
+ type: appKit.FieldType.SELECT,
137
+ label: "Reasoning effort",
138
+ isNullable: true,
139
+ options: [...REASONING_EFFORT_OPTIONS]
140
+ },
141
+ {
142
+ universalIdentifier: AGENT_FIELD_MAX_TOOL_CALLS_UID,
143
+ name: "maxToolCalls",
144
+ type: appKit.FieldType.NUMBER,
145
+ label: "Max tool calls",
146
+ isNullable: true
147
+ }
148
+ ]});
44
149
 
45
150
  // src/domain/evaluation-verdict.ts
46
151
  var EVALUATION_VERDICTS = ["send", "send_and_escalate", "hold"];
@@ -65,6 +170,13 @@ function toDecisionOrigin(value) {
65
170
  }
66
171
 
67
172
  // src/functions/records.ts
173
+ var REASONING_EFFORTS = ["off", "low", "medium", "high"];
174
+ function isReasoningEffort(value) {
175
+ return REASONING_EFFORTS.includes(value);
176
+ }
177
+ function toReasoningEffort(value) {
178
+ return isReasoningEffort(value) ? value : null;
179
+ }
68
180
  function toAgent(record) {
69
181
  const data = record.data;
70
182
  return {
@@ -76,7 +188,8 @@ function toAgent(record) {
76
188
  promptName: data.promptName ?? "",
77
189
  promptLabel: data.promptLabel ?? null,
78
190
  promptVersion: data.promptVersion ?? null,
79
- systemPromptSnapshot: data.systemPromptSnapshot ?? null
191
+ systemPromptSnapshot: data.systemPromptSnapshot ?? null,
192
+ reasoningEffort: toReasoningEffort(data.reasoningEffort)
80
193
  };
81
194
  }
82
195
  function toCategory(record) {
@@ -1711,111 +1824,6 @@ function readPrompt(raw) {
1711
1824
  if (typeof name !== "string" || name === "") return null;
1712
1825
  return typeof label === "string" && label !== "" ? { name, label } : { name };
1713
1826
  }
1714
- var AGENT_FIELD_NAME_UID = "e9cfec6f-15c6-4d02-8f79-0667f64b9eb5";
1715
- var AGENT_FIELD_PROVIDER_UID = "e522b809-e8a7-4439-a2df-936158d04389";
1716
- var AGENT_FIELD_MODEL_ID_UID = "d95977ba-362c-44d6-a2f0-24156c76cf8a";
1717
- var AGENT_FIELD_STATUS_UID = "348725a0-a896-4f8d-8a56-86f4193234a8";
1718
- var AGENT_FIELD_DEFAULT_KEY_UID = "0134491a-c969-4c42-894c-36ad4880fed3";
1719
- var AGENT_FIELD_PROMPT_NAME_UID = "32e7f234-00bb-44d2-917b-be28f32f7214";
1720
- var AGENT_FIELD_PROMPT_LABEL_UID = "bdee53ff-571a-4df6-91ec-00b513a70fe0";
1721
- var AGENT_FIELD_PROMPT_VERSION_UID = "e7c66f99-e1e0-4fc2-9f9e-3bafe3af8e88";
1722
- var AGENT_FIELD_SYSTEM_PROMPT_SNAPSHOT_UID = "710b73c6-929b-48b7-abc0-792849adf1c2";
1723
- var AGENT_FIELD_REASONING_EFFORT_UID = "aa57fc6e-c989-47d3-9fc8-e04184b1e67c";
1724
- var AGENT_FIELD_MAX_TOOL_CALLS_UID = "6948a5ca-48ef-45d7-9118-c7ab195343a3";
1725
-
1726
- // src/records/agent.ts
1727
- var AGENT_STATUSES = ["default", "available", "archived"];
1728
- var REASONING_EFFORT_OPTIONS = ["off", "low", "medium", "high"];
1729
- var DEFAULT_LLM_PROVIDER = "openai";
1730
- ({
1731
- fields: [
1732
- {
1733
- universalIdentifier: AGENT_FIELD_NAME_UID,
1734
- name: "name",
1735
- type: appKit.FieldType.TEXT,
1736
- label: "Name",
1737
- isNullable: false
1738
- },
1739
- {
1740
- universalIdentifier: AGENT_FIELD_PROVIDER_UID,
1741
- name: "provider",
1742
- type: appKit.FieldType.TEXT,
1743
- label: "Provider",
1744
- description: "Free text (spec \xA73.4) \u2014 a new provider must not need a kit release.",
1745
- isNullable: false,
1746
- defaultValue: DEFAULT_LLM_PROVIDER
1747
- },
1748
- {
1749
- universalIdentifier: AGENT_FIELD_MODEL_ID_UID,
1750
- name: "modelId",
1751
- type: appKit.FieldType.TEXT,
1752
- label: "Model id",
1753
- isNullable: false
1754
- },
1755
- {
1756
- universalIdentifier: AGENT_FIELD_STATUS_UID,
1757
- name: "status",
1758
- type: appKit.FieldType.SELECT,
1759
- label: "Status",
1760
- isNullable: false,
1761
- options: [...AGENT_STATUSES],
1762
- defaultValue: "available"
1763
- },
1764
- {
1765
- universalIdentifier: AGENT_FIELD_DEFAULT_KEY_UID,
1766
- name: "defaultKey",
1767
- type: appKit.FieldType.TEXT,
1768
- label: "Default key",
1769
- description: "Equals 'default' when status='default', absent otherwise. Unique.",
1770
- isNullable: true
1771
- },
1772
- {
1773
- universalIdentifier: AGENT_FIELD_PROMPT_NAME_UID,
1774
- name: "promptName",
1775
- type: appKit.FieldType.TEXT,
1776
- label: "Prompt name",
1777
- description: "Free Langfuse prompt name (ETL keeps legacy agent/<old id> names).",
1778
- isNullable: false
1779
- },
1780
- {
1781
- universalIdentifier: AGENT_FIELD_PROMPT_LABEL_UID,
1782
- name: "promptLabel",
1783
- type: appKit.FieldType.TEXT,
1784
- label: "Prompt label",
1785
- isNullable: true
1786
- },
1787
- {
1788
- universalIdentifier: AGENT_FIELD_PROMPT_VERSION_UID,
1789
- name: "promptVersion",
1790
- type: appKit.FieldType.NUMBER,
1791
- label: "Prompt version",
1792
- description: 'Pinning; absent means "follow the label".',
1793
- isNullable: true
1794
- },
1795
- {
1796
- universalIdentifier: AGENT_FIELD_SYSTEM_PROMPT_SNAPSHOT_UID,
1797
- name: "systemPromptSnapshot",
1798
- type: appKit.FieldType.TEXT,
1799
- label: "System prompt snapshot",
1800
- description: "Level-3 fallback of the prompt ladder (\xA73.7).",
1801
- isNullable: true
1802
- },
1803
- {
1804
- universalIdentifier: AGENT_FIELD_REASONING_EFFORT_UID,
1805
- name: "reasoningEffort",
1806
- type: appKit.FieldType.SELECT,
1807
- label: "Reasoning effort",
1808
- isNullable: true,
1809
- options: [...REASONING_EFFORT_OPTIONS]
1810
- },
1811
- {
1812
- universalIdentifier: AGENT_FIELD_MAX_TOOL_CALLS_UID,
1813
- name: "maxToolCalls",
1814
- type: appKit.FieldType.NUMBER,
1815
- label: "Max tool calls",
1816
- isNullable: true
1817
- }
1818
- ]});
1819
1827
 
1820
1828
  // src/settings/to-profile.ts
1821
1829
  var DEFAULT_REASONING = "off";
@@ -2431,6 +2439,49 @@ function describeGuardrail(hits, reconstructed) {
2431
2439
  function asPercent(ratio) {
2432
2440
  return Math.round(ratio * 100);
2433
2441
  }
2442
+
2443
+ // src/domain/system-prompts.ts
2444
+ var OPERATOR_MODE_PROMPT_NAME = "shared/mode-operateur";
2445
+ var DEFAULT_OPERATOR_MODE_PROMPT = [
2446
+ "MODE OP\xC9RATEUR",
2447
+ "Tu es en mode op\xE9rateur : un membre de l'\xE9quipe relit ta r\xE9ponse et l'envoie lui-m\xEAme au client.",
2448
+ "* Quand un message commence par \xAB Merci d'utiliser le contexte suivant \xBB, c'est la consigne de l'op\xE9rateur : applique-la.",
2449
+ "* Ses consignes priment sur toutes les limites indiqu\xE9es plus haut, y compris les plafonds de geste commercial.",
2450
+ "* N'\xE9cris jamais qu'un agent ou l'\xE9quipe reviendra vers le client, sauf si l'op\xE9rateur le demande : r\xE9dige la r\xE9ponse compl\xE8te, pr\xEAte \xE0 envoyer.",
2451
+ "* S'il te manque une information, r\xE9dige quand m\xEAme la r\xE9ponse et signale le point \xE0 v\xE9rifier entre crochets, par exemple [\xC0 v\xE9rifier : num\xE9ro de commande]."
2452
+ ].join("\n");
2453
+ var SYSTEM_PROMPTS = [
2454
+ {
2455
+ name: OPERATOR_MODE_PROMPT_NAME,
2456
+ description: "Ajout\xE9 \xE0 la fin du prompt de l'agent quand un membre de l'\xE9quipe g\xE9n\xE8re une r\xE9ponse depuis l'extension.",
2457
+ usage: "operator",
2458
+ defaultContent: DEFAULT_OPERATOR_MODE_PROMPT
2459
+ }
2460
+ ];
2461
+ function systemPromptOf(name) {
2462
+ return SYSTEM_PROMPTS.find((prompt) => prompt.name === name);
2463
+ }
2464
+
2465
+ // src/domain/prompt-usage.ts
2466
+ var PROMPT_USAGES = ["always", "auto", "operator"];
2467
+ var DEFAULT_PROMPT_USAGE = "always";
2468
+ function isPromptUsage(value) {
2469
+ return typeof value === "string" && PROMPT_USAGES.includes(value);
2470
+ }
2471
+ function toSharedPromptUsages(value) {
2472
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return {};
2473
+ const usages = {};
2474
+ for (const [name, usage] of Object.entries(value)) {
2475
+ if (isPromptUsage(usage) && usage !== DEFAULT_PROMPT_USAGE) usages[name] = usage;
2476
+ }
2477
+ return usages;
2478
+ }
2479
+ function promptUsageOf(name, usages) {
2480
+ return systemPromptOf(name)?.usage ?? usages[name] ?? DEFAULT_PROMPT_USAGE;
2481
+ }
2482
+ function isPromptUsedIn(mode, usage) {
2483
+ return usage === DEFAULT_PROMPT_USAGE || usage === mode;
2484
+ }
2434
2485
  var AGENT_GUARDRAILS = [
2435
2486
  "whatsapp",
2436
2487
  "whatsapp_stop",
@@ -3240,7 +3291,7 @@ var PIPELINE_STEPS = [
3240
3291
  {
3241
3292
  key: "draft",
3242
3293
  label: "R\xE9daction",
3243
- description: "pr\xE9pare un projet de r\xE9ponse",
3294
+ description: "pr\xE9pare un projet de r\xE9ponse \u2014 mod\xE8le et effort par d\xE9faut des agents qui n'en pr\xE9cisent pas",
3244
3295
  requires: null,
3245
3296
  blockedReason: null
3246
3297
  },
@@ -3254,7 +3305,7 @@ var PIPELINE_STEPS = [
3254
3305
  {
3255
3306
  key: "revise",
3256
3307
  label: "R\xE9vision",
3257
- description: "r\xE9\xE9crit la r\xE9ponse si l'\xE9valuation la juge insuffisante",
3308
+ description: "r\xE9\xE9crit la r\xE9ponse si l'\xE9valuation la juge insuffisante, avec le mod\xE8le et l'effort de l'agent qui l'a r\xE9dig\xE9e \u2014 ceux-ci \xE0 d\xE9faut",
3258
3309
  requires: "evaluate",
3259
3310
  blockedReason: "Sans \xE9valuation, rien ne d\xE9clenche une r\xE9vision."
3260
3311
  }
@@ -3332,9 +3383,9 @@ function promptPatch(name, label) {
3332
3383
  }
3333
3384
  function stepReasoning(step2) {
3334
3385
  const value = step2?.reasoning;
3335
- return REASONING_EFFORTS.some((effort) => effort.value === value) ? value : "off";
3386
+ return REASONING_EFFORTS2.some((effort) => effort.value === value) ? value : "off";
3336
3387
  }
3337
- var REASONING_EFFORTS = [
3388
+ var REASONING_EFFORTS2 = [
3338
3389
  { value: "off", label: "Aucun" },
3339
3390
  { value: "low", label: "L\xE9ger" },
3340
3391
  { value: "medium", label: "Moyen" },
@@ -3464,29 +3515,258 @@ function ConfirmModal({
3464
3515
  ] })
3465
3516
  ] }) });
3466
3517
  }
3518
+
3519
+ // src/prompts/references.ts
3520
+ var REF_RE = /@@@langfusePrompt:name=([^|@]+)\|(?:version=(\d+)|label=([^@]+))@@@/g;
3521
+ var REFERENCE_TAG_SOURCE = REF_RE.source;
3522
+
3523
+ // src/prompts/syntax.ts
3524
+ var PROMPT_VARIABLES = {
3525
+ agent_name: { replacedBy: "le pr\xE9nom de la personne qui r\xE9pond, vide quand l'agent r\xE9pond seul", allowsSpaces: true },
3526
+ categories: { replacedBy: "la liste des cat\xE9gories, dans le prompt de tri uniquement", allowsSpaces: false },
3527
+ channel_prompt: { replacedBy: null, allowsSpaces: false }
3528
+ };
3529
+ var USAGE_SENTENCES = {
3530
+ always: "Inclus dans toutes les r\xE9ponses.",
3531
+ auto: "R\xE9ponse automatique seulement : ignor\xE9 quand un membre de l'\xE9quipe g\xE9n\xE8re une r\xE9ponse depuis l'extension.",
3532
+ operator: "Op\xE9rateur seulement : ignor\xE9 quand l'agent r\xE9pond seul."
3533
+ };
3534
+ var TAG_PREFIX = "@@@langfusePrompt:";
3535
+ var TAG_EXAMPLE = "@@@langfusePrompt:name=shared/nom|label=production@@@";
3536
+ var VARIABLE_RE = /\{\{([^{}\n]*)\}\}/g;
3537
+ var UNCLOSED_VARIABLE_RE = /\{\{(?![^{}\n]*\}\})[^\n]*/g;
3538
+ function referenceTokens(content, knowledge) {
3539
+ const tokens = [];
3540
+ const wellFormedStarts = /* @__PURE__ */ new Set();
3541
+ for (const match of content.matchAll(new RegExp(REFERENCE_TAG_SOURCE, "g"))) {
3542
+ const [raw, name, version, label] = match;
3543
+ const start = match.index ?? 0;
3544
+ wellFormedStarts.add(start);
3545
+ tokens.push({ start, end: start + raw.length, kind: "reference", ...describeReference(name, version, label, knowledge) });
3546
+ }
3547
+ let from = content.indexOf(TAG_PREFIX);
3548
+ while (from !== -1) {
3549
+ if (!wellFormedStarts.has(from)) {
3550
+ tokens.push({
3551
+ start: from,
3552
+ end: malformedEnd(content, from),
3553
+ kind: "malformed",
3554
+ status: "error",
3555
+ message: `R\xE9f\xE9rence mal form\xE9e, elle sera envoy\xE9e telle quelle au mod\xE8le. Forme attendue : ${TAG_EXAMPLE}`
3556
+ });
3557
+ }
3558
+ from = content.indexOf(TAG_PREFIX, from + TAG_PREFIX.length);
3559
+ }
3560
+ return tokens;
3561
+ }
3562
+ function malformedEnd(content, start) {
3563
+ const lineEnd = content.indexOf("\n", start);
3564
+ const limit = lineEnd === -1 ? content.length : lineEnd;
3565
+ const closing = content.indexOf("@@@", start + TAG_PREFIX.length);
3566
+ return closing !== -1 && closing < limit ? closing + 3 : limit;
3567
+ }
3568
+ function describeReference(name, version, label, knowledge) {
3569
+ const entry = knowledge.catalogue?.find((prompt) => prompt.name === name);
3570
+ if (knowledge.catalogue && !entry) {
3571
+ return { status: "error", message: `Prompt introuvable : \xAB ${name} \xBB n'existe pas ou n'est pas accessible depuis cette app.` };
3572
+ }
3573
+ if (entry && version !== void 0 && Number(version) > entry.latestVersion) {
3574
+ return { status: "error", message: `La version ${version} de \xAB ${name} \xBB n'existe pas (derni\xE8re version : ${entry.latestVersion}).` };
3575
+ }
3576
+ if (entry && label !== void 0 && !entry.labels.includes(label)) {
3577
+ return { status: "error", message: `Aucune version de \xAB ${name} \xBB ne porte le label \xAB ${label} \xBB.` };
3578
+ }
3579
+ const usage = promptUsageOf(name, knowledge.usages);
3580
+ const target = version !== void 0 ? `version ${version}` : `label \xAB ${label} \xBB`;
3581
+ return {
3582
+ status: isPromptUsedIn("auto", usage) && isPromptUsedIn("operator", usage) ? "ok" : "restricted",
3583
+ message: `Prompt \xAB ${name} \xBB, ${target}. ${USAGE_SENTENCES[usage]}`
3584
+ };
3585
+ }
3586
+ function variableTokens(content) {
3587
+ const tokens = [];
3588
+ for (const match of content.matchAll(VARIABLE_RE)) {
3589
+ const start = match.index ?? 0;
3590
+ const inner = match[1] ?? "";
3591
+ tokens.push({ start, end: start + match[0].length, kind: "variable", ...describeVariable(inner) });
3592
+ }
3593
+ for (const match of content.matchAll(UNCLOSED_VARIABLE_RE)) {
3594
+ const start = match.index ?? 0;
3595
+ tokens.push({
3596
+ start,
3597
+ end: start + match[0].length,
3598
+ kind: "variable",
3599
+ status: "error",
3600
+ message: "Accolades \xAB {{ \xBB sans fermeture \xAB }} \xBB sur la m\xEAme ligne."
3601
+ });
3602
+ }
3603
+ return tokens;
3604
+ }
3605
+ function describeVariable(inner) {
3606
+ const name = inner.trim();
3607
+ const known = PROMPT_VARIABLES[name];
3608
+ if (!known) {
3609
+ return {
3610
+ status: "error",
3611
+ message: `Variable inconnue : \xAB {{${name}}} \xBB ne sera pas remplac\xE9e. Variables disponibles : ${Object.keys(PROMPT_VARIABLES).join(", ")}.`
3612
+ };
3613
+ }
3614
+ if (known.replacedBy === null) {
3615
+ return { status: "error", message: `\xAB {{${name}}} \xBB n'est pas remplac\xE9e pour l'instant : elle arrive telle quelle au mod\xE8le.` };
3616
+ }
3617
+ if (inner !== name && !known.allowsSpaces) {
3618
+ return { status: "error", message: `\xC9crire \xAB {{${name}}} \xBB sans espaces, sinon la variable n'est pas remplac\xE9e.` };
3619
+ }
3620
+ return { status: "ok", message: `Variable remplac\xE9e par ${known.replacedBy}.` };
3621
+ }
3622
+ function readPromptSyntax(content, knowledge) {
3623
+ const drafts = [...referenceTokens(content, knowledge), ...variableTokens(content)].sort((a, b) => a.start - b.start);
3624
+ const tokens = [];
3625
+ let cursor = 0;
3626
+ let line = 1;
3627
+ let counted = 0;
3628
+ for (const draft of drafts) {
3629
+ if (draft.start < cursor) continue;
3630
+ for (; counted < draft.start; counted += 1) if (content[counted] === "\n") line += 1;
3631
+ tokens.push({ ...draft, line });
3632
+ cursor = draft.end;
3633
+ }
3634
+ return tokens;
3635
+ }
3636
+ var PROMPT_USAGE_LABELS = {
3637
+ always: "Toujours",
3638
+ auto: "R\xE9ponse automatique seulement",
3639
+ operator: "Op\xE9rateur seulement"
3640
+ };
3641
+ var PROMPT_USAGE_HINTS = {
3642
+ always: "Inclus dans toutes les r\xE9ponses.",
3643
+ 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.",
3644
+ 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."
3645
+ };
3646
+ var PROMPT_USAGE_OPTIONS = Object.keys(PROMPT_USAGE_LABELS).map((value) => ({
3647
+ value,
3648
+ label: PROMPT_USAGE_LABELS[value]
3649
+ }));
3650
+ function useSharedPromptUsages() {
3651
+ const { settings, error, save, isSaving, saveError } = uiSdk.useAppSettings();
3652
+ const usages = toSharedPromptUsages(settings?.sharedPromptUsages);
3653
+ const isReady = settings !== void 0 && error === void 0;
3654
+ return {
3655
+ usages,
3656
+ usageOf: (name) => promptUsageOf(name, usages),
3657
+ isReady,
3658
+ setUsage: (name, usage) => {
3659
+ if (!isReady) return Promise.resolve();
3660
+ const next = { ...usages };
3661
+ if (usage === DEFAULT_PROMPT_USAGE) delete next[name];
3662
+ else next[name] = usage;
3663
+ return save({ sharedPromptUsages: next });
3664
+ },
3665
+ isSaving,
3666
+ saveError
3667
+ };
3668
+ }
3467
3669
  var PROMPT_PANEL_CLASS = "w-[min(92vw,64rem)] max-w-none";
3468
3670
  var PRODUCTION_LABEL = "production";
3671
+ var TOKEN_CLASSES = {
3672
+ ok: "rounded-sm bg-status-info/15 text-status-info",
3673
+ restricted: "rounded-sm bg-status-pending/15 text-status-pending underline decoration-dashed underline-offset-2",
3674
+ error: "rounded-sm bg-status-blocked/15 text-status-blocked underline decoration-wavy underline-offset-2"
3675
+ };
3676
+ var EDITOR_BOX = "whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs leading-relaxed [scrollbar-gutter:stable]";
3469
3677
  var PromptTextarea = react.forwardRef(
3470
- function PromptTextarea2({ value, className, rows = 14, ...props }, ref) {
3678
+ function PromptTextarea2({ value, className, rows = 14, onScroll, ...props }, ref) {
3679
+ const knowledge = usePromptSyntaxKnowledge();
3680
+ const tokens = react.useMemo(() => readPromptSyntax(value, knowledge), [value, knowledge]);
3681
+ const layerRef = react.useRef(null);
3682
+ const [hovered, setHovered] = react.useState(null);
3683
+ const errors = tokens.filter((token) => token.status === "error");
3684
+ function hoverAt(event) {
3685
+ const index = document.elementsFromPoint?.(event.clientX, event.clientY).map((el) => el instanceof HTMLElement ? el.dataset.promptToken : void 0).find((found) => found !== void 0);
3686
+ const token = index === void 0 ? void 0 : tokens[Number(index)];
3687
+ const box = event.currentTarget.getBoundingClientRect();
3688
+ setHovered(token ? { token, x: event.clientX - box.left, y: event.clientY - box.top } : null);
3689
+ }
3471
3690
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3472
- /* @__PURE__ */ jsxRuntime.jsx(
3473
- uiSdk.Textarea,
3474
- {
3475
- ref,
3476
- value,
3477
- rows,
3478
- className: uiSdk.cn("font-mono text-xs leading-relaxed", className),
3479
- ...props
3480
- }
3481
- ),
3691
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
3692
+ /* @__PURE__ */ jsxRuntime.jsxs(
3693
+ "pre",
3694
+ {
3695
+ ref: layerRef,
3696
+ "aria-hidden": true,
3697
+ "data-testid": "prompt-syntax-layer",
3698
+ className: uiSdk.cn("absolute inset-0 m-0 overflow-hidden border border-transparent text-foreground", EDITOR_BOX),
3699
+ children: [
3700
+ renderSegments(value, tokens),
3701
+ value.endsWith("\n") ? " " : null
3702
+ ]
3703
+ }
3704
+ ),
3705
+ /* @__PURE__ */ jsxRuntime.jsx(
3706
+ uiSdk.Textarea,
3707
+ {
3708
+ ref,
3709
+ value,
3710
+ rows,
3711
+ spellCheck: false,
3712
+ className: uiSdk.cn("relative text-transparent caret-foreground", EDITOR_BOX, className),
3713
+ onScroll: (event) => {
3714
+ if (layerRef.current) layerRef.current.scrollTop = event.currentTarget.scrollTop;
3715
+ setHovered(null);
3716
+ onScroll?.(event);
3717
+ },
3718
+ onMouseMove: hoverAt,
3719
+ onMouseLeave: () => setHovered(null),
3720
+ ...props
3721
+ }
3722
+ ),
3723
+ hovered && /* @__PURE__ */ jsxRuntime.jsx(
3724
+ "div",
3725
+ {
3726
+ role: "tooltip",
3727
+ className: "pointer-events-none absolute z-50 max-w-sm rounded-md bg-foreground px-2 py-1 text-xs text-background shadow-md",
3728
+ style: { left: hovered.x + 12, top: hovered.y + 16 },
3729
+ children: hovered.token.message
3730
+ }
3731
+ )
3732
+ ] }),
3482
3733
  /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-1 text-right text-xs text-muted-foreground", children: [
3483
3734
  value.length.toLocaleString("fr-FR"),
3484
3735
  " caract\xE8re",
3485
3736
  value.length > 1 ? "s" : ""
3486
- ] })
3737
+ ] }),
3738
+ errors.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ul", { "aria-label": "Erreurs dans le prompt", className: "mt-1 space-y-1 text-xs", children: errors.map((token) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex gap-2", children: [
3739
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, className: "text-status-blocked", children: "\u2715" }),
3740
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground", children: [
3741
+ "Ligne ",
3742
+ token.line,
3743
+ " : ",
3744
+ token.message
3745
+ ] })
3746
+ ] }, `${token.start}-${token.end}`)) })
3487
3747
  ] });
3488
3748
  }
3489
3749
  );
3750
+ function renderSegments(value, tokens) {
3751
+ const segments = [];
3752
+ let cursor = 0;
3753
+ tokens.forEach((token, index) => {
3754
+ if (token.start > cursor) segments.push(value.slice(cursor, token.start));
3755
+ segments.push(
3756
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-prompt-token": index, "data-status": token.status, className: TOKEN_CLASSES[token.status], children: value.slice(token.start, token.end) }, token.start)
3757
+ );
3758
+ cursor = token.end;
3759
+ });
3760
+ if (cursor < value.length) segments.push(value.slice(cursor));
3761
+ return segments;
3762
+ }
3763
+ function usePromptSyntaxKnowledge() {
3764
+ const { prompts, isLoading, error } = usePromptCatalogue();
3765
+ const { usages } = useSharedPromptUsages();
3766
+ const catalogue = isLoading || error !== void 0 ? null : prompts;
3767
+ const usagesKey = JSON.stringify(usages);
3768
+ return react.useMemo(() => ({ catalogue, usages }), [catalogue, usagesKey]);
3769
+ }
3490
3770
  function defaultExpandedVersion(versions) {
3491
3771
  const production = versions.find((v) => v.labels.includes(PRODUCTION_LABEL));
3492
3772
  if (production) return production.version;
@@ -3541,8 +3821,8 @@ function VersionCard({
3541
3821
  ] })
3542
3822
  ] });
3543
3823
  }
3544
- function useNewVersionDraft() {
3545
- const [content, setContent] = react.useState("");
3824
+ function useNewVersionDraft(initialContent = "") {
3825
+ const [content, setContent] = react.useState(initialContent);
3546
3826
  const [pendingPrefill, setPendingPrefill] = react.useState(null);
3547
3827
  const editorRef = react.useRef(null);
3548
3828
  function loadIntoEditor(versionContent) {
@@ -3726,6 +4006,7 @@ function emptyForm() {
3726
4006
  name: "",
3727
4007
  modelId: "",
3728
4008
  provider: DEFAULT_LLM_PROVIDER,
4009
+ reasoningEffort: "",
3729
4010
  status: "available",
3730
4011
  promptName: "",
3731
4012
  promptLabel: "",
@@ -3737,12 +4018,14 @@ function formFromAgent(agent) {
3737
4018
  name: agent.name,
3738
4019
  modelId: agent.modelId,
3739
4020
  provider: agent.provider,
4021
+ reasoningEffort: agent.reasoningEffort ?? "",
3740
4022
  status: agent.status,
3741
4023
  promptName: agent.promptName,
3742
4024
  promptLabel: agent.promptLabel ?? "",
3743
4025
  systemPromptSnapshot: agent.systemPromptSnapshot ?? ""
3744
4026
  };
3745
4027
  }
4028
+ var STEP_EFFORT_VALUE = "__step__";
3746
4029
  var DERIVED_PROMPT_VALUE = "__derived__";
3747
4030
  var CUSTOM_PROMPT_VALUE = "__custom-prompt__";
3748
4031
  var DEFAULT_LABEL_VALUE = "__production__";
@@ -3874,6 +4157,25 @@ function AgentFormPanel({
3874
4157
  )
3875
4158
  ] })
3876
4159
  ] }),
4160
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4161
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-sm font-medium", children: "Effort de raisonnement" }),
4162
+ /* @__PURE__ */ jsxRuntime.jsx(
4163
+ uiSdk.Select,
4164
+ {
4165
+ "aria-label": "Effort de raisonnement",
4166
+ value: form.reasoningEffort === "" ? STEP_EFFORT_VALUE : form.reasoningEffort,
4167
+ onValueChange: (next) => setForm({ ...form, reasoningEffort: next === STEP_EFFORT_VALUE ? "" : next }),
4168
+ items: [
4169
+ { value: STEP_EFFORT_VALUE, label: "Celui de l'\xE9tape R\xE9daction" },
4170
+ ...REASONING_EFFORTS2.map((effort) => ({
4171
+ value: effort.value,
4172
+ label: effort.label
4173
+ }))
4174
+ ]
4175
+ }
4176
+ ),
4177
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "Ignor\xE9 par les mod\xE8les qui ne raisonnent pas." })
4178
+ ] }),
3877
4179
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3878
4180
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-sm font-medium", children: "Prompt Langfuse" }),
3879
4181
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-2 sm:grid-cols-2", children: [
@@ -4205,6 +4507,7 @@ function AgentsPage() {
4205
4507
  name: form.name,
4206
4508
  modelId: form.modelId,
4207
4509
  provider: form.provider,
4510
+ reasoningEffort: form.reasoningEffort,
4208
4511
  systemPromptSnapshot: form.systemPromptSnapshot,
4209
4512
  // Verbatim (trim only) — empty means "derive agent/<id>", and an
4210
4513
  // empty label means "follow production" (stored null, never the
@@ -4220,6 +4523,7 @@ function AgentsPage() {
4220
4523
  name: form.name,
4221
4524
  modelId: form.modelId,
4222
4525
  provider: form.provider,
4526
+ reasoningEffort: form.reasoningEffort || null,
4223
4527
  promptName: form.promptName.trim(),
4224
4528
  promptLabel: form.promptLabel.trim() || null,
4225
4529
  ...formAgent.status !== "default" ? { status: form.status } : {}
@@ -4238,7 +4542,14 @@ function AgentsPage() {
4238
4542
  }
4239
4543
  const columns = [
4240
4544
  { key: "name", header: "Nom", cell: (row) => row.name },
4241
- { key: "model", header: "Mod\xE8le", cell: (row) => `${row.provider} / ${row.modelId}` },
4545
+ {
4546
+ key: "model",
4547
+ header: "Mod\xE8le",
4548
+ cell: (row) => {
4549
+ const effort = REASONING_EFFORTS2.find((e) => e.value === row.reasoningEffort);
4550
+ return `${row.provider} / ${row.modelId}${effort ? ` \xB7 effort ${effort.label.toLowerCase()}` : ""}`;
4551
+ }
4552
+ },
4242
4553
  {
4243
4554
  key: "status",
4244
4555
  header: "Statut",
@@ -5222,7 +5533,7 @@ function StepOptions({
5222
5533
  "aria-label": `Effort de raisonnement \u2014 ${step2.label}`,
5223
5534
  value: stepReasoning(settings),
5224
5535
  onValueChange: (next) => onPatch({ reasoning: next }),
5225
- items: REASONING_EFFORTS.map((effort) => ({ value: effort.value, label: effort.label })),
5536
+ items: REASONING_EFFORTS2.map((effort) => ({ value: effort.value, label: effort.label })),
5226
5537
  disabled
5227
5538
  }
5228
5539
  )
@@ -7141,9 +7452,23 @@ function useSharedPrompts() {
7141
7452
  var SHARED_PREFIX2 = "shared/";
7142
7453
  var SLUG_RE = /^[a-z0-9-]{1,64}$/;
7143
7454
  var SLUG_ERROR = "Le nom doit contenir 1 \xE0 64 minuscules, chiffres ou tirets.";
7144
- function VersionsPanel({ name, canWrite, onClose }) {
7145
- const { versions, error, promote, deleteVersion, refresh } = usePromptVersions(name);
7146
- const draft = useNewVersionDraft();
7455
+ function VersionsPanel({
7456
+ name,
7457
+ canWrite,
7458
+ usage,
7459
+ isAdmin,
7460
+ canEditUsage,
7461
+ isSavingUsage,
7462
+ onUsageChange,
7463
+ system,
7464
+ isPublished,
7465
+ servesDefault,
7466
+ onPublished,
7467
+ onClose
7468
+ }) {
7469
+ const [exists, setExists] = react.useState(isPublished);
7470
+ const { versions, error, promote, deleteVersion, refresh } = usePromptVersions(exists ? name : null);
7471
+ const draft = useNewVersionDraft(servesDefault ? system?.defaultContent ?? "" : "");
7147
7472
  const [isCreating, setIsCreating] = react.useState(false);
7148
7473
  const [createError, setCreateError] = react.useState(null);
7149
7474
  const [deletingVersion, setDeletingVersion] = react.useState(null);
@@ -7153,6 +7478,7 @@ function VersionsPanel({ name, canWrite, onClose }) {
7153
7478
  const [compareRight, setCompareRight] = react.useState(null);
7154
7479
  const newVersionId = react.useId();
7155
7480
  const api = uiSdk.useAppApi();
7481
+ const { appSlug } = uiSdk.useAppContext();
7156
7482
  const toast = uiSdk.useToast();
7157
7483
  const sorted = [...versions].sort((a, b) => b.version - a.version);
7158
7484
  const expandedVersion = defaultExpandedVersion(versions);
@@ -7170,6 +7496,7 @@ function VersionsPanel({ name, canWrite, onClose }) {
7170
7496
  const version = promotingVersion;
7171
7497
  try {
7172
7498
  await promote(version);
7499
+ onPublished();
7173
7500
  toast({ title: `Version ${version} promue en production.`, variant: "success" });
7174
7501
  } catch (err) {
7175
7502
  toast({ title: "\xC9chec de la promotion", description: describeApiError(err), variant: "error" });
@@ -7195,13 +7522,21 @@ function VersionsPanel({ name, canWrite, onClose }) {
7195
7522
  setCreateError(null);
7196
7523
  const payload = { name, content: draft.content };
7197
7524
  try {
7198
- await api.invoke(
7525
+ const result = await api.invoke(
7199
7526
  "create-shared-prompt-version",
7200
7527
  payload,
7201
7528
  { idempotencyKey: idempotencyKeyFor("create-shared-prompt-version", payload) }
7202
7529
  );
7203
7530
  draft.setContent("");
7204
- await refresh();
7531
+ if (exists) {
7532
+ await refresh();
7533
+ } else {
7534
+ await api.post(`/data/apps/${appSlug}/prompts/promote`, { name, version: result.version, label: PRODUCTION_LABEL }).catch(() => {
7535
+ toast({ title: "Version cr\xE9\xE9e, mais pas encore en production", description: "Promouvez-la pour qu'elle soit utilis\xE9e.", variant: "error" });
7536
+ });
7537
+ setExists(true);
7538
+ onPublished();
7539
+ }
7205
7540
  } catch (err) {
7206
7541
  setCreateError(describeInvokeError(err));
7207
7542
  } finally {
@@ -7211,6 +7546,37 @@ function VersionsPanel({ name, canWrite, onClose }) {
7211
7546
  return /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.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: [
7212
7547
  /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-testid": "shared-prompt-versions", className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto", children: [
7213
7548
  error !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du chargement des versions." }),
7549
+ system && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 rounded-md border bg-muted/40 p-3 text-sm", children: [
7550
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium", children: "Prompt syst\xE8me" }),
7551
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-muted-foreground", children: [
7552
+ system.description,
7553
+ " Il existe toujours et son nom ne peut pas changer : seul son texte se modifie."
7554
+ ] }),
7555
+ (!exists || versions.length > 0 && !hasActiveVersion) && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-muted-foreground", children: [
7556
+ "Aucune version en production : le texte par d\xE9faut est utilis\xE9.",
7557
+ exists ? " Promouvez une version pour la mettre en service." : " Cr\xE9ez une version pour le modifier."
7558
+ ] })
7559
+ ] }),
7560
+ !system && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
7561
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "block text-sm font-medium", children: "Utilisation" }),
7562
+ /* @__PURE__ */ jsxRuntime.jsx(
7563
+ uiSdk.Select,
7564
+ {
7565
+ "aria-label": "Utilisation",
7566
+ value: usage,
7567
+ onValueChange: (value) => {
7568
+ if (isPromptUsage(value)) onUsageChange(value);
7569
+ },
7570
+ items: PROMPT_USAGE_OPTIONS,
7571
+ disabled: !canEditUsage || isSavingUsage
7572
+ }
7573
+ ),
7574
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
7575
+ PROMPT_USAGE_HINTS[usage],
7576
+ " Ce r\xE9glage ne vaut que pour cette app.",
7577
+ !isAdmin && " Seul un administrateur de l'app peut le changer."
7578
+ ] })
7579
+ ] }),
7214
7580
  versions.length > 0 && !hasActiveVersion && /* @__PURE__ */ jsxRuntime.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." }),
7215
7581
  versions.length >= 2 && /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: openCompare, children: "Comparer" }) }),
7216
7582
  isComparing && compareLeft !== null && compareRight !== null && /* @__PURE__ */ jsxRuntime.jsx(
@@ -7235,7 +7601,7 @@ function VersionsPanel({ name, canWrite, onClose }) {
7235
7601
  },
7236
7602
  v.version
7237
7603
  )),
7238
- sorted.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune version pour l'instant." })
7604
+ sorted.length === 0 && exists && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune version pour l'instant." })
7239
7605
  ] }),
7240
7606
  canWrite && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 border-t pt-3", children: [
7241
7607
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: newVersionId, className: "block text-sm font-medium", children: "Nouvelle version" }),
@@ -7363,16 +7729,61 @@ function SharedPromptsPage() {
7363
7729
  const { role } = uiSdk.useAppContext();
7364
7730
  const canWrite = canWriteForRole(role);
7365
7731
  const { prompts, isLoading, error, refresh } = useSharedPrompts();
7732
+ const { usageOf, setUsage, isReady: areUsagesReady, isSaving: isSavingUsage, saveError: usageSaveError } = useSharedPromptUsages();
7733
+ const toast = uiSdk.useToast();
7366
7734
  const [selected, setSelected] = react.useState(null);
7367
7735
  const [isCreateOpen, setIsCreateOpen] = react.useState(false);
7736
+ const wasSavingUsageRef = react.useRef(false);
7737
+ react.useEffect(() => {
7738
+ if (wasSavingUsageRef.current && !isSavingUsage) {
7739
+ if (usageSaveError === void 0) toast({ title: "Utilisation enregistr\xE9e.", variant: "success" });
7740
+ else toast({ title: "\xC9chec de l'enregistrement", description: describeApiError(usageSaveError), variant: "error" });
7741
+ }
7742
+ wasSavingUsageRef.current = isSavingUsage;
7743
+ }, [isSavingUsage, usageSaveError, toast]);
7744
+ const publishedNames = new Set(prompts.map((prompt) => prompt.name));
7745
+ const rows = isLoading || error ? prompts : [
7746
+ ...prompts,
7747
+ ...SYSTEM_PROMPTS.filter((system) => !publishedNames.has(system.name)).map((system) => ({
7748
+ name: system.name,
7749
+ labels: [],
7750
+ latestVersion: 0,
7751
+ isUnpublished: true
7752
+ }))
7753
+ ].sort((a, b) => a.name.localeCompare(b.name));
7754
+ const selectedSystem = selected ? systemPromptOf(selected) : void 0;
7368
7755
  const columns = [
7369
- { key: "name", header: "Nom", cell: (row) => row.name },
7756
+ {
7757
+ key: "name",
7758
+ header: "Nom",
7759
+ cell: (row) => systemPromptOf(row.name) ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-2", children: [
7760
+ row.name,
7761
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { children: "Syst\xE8me" })
7762
+ ] }) : row.name
7763
+ },
7764
+ {
7765
+ key: "usage",
7766
+ header: "Utilisation",
7767
+ cell: (row) => {
7768
+ const usage = systemPromptOf(row.name)?.usage ?? usageOf(row.name);
7769
+ return usage === DEFAULT_PROMPT_USAGE ? PROMPT_USAGE_LABELS[usage] : /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "info", children: PROMPT_USAGE_LABELS[usage] });
7770
+ }
7771
+ },
7370
7772
  {
7371
7773
  key: "labels",
7372
7774
  header: "Labels",
7373
7775
  cell: (row) => row.labels.length > 0 ? row.labels.map((l) => /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { children: l }, l)) : "\u2014"
7374
7776
  },
7375
- { key: "latestVersion", header: "Derni\xE8re version", align: "right", cell: (row) => `v${row.latestVersion}` }
7777
+ {
7778
+ key: "latestVersion",
7779
+ header: "Derni\xE8re version",
7780
+ align: "right",
7781
+ cell: (row) => {
7782
+ if (row.isUnpublished) return "Texte par d\xE9faut";
7783
+ const servesDefault = systemPromptOf(row.name) && !row.labels.includes(PRODUCTION_LABEL);
7784
+ return servesDefault ? `v${row.latestVersion} \xB7 texte par d\xE9faut utilis\xE9` : `v${row.latestVersion}`;
7785
+ }
7786
+ }
7376
7787
  ];
7377
7788
  return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
7378
7789
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -7388,7 +7799,7 @@ function SharedPromptsPage() {
7388
7799
  uiSdk.DataTable,
7389
7800
  {
7390
7801
  columns,
7391
- rows: prompts,
7802
+ rows,
7392
7803
  rowId: (row) => row.name,
7393
7804
  manual: true,
7394
7805
  loading: isLoading,
@@ -7400,7 +7811,24 @@ function SharedPromptsPage() {
7400
7811
  empty: "Aucun prompt \xAB shared/* \xBB accessible depuis cette app."
7401
7812
  }
7402
7813
  ),
7403
- selected && /* @__PURE__ */ jsxRuntime.jsx(VersionsPanel, { name: selected, canWrite, onClose: () => setSelected(null) }, selected),
7814
+ selected && /* @__PURE__ */ jsxRuntime.jsx(
7815
+ VersionsPanel,
7816
+ {
7817
+ name: selected,
7818
+ canWrite,
7819
+ usage: usageOf(selected),
7820
+ isAdmin: role === "ADMIN",
7821
+ canEditUsage: role === "ADMIN" && areUsagesReady,
7822
+ isSavingUsage,
7823
+ onUsageChange: (usage) => void setUsage(selected, usage),
7824
+ system: selectedSystem,
7825
+ isPublished: !rows.some((row) => row.name === selected && row.isUnpublished),
7826
+ servesDefault: selectedSystem !== void 0 && !rows.some((row) => row.name === selected && row.labels.includes(PRODUCTION_LABEL)),
7827
+ onPublished: () => void refresh(),
7828
+ onClose: () => setSelected(null)
7829
+ },
7830
+ selected
7831
+ ),
7404
7832
  isCreateOpen && /* @__PURE__ */ jsxRuntime.jsx(
7405
7833
  NewSharedPromptModal,
7406
7834
  {