@scalio-cloud/ui 0.60.0 → 0.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -604,6 +604,37 @@ list. Test IDs: `agents-panel`, `agents-code-create`, `agents-code-value`, `agen
604
604
  `agent-role-<id>-<role>`, `agent-worker-state-<id>-<worker>`, `agent-worker-restart|stop|start-<id>-<worker>`,
605
605
  `agent-block-<id>`, `agent-remove-<id>`, `agents-tasks`.
606
606
 
607
+ Since 0.64.0 (self-update U2, scalio-platform 0.39.0) the block also shows the agent version bundled in the app, the
608
+ update rule of the instance (automatic, maintenance window with days and times, or only on request; `GET|PUT
609
+ /update[/policy]`) and per agent the update state reported by the agent (updating, updated, rolled back with reason,
610
+ refused), a hint when the agent is below the app's minimum version, «Jetzt aktualisieren» (with a question) and «Erneut
611
+ versuchen» after a rollback. Against an older backend without `/update` the section stays hidden. Test IDs:
612
+ `agents-update`, `agents-update-mode`, `agents-update-day-<0..6>`, `agents-update-save`, `agent-update-state-<id>`,
613
+ `agent-update-now-<id>`, `agent-update-retry-<id>`, `agent-outdated-<id>`.
614
+
615
+ Since 0.65.0 (scripts from the app U3, scalio-platform 0.40.0) every agent shows its script state (`scripts: {version,
616
+ current}`: «aktuell» or «werden aktualisiert») and «Passwörter verschlüsselt» when it reported an encryption key
617
+ (`sealed`). Test ID `agent-scripts-<id>`.
618
+
619
+ ### Scripts des Agents (U5)
620
+
621
+ Since 0.66.0 (customer customizations U5, scalio-platform 0.41.0) `AgentScriptsPanel` shows every script the app
622
+ brings for the agent with its state (Standard, Angepasst, Angepasst veraltet, Freigabe ausstehend). The admin writes a
623
+ hook (`<Name>.after.ps1`, shown first) or replaces the whole script with a reason; after a new standard the panel
624
+ shows what Scalio changed and the customer's version side by side with «Anpassung behalten» and «Zurück zum
625
+ Standard»; with the four-eyes switch a second person approves. `canEdit` = the app's right `agent.scripts.edit`.
626
+
627
+ ```jsx
628
+ import { AgentScriptsPanel, agentScriptsApi } from "@scalio-cloud/ui/react";
629
+
630
+ const scripts = agentScriptsApi(api); // once, outside the component
631
+ <AgentScriptsPanel client={scripts} lang={lang} canEdit={can("agent.scripts.edit")} notify={notify} />
632
+ ```
633
+
634
+ Test IDs: `agent-scripts-panel`, `agent-script-<worker>-<name>`, `agent-script-state-…`, `agent-script-edit-…`,
635
+ `agent-script-content`, `agent-script-reason`, `agent-script-save`, `agent-script-keep`, `agent-script-approve`,
636
+ `agent-scripts-four-eyes`.
637
+
607
638
  ## KI-Bausteine: Einstellungen → KI-Assistent, Knopf, Vorschlag, Assistent (React)
608
639
 
609
640
  Since 0.57.0 (scalio-docs ADR 0111, `concepts/ki-alle-apps.md`) every app shows AI the same way. Server side:
@@ -700,6 +731,24 @@ const jobs = jobsApi(api); // GET /jobs, /jobs/runs, /jobs/queue, POST /jobs
700
731
  `queueActions(item, reload)`, `renderQueueDetail(item, reload)`.
701
732
  - `AuditNav`: the tabs `/audit` and `/jobs` (`base` for another prefix, `jobs={false}` hides Jobs).
702
733
 
734
+ ## Markdown anzeigen (React)
735
+
736
+ Since 0.63.0 (scalio-docs ADR 0110 point 4) Beacon (knowledge base) and Folio (pages) show Markdown with the same
737
+ block. The text is parsed into plain data and shown as React elements, never as HTML: a `<script>` in a text stays
738
+ text, links work only with http, https, mailto or a relative address. GitHub flavour: headings, tables with
739
+ alignment, callouts (`> [!NOTE]`, TIP, IMPORTANT, WARNING, CAUTION), task lists, one nested list level, code blocks,
740
+ strikethrough. Styles: classes `scalio-md-*` in `nav.css`.
741
+
742
+ ```jsx
743
+ import { Markdown, markdownOutline } from "@scalio-cloud/ui/react";
744
+
745
+ <Markdown text={page.body} lang={lang} testId="page-body" />
746
+ markdownOutline(page.body) // [{ level, text, id }] for a table of contents; headings carry the same id
747
+ ```
748
+
749
+ `labels` overrides the callout titles (`{ note, tip, important, warning, caution }`). Also exported:
750
+ `parseMarkdownBlocks`, `parseMarkdownInline`, `markdownHeadingId`, `safeHref`. Test IDs: `callout-<kind>`.
751
+
703
752
  ## shadcn/ui components (from 0.38.0)
704
753
 
705
754
  One copy of the shadcn/ui components the apps used to keep in `src/components/ui` (code-quality plan QA6, decision
package/nav.css CHANGED
@@ -919,3 +919,37 @@ ul.scalio-notice { flex-direction: column; gap: 0.25rem; padding-left: 2rem; lis
919
919
  .scalio-ai-turn-text { white-space: pre-wrap; }
920
920
  .scalio-ai-panel-form { display: flex; gap: 0.5rem; align-items: flex-end; }
921
921
  .scalio-ai-panel-form textarea { flex: 1; resize: vertical; }
922
+
923
+ /* Markdown (react/markdown.js): Beacon knowledge base, Folio pages. */
924
+ .scalio-md { font-size: 0.875rem; line-height: 1.6; overflow-wrap: anywhere; }
925
+ .scalio-md > * + *, .scalio-md-quote > * + *, .scalio-md-callout > * + * { margin-top: 0.75rem; }
926
+ .scalio-md-h1, .scalio-md-h2 { font-family: 'Chivo', 'IBM Plex Sans', sans-serif; font-weight: 700; padding-top: 0.5rem; }
927
+ .scalio-md-h1 { font-size: 1.5rem; line-height: 2rem; }
928
+ .scalio-md-h2 { font-size: 1.25rem; line-height: 1.75rem; border-bottom: 1px solid hsl(var(--border)); padding-bottom: 0.25rem; }
929
+ .scalio-md-h3 { font-size: 1.125rem; font-weight: 700; padding-top: 0.25rem; }
930
+ .scalio-md-h4, .scalio-md-h5, .scalio-md-h6 { font-size: 1rem; font-weight: 700; }
931
+ .scalio-md-h5, .scalio-md-h6 { font-size: 0.875rem; }
932
+ .scalio-md-h6 { color: hsl(var(--muted-foreground)); }
933
+ .scalio-md-link { color: hsl(var(--primary)); text-decoration: underline; }
934
+ .scalio-md-code { padding: 0.125rem 0.25rem; border-radius: 2px; background: hsl(var(--secondary)); font-family: 'JetBrains Mono', monospace; font-size: 0.85em; }
935
+ .scalio-md-pre { padding: 0.75rem; border-radius: 2px; background: hsl(var(--secondary)); font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; overflow-x: auto; white-space: pre; }
936
+ .scalio-md-rule { border: 0; border-top: 1px solid hsl(var(--border)); }
937
+ .scalio-md-list { list-style: disc; padding-left: 1.5rem; }
938
+ .scalio-md-list.is-ordered { list-style: decimal; }
939
+ .scalio-md-list.is-tasks { list-style: none; padding-left: 0.25rem; }
940
+ .scalio-md-list > li + li { margin-top: 0.25rem; }
941
+ .scalio-md-list > li.is-task { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-start; }
942
+ .scalio-md-list > li.is-task > input { margin-top: 0.3rem; }
943
+ .scalio-md-list > li > .scalio-md-list { margin-top: 0.25rem; flex-basis: 100%; }
944
+ .scalio-md-quote { border-left: 4px solid hsl(var(--border)); padding-left: 1rem; color: hsl(var(--muted-foreground)); }
945
+ .scalio-md-callout { border-left: 4px solid rgb(59 130 246 / 0.6); background: rgb(59 130 246 / 0.05); border-radius: 2px; padding: 0.75rem 1rem; }
946
+ .scalio-md-callout[data-callout="tip"] { border-color: rgb(22 163 74 / 0.6); background: rgb(22 163 74 / 0.05); }
947
+ .scalio-md-callout[data-callout="important"] { border-color: rgb(168 85 247 / 0.6); background: rgb(168 85 247 / 0.05); }
948
+ .scalio-md-callout[data-callout="warning"] { border-color: rgb(245 158 11 / 0.7); background: rgb(245 158 11 / 0.05); }
949
+ .scalio-md-callout[data-callout="caution"] { border-color: rgb(220 38 38 / 0.6); background: rgb(220 38 38 / 0.05); }
950
+ .scalio-md-callout-title { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 0.875rem; }
951
+ .scalio-md-table-wrap { overflow-x: auto; }
952
+ .scalio-md-table { font-size: 0.875rem; border-collapse: collapse; border: 1px solid hsl(var(--border)); }
953
+ .scalio-md-table th, .scalio-md-table td { padding: 0.375rem 0.75rem; border: 1px solid hsl(var(--border)); vertical-align: top; }
954
+ .scalio-md-table thead { background: hsl(var(--secondary)); }
955
+ .scalio-md-table th { font-weight: 700; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalio-cloud/ui",
3
- "version": "0.60.0",
3
+ "version": "0.66.0",
4
4
  "description": "Scalio Control Room design tokens, Tailwind preset, self-hosted fonts, the shared app header, sign-in layout, sidebar and page blocks",
5
5
  "license": "SEE LICENSE IN README.md",
6
6
  "private": false,
@@ -0,0 +1,295 @@
1
+ "use strict";
2
+ // Customer customizations of the Scalio Agent scripts (scalio-docs ADR 0107 U5, interfaces/agent-v2.md
3
+ // «Kunden-Anpassungen», concept agent-2 F5-F7, F9): Einstellungen -> Scalio Agent -> Scripts. Backend: scalio-platform
4
+ // 0.41.0 `agent.AgentHub.router` (GET /agent/v2/admin/scripts, GET|PUT|DELETE /scripts/{worker}/{name},
5
+ // POST /scripts/{worker}/{name}/approve|keep, PUT /scripts-policy).
6
+ // Hooks first (F6): a hook runs after the standard script; the whole script can be replaced too. After a new standard
7
+ // (contract change) the customization is «veraltet»: the panel shows what Scalio changed and the customer's version
8
+ // side by side, tasks wait until the admin keeps the customization or goes back to the standard (F7).
9
+ const React = require("react");
10
+ const h = React.createElement;
11
+ const Icons = require("./icons");
12
+ const { StatusBadge } = require("./blocks");
13
+ const { SettingsSection, SettingsField: Field } = require("./settings");
14
+ const { askConfirm } = require("./dialog");
15
+
16
+ const LABELS = {
17
+ de: {
18
+ title: "Scripts des Agents",
19
+ hint: "Hier passen Sie die Scripts an, die der Scalio Agent ausführt. Ein Hook läuft nach dem Standard-Script und ändert es nicht; Sie können das Script auch ganz ersetzen. Angepasste Scripts laufen nur auf Servern, auf denen «Eigene Scripts erlauben» (AllowCustomScripts) eingeschaltet ist.",
20
+ script: "Script",
21
+ actions: "Aktionen",
22
+ state: "Status",
23
+ version: "Version",
24
+ edit: "Bearbeiten",
25
+ close: "Schliessen",
26
+ none: "Diese App bringt keine Scripts für den Agent mit.",
27
+ states: { standard: "Standard", custom: "Angepasst", outdated: "Angepasst, veraltet", pending: "Freigabe ausstehend" },
28
+ fourEyes: "Vier-Augen-Prinzip: Änderungen an Scripts gibt eine zweite Person frei",
29
+ kindHook: "Hook (nach dem Standard-Script)",
30
+ kindFull: "Ganzes Script ersetzen",
31
+ content: "Inhalt",
32
+ reason: "Begründung (mindestens 10 Zeichen)",
33
+ save: "Speichern",
34
+ saved: "Gespeichert.",
35
+ savedPending: "Gespeichert. Die Änderung wartet auf die Freigabe einer zweiten Person.",
36
+ standardText: "Standard-Script von Scalio",
37
+ pendingBy: "Version {n} von {by} wartet auf Freigabe.",
38
+ approve: "Freigeben",
39
+ approved: "Freigegeben.",
40
+ outdatedTitle: "Scalio hat das Standard-Script geändert",
41
+ outdatedText: "Aufträge dieser Aktion warten, bis Sie entscheiden. Prüfen Sie, ob Ihre Anpassung zur neuen Fassung passt.",
42
+ scalioChanged: "Was Scalio geändert hat",
43
+ yourVersion: "Ihre Anpassung",
44
+ keep: "Anpassung behalten",
45
+ keepConfirm: "Ihre Anpassung für die neue Fassung des Standard-Scripts behalten? Wartende Aufträge laufen dann damit.",
46
+ reset: "Zurück zum Standard",
47
+ resetConfirm: "Die Anpassung von «{name}» entfernen? Aufträge laufen wieder mit dem Standard-Script. Die Versionen bleiben im Verlauf.",
48
+ history: "Verlauf",
49
+ noHistory: "Noch keine Anpassung.",
50
+ by: "von {by}",
51
+ hookTemplate: "param($Data, $Result)\n# Läuft nach dem Standard-Script. $Data = Auftragsdaten, $Result = Ergebnis des Standard-Scripts.\n",
52
+ },
53
+ en: {
54
+ title: "Agent scripts",
55
+ hint: "Customize the scripts the Scalio Agent runs. A hook runs after the standard script and leaves it unchanged; you can also replace the whole script. Customized scripts run only on servers where «Allow own scripts» (AllowCustomScripts) is switched on.",
56
+ script: "Script",
57
+ actions: "Actions",
58
+ state: "State",
59
+ version: "Version",
60
+ edit: "Edit",
61
+ close: "Close",
62
+ none: "This app brings no scripts for the agent.",
63
+ states: { standard: "Standard", custom: "Customized", outdated: "Customized, outdated", pending: "Waiting for approval" },
64
+ fourEyes: "Four-eyes principle: a second person approves changes to scripts",
65
+ kindHook: "Hook (after the standard script)",
66
+ kindFull: "Replace the whole script",
67
+ content: "Content",
68
+ reason: "Reason (at least 10 characters)",
69
+ save: "Save",
70
+ saved: "Saved.",
71
+ savedPending: "Saved. The change waits for a second person to approve it.",
72
+ standardText: "Standard script by Scalio",
73
+ pendingBy: "Version {n} by {by} waits for approval.",
74
+ approve: "Approve",
75
+ approved: "Approved.",
76
+ outdatedTitle: "Scalio changed the standard script",
77
+ outdatedText: "Tasks of this action wait until you decide. Check whether your customization fits the new version.",
78
+ scalioChanged: "What Scalio changed",
79
+ yourVersion: "Your customization",
80
+ keep: "Keep customization",
81
+ keepConfirm: "Keep your customization for the new version of the standard script? Waiting tasks then run with it.",
82
+ reset: "Back to standard",
83
+ resetConfirm: "Remove the customization of «{name}»? Tasks run with the standard script again. The versions stay in the history.",
84
+ history: "History",
85
+ noHistory: "No customization yet.",
86
+ by: "by {by}",
87
+ hookTemplate: "param($Data, $Result)\n# Runs after the standard script. $Data = task data, $Result = result of the standard script.\n",
88
+ },
89
+ };
90
+
91
+ const STATE_TONE = { standard: "neutral", custom: "ok", outdated: "warn", pending: "running" };
92
+
93
+ function labels(lang, overrides) {
94
+ return Object.assign({}, LABELS[lang === "en" ? "en" : "de"], overrides || {});
95
+ }
96
+
97
+ function fill(text, vars) {
98
+ return Object.keys(vars || {}).reduce((s, k) => s.split(`{${k}}`).join(vars[k] == null ? "" : vars[k]), text);
99
+ }
100
+
101
+ function errorText(err) {
102
+ const d = err && err.response && err.response.data && err.response.data.detail;
103
+ if (typeof d === "string") return d;
104
+ return (err && err.message) || String(err);
105
+ }
106
+
107
+ function agentScriptsApi(api, base) {
108
+ const b = base || "/agent/v2/admin";
109
+ const one = (w, n) => `${b}/scripts/${encodeURIComponent(w)}/${encodeURIComponent(n)}`;
110
+ return {
111
+ list: () => api.get(`${b}/scripts`).then((r) => r.data),
112
+ get: (w, n) => api.get(one(w, n)).then((r) => r.data),
113
+ save: (w, n, body) => api.put(one(w, n), body).then((r) => r.data),
114
+ approve: (w, n, number) => api.post(`${one(w, n)}/approve`, { number }).then((r) => r.data),
115
+ keep: (w, n) => api.post(`${one(w, n)}/keep`, {}).then((r) => r.data),
116
+ reset: (w, n) => api.delete(one(w, n)).then((r) => r.data),
117
+ setPolicy: (policy) => api.put(`${b}/scripts-policy`, policy).then((r) => r.data),
118
+ };
119
+ }
120
+
121
+ // Line diff (longest common subsequence): [{op: "same"|"add"|"del", text}].
122
+ function lineDiff(a, b) {
123
+ const x = String(a || "").split("\n");
124
+ const y = String(b || "").split("\n");
125
+ const n = x.length;
126
+ const m = y.length;
127
+ const len = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(0));
128
+ for (let i = n - 1; i >= 0; i -= 1) {
129
+ for (let j = m - 1; j >= 0; j -= 1) len[i][j] = x[i] === y[j] ? len[i + 1][j + 1] + 1 : Math.max(len[i + 1][j], len[i][j + 1]);
130
+ }
131
+ const out = [];
132
+ let i = 0;
133
+ let j = 0;
134
+ while (i < n && j < m) {
135
+ if (x[i] === y[j]) { out.push({ op: "same", text: x[i] }); i += 1; j += 1; }
136
+ else if (len[i + 1][j] >= len[i][j + 1]) { out.push({ op: "del", text: x[i] }); i += 1; }
137
+ else { out.push({ op: "add", text: y[j] }); j += 1; }
138
+ }
139
+ while (i < n) { out.push({ op: "del", text: x[i] }); i += 1; }
140
+ while (j < m) { out.push({ op: "add", text: y[j] }); j += 1; }
141
+ return out;
142
+ }
143
+
144
+ const DIFF_STYLE = {
145
+ add: { background: "var(--scalio-success-soft, #e6f4ea)" },
146
+ del: { background: "var(--scalio-danger-soft, #fdecea)", textDecoration: "line-through" },
147
+ same: {},
148
+ };
149
+
150
+ function DiffView(props) {
151
+ const rows = lineDiff(props.from, props.to);
152
+ return h("pre", { className: "scalio-settings-text", "data-testid": props.testId,
153
+ style: { whiteSpace: "pre-wrap", fontFamily: "var(--scalio-font-mono, monospace)", fontSize: "0.85em", maxHeight: "24rem", overflow: "auto" } },
154
+ rows.map((r, i) => h("div", { key: i, style: DIFF_STYLE[r.op], "data-op": r.op }, `${r.op === "add" ? "+ " : r.op === "del" ? "- " : " "}${r.text}`)));
155
+ }
156
+
157
+ function stateOf(row) {
158
+ if (row.pending && row.state === "standard") return "pending";
159
+ return row.state;
160
+ }
161
+
162
+ // Props: client (agentScriptsApi), lang, labels, canEdit (right agent.scripts.edit, default true), notify, formatError.
163
+ function AgentScriptsPanel(props) {
164
+ const L = labels(props.lang, props.labels);
165
+ const fmtErr = props.formatError || errorText;
166
+ const canEdit = props.canEdit !== false;
167
+ const [data, setData] = React.useState(null);
168
+ const [open, setOpen] = React.useState(null); // detail of the opened script
169
+ const [kind, setKind] = React.useState("hook");
170
+ const [text, setText] = React.useState("");
171
+ const [reason, setReason] = React.useState("");
172
+ const [busy, setBusy] = React.useState(false);
173
+ const [error, setError] = React.useState("");
174
+
175
+ const load = React.useCallback(async () => {
176
+ try { setData(await props.client.list()); setError(""); } catch (e) { setError(fmtErr(e)); }
177
+ }, [props.client]); // eslint-disable-line react-hooks/exhaustive-deps
178
+ React.useEffect(() => { load(); }, [load]);
179
+
180
+ const fillEditor = (d, k) => {
181
+ const v = d.pending || d.active;
182
+ if (v && v.kind === k) setText(v.content || "");
183
+ else setText(k === "hook" ? L.hookTemplate : d.standard.content);
184
+ };
185
+ const openScript = async (row) => {
186
+ try {
187
+ const d = await props.client.get(row.worker, row.name);
188
+ const v = d.pending || d.active;
189
+ const k = v ? v.kind : "hook";
190
+ setOpen(d); setKind(k); fillEditor(d, k); setReason(""); setError("");
191
+ } catch (e) { setError(fmtErr(e)); }
192
+ };
193
+ const run = async (fn, ok) => {
194
+ setBusy(true);
195
+ try {
196
+ const res = await fn();
197
+ if (ok && props.notify) props.notify(typeof ok === "function" ? ok(res) : ok, "ok");
198
+ await load();
199
+ if (open) setOpen(await props.client.get(open.worker, open.name));
200
+ setBusy(false);
201
+ return res;
202
+ } catch (e) {
203
+ const t = fmtErr(e); setError(t); if (props.notify) props.notify(t, "error"); setBusy(false);
204
+ return null;
205
+ }
206
+ };
207
+
208
+ const rows = [];
209
+ const scripts = (data && data.scripts) || [];
210
+ const policy = (data && data.policy) || { four_eyes: false };
211
+ rows.push(h(Field, { key: "policy", label: L.fourEyes, testId: "agent-scripts-policy" },
212
+ h("label", { className: "scalio-settings-check" },
213
+ h("input", { type: "checkbox", checked: !!policy.four_eyes, disabled: busy || !canEdit, "data-testid": "agent-scripts-four-eyes",
214
+ onChange: () => run(() => props.client.setPolicy({ four_eyes: !policy.four_eyes }), L.saved) }),
215
+ h("span", null, L.fourEyes))));
216
+
217
+ rows.push(h(Field, { key: "list", label: L.title },
218
+ !data ? null : scripts.length === 0 ? h("p", { className: "scalio-settings-text", "data-testid": "agent-scripts-none" }, L.none)
219
+ : h("div", { style: { overflowX: "auto" } }, h("table", { className: "scalio-users-table", "data-testid": "agent-scripts-table" },
220
+ h("thead", null, h("tr", null, [L.script, L.actions, L.state, L.version, ""].map((t, i) => h("th", { key: i }, t)))),
221
+ h("tbody", null, scripts.map((s) => {
222
+ const st = stateOf(s);
223
+ const id = `${s.worker}-${s.name}`;
224
+ return h("tr", { key: id, "data-testid": `agent-script-${id}` },
225
+ h("td", null, h("div", { className: "font-medium" }, s.name), h("div", { className: "scalio-settings-text" }, s.worker)),
226
+ h("td", null, (s.actions || []).join(", ")),
227
+ h("td", null, h(StatusBadge, { tone: STATE_TONE[st] || "neutral", testId: `agent-script-state-${id}` }, L.states[st] || st)),
228
+ h("td", null, s.active ? `${s.active.number} · ${s.active.kind === "hook" ? "Hook" : "Script"}` : "–"),
229
+ h("td", null, h("button", { type: "button", className: "scalio-btn is-ghost", disabled: busy, "data-testid": `agent-script-edit-${id}`,
230
+ onClick: () => openScript(s) }, L.edit)));
231
+ }))))));
232
+
233
+ if (open) {
234
+ const d = open;
235
+ const tid = `${d.worker}-${d.name}`;
236
+ const parts = [];
237
+ if (d.state === "outdated" && d.active) {
238
+ parts.push(h("div", { key: "out", className: "scalio-notice is-warning", role: "status", "data-testid": "agent-script-outdated" },
239
+ h("div", { className: "scalio-notice-body" },
240
+ h("div", { className: "scalio-notice-title" }, L.outdatedTitle),
241
+ h("div", { className: "scalio-notice-text" }, L.outdatedText),
242
+ h("div", { style: { display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(18rem, 1fr))", gap: "0.75rem", marginTop: "0.5rem" } },
243
+ h("div", null, h("div", { className: "font-medium" }, L.scalioChanged),
244
+ h(DiffView, { from: d.active.base_content, to: d.standard.content, testId: "agent-script-diff-standard" })),
245
+ h("div", null, h("div", { className: "font-medium" }, L.yourVersion),
246
+ d.active.kind === "full"
247
+ ? h(DiffView, { from: d.active.base_content, to: d.active.content, testId: "agent-script-diff-custom" })
248
+ : h("pre", { className: "scalio-settings-text", "data-testid": "agent-script-diff-custom", style: { whiteSpace: "pre-wrap" } }, d.active.content))),
249
+ canEdit ? h("div", { style: { display: "flex", gap: "0.5rem", marginTop: "0.5rem", flexWrap: "wrap" } },
250
+ h("button", { type: "button", className: "scalio-btn is-solid", disabled: busy, "data-testid": "agent-script-keep",
251
+ onClick: async () => { if (await askConfirm({ title: L.title, text: L.keepConfirm, confirmLabel: L.keep, lang: props.lang })) run(() => props.client.keep(d.worker, d.name), L.saved); } }, L.keep),
252
+ h("button", { type: "button", className: "scalio-btn", disabled: busy, "data-testid": "agent-script-reset-outdated",
253
+ onClick: async () => { if (await askConfirm({ title: L.title, text: fill(L.resetConfirm, { name: d.name }), confirmLabel: L.reset, lang: props.lang, danger: true })) run(() => props.client.reset(d.worker, d.name), L.saved); } }, L.reset)) : null)));
254
+ }
255
+ if (d.pending) {
256
+ parts.push(h("div", { key: "pend", className: "scalio-notice is-info", role: "status", "data-testid": "agent-script-pending" },
257
+ h("div", { className: "scalio-notice-body" },
258
+ h("div", { className: "scalio-notice-text" }, fill(L.pendingBy, { n: d.pending.number, by: d.pending.by }), " ", d.pending.reason || ""),
259
+ d.active || d.standard ? h(DiffView, { from: d.pending.kind === "full" ? (d.active && d.active.kind === "full" ? d.active.content : d.standard.content) : (d.active && d.active.kind === "hook" ? d.active.content : ""),
260
+ to: d.pending.content, testId: "agent-script-diff-pending" }) : null,
261
+ canEdit ? h("button", { type: "button", className: "scalio-btn is-solid", disabled: busy, "data-testid": "agent-script-approve",
262
+ onClick: () => run(() => props.client.approve(d.worker, d.name, d.pending.number), L.approved) }, L.approve) : null)));
263
+ }
264
+ parts.push(h("div", { key: "kind", style: { display: "flex", gap: "1rem", flexWrap: "wrap" } },
265
+ [["hook", L.kindHook], ["full", L.kindFull]].map(([k, label]) => h("label", { key: k, className: "scalio-settings-check" },
266
+ h("input", { type: "radio", name: `agent-script-kind-${tid}`, checked: kind === k, disabled: busy || !canEdit, "data-testid": `agent-script-kind-${k}`,
267
+ onChange: () => { setKind(k); fillEditor(d, k); } }),
268
+ h("span", null, k === "hook" ? `${label}: ${d.hook}` : label)))));
269
+ parts.push(h("textarea", { key: "text", className: "scalio-input", rows: 16, value: text, disabled: busy || !canEdit, spellCheck: false,
270
+ "aria-label": L.content, "data-testid": "agent-script-content", style: { width: "100%", fontFamily: "var(--scalio-font-mono, monospace)" },
271
+ onChange: (e) => setText(e.target.value) }));
272
+ if (kind === "full") parts.push(h(DiffView, { key: "d", from: d.standard.content, to: text, testId: "agent-script-diff-edit" }));
273
+ parts.push(h("div", { key: "save", style: { display: "flex", gap: "0.5rem", flexWrap: "wrap", alignItems: "center" } },
274
+ h("input", { className: "scalio-input", placeholder: L.reason, "aria-label": L.reason, value: reason, maxLength: 500, disabled: busy || !canEdit,
275
+ "data-testid": "agent-script-reason", style: { flex: "1 1 20rem" }, onChange: (e) => setReason(e.target.value) }),
276
+ canEdit ? h("button", { type: "button", className: "scalio-btn is-solid", disabled: busy || reason.trim().length < 10, "data-testid": "agent-script-save",
277
+ onClick: async () => { const res = await run(() => props.client.save(d.worker, d.name, { kind, content: text, reason }), (r) => (r && r.status === "pending" ? L.savedPending : L.saved)); if (res) setReason(""); } }, L.save) : null,
278
+ canEdit && d.active && d.state !== "outdated" ? h("button", { type: "button", className: "scalio-btn", disabled: busy, "data-testid": "agent-script-reset",
279
+ onClick: async () => { if (await askConfirm({ title: L.title, text: fill(L.resetConfirm, { name: d.name }), confirmLabel: L.reset, lang: props.lang, danger: true })) run(() => props.client.reset(d.worker, d.name), L.saved); } }, L.reset) : null,
280
+ h("button", { type: "button", className: "scalio-btn is-ghost", "data-testid": "agent-script-close", onClick: () => setOpen(null) }, L.close)));
281
+ parts.push(h("details", { key: "std" }, h("summary", null, L.standardText),
282
+ h("pre", { className: "scalio-settings-text", style: { whiteSpace: "pre-wrap" }, "data-testid": "agent-script-standard" }, d.standard.content)));
283
+ parts.push(h("div", { key: "hist", "data-testid": "agent-script-history" }, h("div", { className: "font-medium" }, L.history),
284
+ (d.versions || []).length === 0 ? h("p", { className: "scalio-settings-text" }, L.noHistory)
285
+ : h("ul", { className: "scalio-settings-text" }, d.versions.map((v) => h("li", { key: v.number },
286
+ `${v.number} · ${v.kind === "hook" ? "Hook" : "Script"} · ${fill(L.by, { by: v.by })} · ${v.reason || ""}${v.status === "pending" ? ` · ${L.states.pending}` : ""}`)))));
287
+ rows.push(h(Field, { key: "detail", label: `${d.worker} / ${d.name}`, testId: "agent-script-detail" },
288
+ h("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" } }, parts)));
289
+ }
290
+
291
+ if (error) rows.push(h("div", { key: "err", className: "scalio-notice is-error", role: "alert", "data-testid": "agent-scripts-error" }, error));
292
+ return h(SettingsSection, { id: "agent-scripts", title: L.title, description: L.hint, testId: "agent-scripts-panel" }, rows);
293
+ }
294
+
295
+ module.exports = { AgentScriptsPanel, agentScriptsApi, agentScriptLineDiff: lineDiff, AGENT_SCRIPTS_LABELS: LABELS };
package/react/agents.js CHANGED
@@ -2,7 +2,8 @@
2
2
  // Scalio Agent in the app (scalio-docs ADR 0107, interfaces/agent-v2.md): AgentsPanel in Einstellungen -> Scalio Agent
3
3
  // for admins. Backend: scalio-platform `agent.AgentHub.router` (GET /agent/v2/admin/agents, PATCH /agents/{id},
4
4
  // POST /agents/{id}/block|unblock, DELETE /agents/{id}, POST /agents/{id}/workers/{worker}/{restart|stop|start},
5
- // POST|GET /agent/v2/admin/codes, DELETE /codes/{id}, GET /agent/v2/admin/tasks).
5
+ // POST|GET /agent/v2/admin/codes, DELETE /codes/{id}, GET /agent/v2/admin/tasks; self-update U2: GET /update,
6
+ // PUT /update/policy, POST /agents/{id}/update, POST /agents/{id}/update/retry).
6
7
  // Shows every agent of this instance with its roles and worker states, creates one-time enrollment codes (the
7
8
  // code is shown once) and lists the last tasks without their data.
8
9
  const React = require("react");
@@ -63,6 +64,30 @@ const LABELS = {
63
64
  states: { starting: "startet", running: "läuft", stopped: "angehalten", crashed: "abgestürzt, startet neu", disabled: "abgeschaltet nach Abstürzen", unavailable: "nicht verfügbar" },
64
65
  taskStates: { queued: "wartet", claimed: "läuft", finished: "fertig", error: "Fehler" },
65
66
  restarts: "{n} Neustarts",
67
+ updTitle: "Updates des Agents",
68
+ updAvailable: "In dieser App enthalten: Agent {version}",
69
+ updNone: "Diese App enthält keine freigegebene Agent-Version.",
70
+ updMode: "Regel",
71
+ updModes: { auto: "Automatisch, sobald verfügbar", window: "Im Wartungsfenster", manual: "Nur auf Knopfdruck" },
72
+ updDays: "Tage",
73
+ updFrom: "von",
74
+ updTo: "bis",
75
+ updSave: "Regel speichern",
76
+ updMinimum: "Agents unter Version {version} bekommen das Update immer, sie sind zu alt für diese App.",
77
+ days: ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"],
78
+ updateNow: "Jetzt aktualisieren",
79
+ updateRetry: "Erneut versuchen",
80
+ updateRequested: "Update auf {version} angefordert",
81
+ updateNowConfirm: "Agent «{name}» jetzt auf {version} aktualisieren? Laufende Aufträge werden fertig gemacht, dann startet der Dienst neu.",
82
+ outdated: "Zu alt für diese App, bitte aktualisieren",
83
+ scripts: "Scripts {version}",
84
+ scriptsCurrent: "aktuell",
85
+ scriptsOld: "werden aktualisiert",
86
+ sealed: "Passwörter verschlüsselt",
87
+ customAllowed: "eigene Scripts erlaubt",
88
+ updStates: { installing: "Wird aktualisiert auf {version}", verifying: "Prüft Version {version}", installed: "Aktualisiert auf {version}",
89
+ rolled_back: "Zurückgerollt auf {from} ({reason})", rollback_failed: "Rollback fehlgeschlagen ({reason})", failed: "Update fehlgeschlagen ({reason})",
90
+ refused: "Update abgelehnt ({reason})" },
66
91
  },
67
92
  en: {
68
93
  title: "Scalio Agent",
@@ -114,10 +139,36 @@ const LABELS = {
114
139
  states: { starting: "starting", running: "running", stopped: "stopped", crashed: "crashed, restarting", disabled: "switched off after crashes", unavailable: "not available" },
115
140
  taskStates: { queued: "waiting", claimed: "running", finished: "done", error: "error" },
116
141
  restarts: "{n} restarts",
142
+ updTitle: "Agent updates",
143
+ updAvailable: "Included in this app: agent {version}",
144
+ updNone: "This app includes no released agent version.",
145
+ updMode: "Rule",
146
+ updModes: { auto: "Automatically when available", window: "In the maintenance window", manual: "Only on request" },
147
+ updDays: "Days",
148
+ updFrom: "from",
149
+ updTo: "to",
150
+ updSave: "Save rule",
151
+ updMinimum: "Agents below version {version} always get the update, they are too old for this app.",
152
+ days: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
153
+ updateNow: "Update now",
154
+ updateRetry: "Try again",
155
+ updateRequested: "Update to {version} requested",
156
+ updateNowConfirm: "Update agent «{name}» to {version} now? Running tasks are finished first, then the service restarts.",
157
+ outdated: "Too old for this app, please update",
158
+ scripts: "Scripts {version}",
159
+ scriptsCurrent: "current",
160
+ scriptsOld: "being updated",
161
+ sealed: "passwords encrypted",
162
+ customAllowed: "own scripts allowed",
163
+ updStates: { installing: "Updating to {version}", verifying: "Checking version {version}", installed: "Updated to {version}",
164
+ rolled_back: "Rolled back to {from} ({reason})", rollback_failed: "Rollback failed ({reason})", failed: "Update failed ({reason})",
165
+ refused: "Update refused ({reason})" },
117
166
  },
118
167
  };
119
168
 
120
169
  const STATE_TONE = { starting: "running", running: "ok", stopped: "neutral", crashed: "warn", disabled: "error", unavailable: "neutral" };
170
+ const UPDATE_TONE = { installing: "running", verifying: "running", installed: "ok", rolled_back: "warn", rollback_failed: "error", failed: "error", refused: "error" };
171
+ const RETRY_STATES = ["rolled_back", "rollback_failed", "failed", "refused"];
121
172
  const TASK_TONE = { queued: "neutral", claimed: "running", finished: "ok", error: "error" };
122
173
 
123
174
  function labels(lang, overrides) {
@@ -154,6 +205,10 @@ function agentsApi(api, base) {
154
205
  createCode: (body) => api.post(`${b}/codes`, body || {}).then((r) => r.data),
155
206
  revokeCode: (id) => api.delete(`${b}/codes/${id}`).then((r) => r.data),
156
207
  tasks: (limit) => api.get(`${b}/tasks?limit=${limit || 20}`).then((r) => r.data),
208
+ updateInfo: () => api.get(`${b}/update`).then((r) => r.data),
209
+ setPolicy: (policy) => api.put(`${b}/update/policy`, policy).then((r) => r.data),
210
+ updateNow: (id) => api.post(`${b}/agents/${id}/update`, {}).then((r) => r.data),
211
+ retryUpdate: (id) => api.post(`${b}/agents/${id}/update/retry`, {}).then((r) => r.data),
157
212
  };
158
213
  }
159
214
 
@@ -180,6 +235,8 @@ function AgentsPanel(props) {
180
235
  const [codeRoles, setCodeRoles] = React.useState(null);
181
236
  const [note, setNote] = React.useState("");
182
237
  const [shown, setShown] = React.useState(null); // {code, expires_at} right after «Code erzeugen»
238
+ const [upd, setUpd] = React.useState(null); // GET /update; stays null with an older backend
239
+ const [policy, setPolicy] = React.useState(null); // the rule being edited
183
240
 
184
241
  const load = React.useCallback(async () => {
185
242
  try {
@@ -191,6 +248,13 @@ function AgentsPanel(props) {
191
248
  } catch (e) {
192
249
  setError(fmtErr(e));
193
250
  }
251
+ if (props.client.updateInfo) {
252
+ try {
253
+ const u = await props.client.updateInfo();
254
+ setUpd(u);
255
+ setPolicy((p) => p || (u && u.policy) || null);
256
+ } catch (e) { setUpd(null); } // older backend without self-update
257
+ }
194
258
  }, [props.client]); // eslint-disable-line react-hooks/exhaustive-deps
195
259
 
196
260
  React.useEffect(() => {
@@ -283,10 +347,63 @@ function AgentsPanel(props) {
283
347
  onClick: () => run(() => props.client.revokeCode(c.id)) }, L.revoke))))));
284
348
  }
285
349
 
350
+ // self-update rule (U2)
351
+ if (upd && policy) {
352
+ const win = policy.window || { days: [], start: "22:00", end: "04:00" };
353
+ const setWin = (k, v) => setPolicy(Object.assign({}, policy, { window: Object.assign({}, win, { [k]: v }) }));
354
+ const days = win.days || [];
355
+ rows.push(h(Field, { key: "update", label: L.updTitle, testId: "agents-update" },
356
+ h("p", { className: "scalio-settings-text", "data-testid": "agents-update-available" },
357
+ upd.available ? fill(L.updAvailable, { version: upd.available.version }) : L.updNone),
358
+ upd.minimum_version ? h("p", { className: "scalio-settings-text", "data-testid": "agents-update-minimum" }, fill(L.updMinimum, { version: upd.minimum_version })) : null,
359
+ h("div", { style: { display: "flex", gap: "0.5rem", flexWrap: "wrap", alignItems: "center", marginTop: "0.5rem" } },
360
+ h("select", { className: "scalio-input", value: policy.mode, "aria-label": L.updMode, disabled: busy, "data-testid": "agents-update-mode",
361
+ onChange: (e) => setPolicy(Object.assign({}, policy, { mode: e.target.value })) },
362
+ ["auto", "window", "manual"].map((m) => h("option", { key: m, value: m }, L.updModes[m]))),
363
+ policy.mode === "window" ? [
364
+ h("span", { key: "d", style: { display: "flex", gap: "0.5rem", flexWrap: "wrap" } }, `${L.updDays}:`,
365
+ L.days.map((d, i) => h("label", { key: i, className: "scalio-settings-check" },
366
+ h("input", { type: "checkbox", checked: days.includes(i), disabled: busy, "data-testid": `agents-update-day-${i}`,
367
+ onChange: () => setWin("days", days.includes(i) ? days.filter((x) => x !== i) : days.concat([i]).sort()) }),
368
+ h("span", null, d)))),
369
+ h("label", { key: "s" }, L.updFrom, " ", h("input", { type: "time", className: "scalio-input", value: win.start, disabled: busy,
370
+ "data-testid": "agents-update-start", onChange: (e) => setWin("start", e.target.value) })),
371
+ h("label", { key: "e" }, L.updTo, " ", h("input", { type: "time", className: "scalio-input", value: win.end, disabled: busy,
372
+ "data-testid": "agents-update-end", onChange: (e) => setWin("end", e.target.value) })),
373
+ ] : null,
374
+ h("button", { type: "button", className: "scalio-btn", disabled: busy, "data-testid": "agents-update-save",
375
+ onClick: async () => { const res = await run(() => props.client.setPolicy(policy), L.saved); if (res) setPolicy(res); } }, L.updSave))));
376
+ }
377
+
286
378
  // agents
287
379
  const agents = (data && data.agents) || [];
288
380
  const roleLabel = (name) => (offered.find((r) => r.name === name) || {}).label || name;
289
381
  const setRoles = (a, roles) => run(() => props.client.update(a.id, { roles }), L.saved);
382
+ const updateCell = (a) => {
383
+ const u = a.update;
384
+ const out = [];
385
+ if (u && u.state) {
386
+ const text = fill((L.updStates || {})[u.state] || u.state, { version: u.version, from: u.from_version || a.version, reason: u.reason || "–" });
387
+ out.push(h("div", { key: "s" }, h(StatusBadge, { tone: UPDATE_TONE[u.state] || "neutral", testId: `agent-update-state-${a.id}` }, text)));
388
+ }
389
+ if (a.scripts) {
390
+ out.push(h("div", { key: "sc", className: "scalio-settings-text", "data-testid": `agent-scripts-${a.id}` },
391
+ fill(L.scripts, { version: a.scripts.version || "–" }), " · ", a.scripts.current ? L.scriptsCurrent : L.scriptsOld,
392
+ a.sealed ? ` · ${L.sealed}` : "", a.custom_scripts ? ` · ${L.customAllowed}` : ""));
393
+ }
394
+ if (a.outdated) out.push(h("div", { key: "o", className: "scalio-settings-text", "data-testid": `agent-outdated-${a.id}` }, h(Icons.Alert, { className: "scalio-icon" }), " ", L.outdated));
395
+ const target = upd && upd.available ? upd.available.version : "";
396
+ if (a.update_requested) out.push(h("div", { key: "r", className: "scalio-settings-text", "data-testid": `agent-update-requested-${a.id}` }, fill(L.updateRequested, { version: a.update_requested })));
397
+ else if (u && RETRY_STATES.includes(u.state) && u.version === target) {
398
+ out.push(h("button", { key: "b", type: "button", className: "scalio-btn is-ghost", disabled: busy || a.blocked, "data-testid": `agent-update-retry-${a.id}`,
399
+ onClick: () => run(() => props.client.retryUpdate(a.id), L.sent) }, h(Icons.RotateCcw, { className: "scalio-icon" }), L.updateRetry));
400
+ } else if (a.update_available && !(u && (u.state === "installing" || u.state === "verifying"))) {
401
+ out.push(h("button", { key: "b", type: "button", className: "scalio-btn is-ghost", disabled: busy || a.blocked, "data-testid": `agent-update-now-${a.id}`,
402
+ onClick: () => confirmThen(fill(L.updateNowConfirm, { name: a.name, version: target }), L.updateNow, () => props.client.updateNow(a.id), L.sent) },
403
+ h(Icons.Download, { className: "scalio-icon" }), L.updateNow));
404
+ }
405
+ return out.length ? out : null;
406
+ };
290
407
  const agentRow = (a) => {
291
408
  const st = statusOf(a);
292
409
  const can = new Set(((a.capabilities || {}).workers) || []);
@@ -295,7 +412,7 @@ function AgentsPanel(props) {
295
412
  return h("tr", { key: a.id, "data-testid": `agent-${a.id}` },
296
413
  h("td", null, h("div", { className: "font-medium" }, a.name || a.hostname), a.domain ? h("div", { className: "scalio-settings-text" }, a.domain) : null),
297
414
  h("td", null, a.hostname || "", a.os ? h("div", { className: "scalio-settings-text" }, a.os) : null),
298
- h("td", null, a.version || "–"),
415
+ h("td", null, a.version || "–", updateCell(a)),
299
416
  h("td", null, h(StatusBadge, { tone: st === "online" ? "ok" : st === "blocked" ? "error" : "warn", testId: `agent-status-${a.id}` }, L[st]),
300
417
  h("div", { className: "scalio-settings-text" }, a.last_seen ? when(a.last_seen, props.lang) : L.never)),
301
418
  h("td", null, offered.map((r) => h("label", { key: r.name, className: "scalio-settings-check", title: can.has(r.name) ? "" : L.notOnHost },
package/react/icons.js CHANGED
@@ -32,6 +32,7 @@ const LifeBuoy = icon([
32
32
  ["circle", { cx: 12, cy: 12, r: 4 }],
33
33
  ["path", { d: "m4.93 4.93 4.24 4.24M14.83 9.17l4.24-4.24M14.83 14.83l4.24 4.24M9.17 14.83l-4.24 4.24" }],
34
34
  ]);
35
+ const Library = icon([["path", { d: "m16 6 4 14" }], ["path", { d: "M12 6v14" }], ["path", { d: "M8 8v12" }], ["path", { d: "M4 4v16" }]]);
35
36
  const BookOpen = icon([["path", { d: "M12 7v14" }], ["path", { d: "M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z" }]]);
36
37
  const LogOut = icon([["path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9" }]]);
37
38
  const Menu = icon([["path", { d: "M4 6h16M4 12h16M4 18h16" }]]);
@@ -140,6 +141,6 @@ const Sparkles = icon([
140
141
  ]);
141
142
  const Download = icon([["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }], ["path", { d: "m7 10 5 5 5-5" }], ["path", { d: "M12 15V3" }]]);
142
143
 
143
- module.exports = { Sun, Moon, Monitor, LifeBuoy, BookOpen, LogOut, Menu, Check, X, Search, ChevronDown, Fingerprint, FileStack, ShieldCheck, Hammer, Activity,
144
+ module.exports = { Sun, Moon, Monitor, LifeBuoy, BookOpen, Library, LogOut, Menu, Check, X, Search, ChevronDown, Fingerprint, FileStack, ShieldCheck, Hammer, Activity,
144
145
  Smartphone, KeyRound, Trash, Copy, Puzzle, Plus, Pencil, Link2, Alert, History, CornerDownLeft,
145
146
  Users, Settings, ScrollText, Info, RadioTower, Globe, Clock, Download, Upload, RotateCcw, Sparkles };
package/react/index.js CHANGED
@@ -243,6 +243,7 @@ const DOCS_DOMAINS = {
243
243
  rosetta: "scaliorosetta.com",
244
244
  beacon: "scaliobeacon.com",
245
245
  pulse: "scaliopulse.com",
246
+ folio: "scaliofolio.com",
246
247
  };
247
248
 
248
249
  function manualUrl(product, opts) {
@@ -378,6 +379,6 @@ module.exports = {
378
379
  TEST_IDS,
379
380
  initials,
380
381
  };
381
- Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./palette"), require("./unify"), require("./profile"), require("./actions"), require("./selftest"), require("./users"), require("./customers"), require("./roles"), require("./wizard"), require("./maintenance"), require("./backup"), require("./audit"), require("./mail"), require("./saas_updates"), require("./pages"), require("./tenant"), require("./fields"), require("./dialog"), require("./keyboard"), require("./agents"), require("./ai"));
382
+ Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./palette"), require("./unify"), require("./profile"), require("./actions"), require("./selftest"), require("./users"), require("./customers"), require("./roles"), require("./wizard"), require("./maintenance"), require("./backup"), require("./audit"), require("./mail"), require("./saas_updates"), require("./pages"), require("./tenant"), require("./fields"), require("./dialog"), require("./keyboard"), require("./agents"), require("./agent_scripts"), require("./ai"), require("./markdown"));
382
383
  // After the exports above: auth.js uses LanguageToggle and ThemeToggle from this module.
383
384
  Object.assign(module.exports, require("./auth"), require("./session"), require("./setup"), require("./clientErrors"));
package/react/labels.js CHANGED
@@ -17,6 +17,7 @@ const LABELS = {
17
17
  demoHint: "Wählen Sie ein Demo-Konto. Die Demo setzt sich jede Nacht zurück.",
18
18
  demoPassword: "Passwort",
19
19
  dialog: { ok: "OK", cancel: "Abbrechen", confirm: "Bestätigen", input: "Eingabe" },
20
+ markdown: { note: "Hinweis", tip: "Tipp", important: "Wichtig", warning: "Warnung", caution: "Vorsicht" },
20
21
  wizard: {
21
22
  step: "Schritt {n} von {total}",
22
23
  back: "Zurück",
@@ -592,6 +593,7 @@ const LABELS = {
592
593
  demoHint: "Pick a demo account. The demo resets itself every night.",
593
594
  demoPassword: "Password",
594
595
  dialog: { ok: "OK", cancel: "Cancel", confirm: "Confirm", input: "Input" },
596
+ markdown: { note: "Note", tip: "Tip", important: "Important", warning: "Warning", caution: "Caution" },
595
597
  wizard: {
596
598
  step: "Step {n} of {total}",
597
599
  back: "Back",
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+ // Markdown (GitHub flavour) for every app: parsed into plain data and shown as React elements, never as HTML, so a
3
+ // text can hold no script (Beacon knowledge base, Folio pages; scalio-docs ADR 0110 point 4). Blocks: headings,
4
+ // paragraphs, fenced code, quotes and callouts (> [!NOTE]), lists with task boxes and one level of nesting, tables,
5
+ // rules. Inline: code, bold, italic, strikethrough, links (http, https, mailto, relative; anything else stays text)
6
+ // and images (shown as a link). Styles: classes "scalio-md-*" in nav.css.
7
+ const React = require("react");
8
+ const h = React.createElement;
9
+ const Icons = require("./icons");
10
+ const { labelsFor } = require("./labels");
11
+
12
+ const CALLOUTS = ["NOTE", "TIP", "IMPORTANT", "WARNING", "CAUTION"];
13
+
14
+ function safeHref(href) {
15
+ const h = String(href || "").trim();
16
+ if (/^(https?:|mailto:)/i.test(h)) return h;
17
+ if (/^[a-z][a-z0-9+.-]*:/i.test(h)) return null; // javascript:, data:, file: ...
18
+ if (h.startsWith("//")) return null;
19
+ return h || null;
20
+ }
21
+
22
+ function splitRow(line) {
23
+ let s = line.trim();
24
+ if (s.startsWith("|")) s = s.slice(1);
25
+ if (s.endsWith("|") && !s.endsWith("\\|")) s = s.slice(0, -1);
26
+ const cells = [];
27
+ let cur = "";
28
+ for (let i = 0; i < s.length; i += 1) {
29
+ if (s[i] === "\\" && s[i + 1] === "|") { cur += "|"; i += 1; continue; }
30
+ if (s[i] === "|") { cells.push(cur.trim()); cur = ""; continue; }
31
+ cur += s[i];
32
+ }
33
+ cells.push(cur.trim());
34
+ return cells;
35
+ }
36
+
37
+ const isTableSep = (line) => /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(line) && line.includes("-");
38
+ const LIST_RE = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/;
39
+
40
+ function listItem(text) {
41
+ const task = text.match(/^\[( |x|X)\]\s+(.*)$/);
42
+ return task ? { text: task[2], task: true, checked: task[1] !== " ", children: null }
43
+ : { text, task: false, checked: false, children: null };
44
+ }
45
+
46
+ function parseBlocks(src) {
47
+ const lines = String(src || "").replace(/\r\n?/g, "\n").split("\n");
48
+ const blocks = [];
49
+ let i = 0;
50
+ while (i < lines.length) {
51
+ const line = lines[i];
52
+ if (!line.trim()) { i += 1; continue; }
53
+
54
+ const fence = line.match(/^\s*(```|~~~)\s*([\w+-]*)/);
55
+ if (fence) {
56
+ const code = [];
57
+ i += 1;
58
+ while (i < lines.length && !lines[i].trim().startsWith(fence[1])) { code.push(lines[i]); i += 1; }
59
+ i += 1;
60
+ blocks.push({ type: "code", lang: fence[2] || "", text: code.join("\n") });
61
+ continue;
62
+ }
63
+
64
+ const h = line.match(/^(#{1,6})\s+(.*?)\s*#*\s*$/);
65
+ if (h) { blocks.push({ type: "heading", level: h[1].length, text: h[2] }); i += 1; continue; }
66
+
67
+ if (/^\s*([-*_])(\s*\1){2,}\s*$/.test(line)) { blocks.push({ type: "rule" }); i += 1; continue; }
68
+
69
+ if (/^\s*>/.test(line)) {
70
+ const inner = [];
71
+ while (i < lines.length && /^\s*>/.test(lines[i])) { inner.push(lines[i].replace(/^\s*>\s?/, "")); i += 1; }
72
+ const first = (inner[0] || "").match(/^\[!(\w+)\]\s*$/);
73
+ const kind = first && CALLOUTS.includes(first[1].toUpperCase()) ? first[1].toLowerCase() : null;
74
+ blocks.push({ type: kind ? "callout" : "quote", kind, blocks: parseBlocks((kind ? inner.slice(1) : inner).join("\n")) });
75
+ continue;
76
+ }
77
+
78
+ if (line.includes("|") && i + 1 < lines.length && isTableSep(lines[i + 1])) {
79
+ const head = splitRow(line);
80
+ const align = splitRow(lines[i + 1]).map((c) => (c.startsWith(":") && c.endsWith(":") ? "center"
81
+ : c.endsWith(":") ? "right" : "left"));
82
+ const rows = [];
83
+ i += 2;
84
+ while (i < lines.length && lines[i].includes("|") && lines[i].trim()) { rows.push(splitRow(lines[i])); i += 1; }
85
+ blocks.push({ type: "table", head, align, rows: rows.map((r) => head.map((_, k) => r[k] ?? "")) });
86
+ continue;
87
+ }
88
+
89
+ const li = line.match(LIST_RE);
90
+ if (li) {
91
+ const ordered = /\d/.test(li[2]);
92
+ const start = ordered ? parseInt(li[2], 10) : 1;
93
+ const base = li[1].length;
94
+ const items = [];
95
+ while (i < lines.length) {
96
+ const m = lines[i].match(LIST_RE);
97
+ if (m && m[1].length <= base + 1) {
98
+ if (/\d/.test(m[2]) !== ordered) break;
99
+ items.push(listItem(m[3]));
100
+ i += 1;
101
+ } else if (m && items.length) { // nested list, one level
102
+ const sub = [];
103
+ const subOrdered = /\d/.test(m[2]);
104
+ while (i < lines.length) {
105
+ const n = lines[i].match(LIST_RE);
106
+ if (!n || n[1].length <= base + 1) break;
107
+ sub.push(listItem(n[3]));
108
+ i += 1;
109
+ }
110
+ items[items.length - 1].children = { ordered: subOrdered, items: sub };
111
+ } else if (lines[i].trim() && /^\s{2,}\S/.test(lines[i]) && items.length) {
112
+ items[items.length - 1].text += ` ${lines[i].trim()}`; // continuation line
113
+ i += 1;
114
+ } else break;
115
+ }
116
+ blocks.push({ type: "list", ordered, start, items });
117
+ continue;
118
+ }
119
+
120
+ const para = [];
121
+ while (i < lines.length && lines[i].trim() && !/^(#{1,6})\s/.test(lines[i]) && !/^\s*(```|~~~)/.test(lines[i])
122
+ && !/^\s*>/.test(lines[i]) && !LIST_RE.test(lines[i])
123
+ && !(lines[i].includes("|") && i + 1 < lines.length && isTableSep(lines[i + 1]))) {
124
+ para.push(lines[i].trim());
125
+ i += 1;
126
+ }
127
+ blocks.push({ type: "paragraph", text: para.join("\n") });
128
+ }
129
+ return blocks;
130
+ }
131
+
132
+ // code | image | link | bold | strike | italic | bare url
133
+ const INLINE = /(`+)([\s\S]*?[^`])\1(?!`)|!\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|\*\*([\s\S]+?)\*\*|__([\s\S]+?)__|~~([\s\S]+?)~~|\*([^*\s][^*]*?)\*|(?<![\w])_([^_\s][^_]*?)_(?![\w])|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g;
134
+
135
+ function parseInline(src) {
136
+ const out = [];
137
+ const text = String(src || "");
138
+ let last = 0;
139
+ for (const m of text.matchAll(INLINE)) {
140
+ if (m.index > last) out.push({ type: "text", text: text.slice(last, m.index) });
141
+ if (m[1]) out.push({ type: "code", text: m[2].trim() ? m[2].replace(/^ (.*) $/, "$1") : m[2] });
142
+ else if (m[4] !== undefined) {
143
+ const href = safeHref(m[4]);
144
+ out.push(href ? { type: "image", alt: m[3], href } : { type: "text", text: m[0] });
145
+ } else if (m[6] !== undefined) {
146
+ const href = safeHref(m[6]);
147
+ out.push(href ? { type: "link", href, children: parseInline(m[5]) } : { type: "text", text: m[5] });
148
+ } else if (m[7] !== undefined || m[8] !== undefined) out.push({ type: "bold", children: parseInline(m[7] ?? m[8]) });
149
+ else if (m[9] !== undefined) out.push({ type: "strike", children: parseInline(m[9]) });
150
+ else if (m[10] !== undefined || m[11] !== undefined) out.push({ type: "italic", children: parseInline(m[10] ?? m[11]) });
151
+ else if (m[12]) out.push({ type: "link", href: m[12], children: [{ type: "text", text: m[12] }] });
152
+ last = m.index + m[0].length;
153
+ }
154
+ if (last < text.length) out.push({ type: "text", text: text.slice(last) });
155
+ return out;
156
+ }
157
+
158
+ // Headings with an anchor id (for the table of contents on a page).
159
+ function headingId(text) {
160
+ return String(text || "").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-|-$/g, "") || "abschnitt";
161
+ }
162
+
163
+ function outline(src) {
164
+ return parseBlocks(src).filter((b) => b.type === "heading" && b.level <= 3)
165
+ .map((b) => ({ level: b.level, text: b.text, id: headingId(b.text) }));
166
+ }
167
+
168
+ function Inline(props) {
169
+ return h(React.Fragment, null, props.nodes.map((n, i) => {
170
+ if (n.type === "code") return h("code", { key: i, className: "scalio-md-code" }, n.text);
171
+ if (n.type === "bold") return h("strong", { key: i }, h(Inline, { nodes: n.children }));
172
+ if (n.type === "italic") return h("em", { key: i }, h(Inline, { nodes: n.children }));
173
+ if (n.type === "strike") return h("del", { key: i }, h(Inline, { nodes: n.children }));
174
+ if (n.type === "image") {
175
+ return h("a", { key: i, href: n.href, target: "_blank", rel: "noopener noreferrer", className: "scalio-md-link" }, "🖼 " + (n.alt || n.href));
176
+ }
177
+ if (n.type === "link") {
178
+ const external = /^(https?:|mailto:)/i.test(n.href);
179
+ return h("a", Object.assign({ key: i, href: n.href, className: "scalio-md-link" },
180
+ external ? { target: "_blank", rel: "noopener noreferrer" } : {}), h(Inline, { nodes: n.children }));
181
+ }
182
+ return h(React.Fragment, { key: i }, n.text);
183
+ }));
184
+ }
185
+
186
+ const inline = (text) => h(Inline, { nodes: parseInline(text) });
187
+
188
+ function List(props) {
189
+ const list = props.list;
190
+ const allTasks = list.items.every((x) => x.task);
191
+ return h(list.ordered ? "ol" : "ul", {
192
+ start: list.ordered && list.start !== 1 ? list.start : undefined,
193
+ className: "scalio-md-list" + (list.ordered ? " is-ordered" : "") + (allTasks ? " is-tasks" : ""),
194
+ }, list.items.map((it, k) => h("li", { key: k, className: it.task ? "is-task" : undefined },
195
+ it.task ? h("input", { type: "checkbox", checked: it.checked, readOnly: true, disabled: true, "aria-label": it.text }) : null,
196
+ h("span", null, inline(it.text)),
197
+ it.children ? h(List, { list: it.children }) : null)));
198
+ }
199
+
200
+ const CALLOUT_ICON = { note: "Info", tip: "Info", important: "Info", warning: "Alert", caution: "Alert" };
201
+
202
+ function Blocks(props) {
203
+ const L = props.labels;
204
+ return h(React.Fragment, null, props.blocks.map((b, i) => {
205
+ if (b.type === "heading") return h("h" + b.level, { key: i, id: headingId(b.text), className: "scalio-md-h" + b.level }, inline(b.text));
206
+ if (b.type === "code") return h("pre", { key: i, "data-lang": b.lang || undefined, className: "scalio-md-pre" }, b.text);
207
+ if (b.type === "rule") return h("hr", { key: i, className: "scalio-md-rule" });
208
+ if (b.type === "list") return h(List, { key: i, list: b });
209
+ if (b.type === "quote") return h("blockquote", { key: i, className: "scalio-md-quote" }, h(Blocks, { blocks: b.blocks, labels: L }));
210
+ if (b.type === "callout") {
211
+ const Icon = Icons[CALLOUT_ICON[b.kind]];
212
+ return h("div", { key: i, className: "scalio-md-callout", "data-callout": b.kind, "data-testid": "callout-" + b.kind },
213
+ h("div", { className: "scalio-md-callout-title" }, Icon ? h(Icon, { className: "scalio-icon" }) : null, L[b.kind]),
214
+ h(Blocks, { blocks: b.blocks, labels: L }));
215
+ }
216
+ if (b.type === "table") {
217
+ return h("div", { key: i, className: "scalio-md-table-wrap" }, h("table", { className: "scalio-md-table" },
218
+ h("thead", null, h("tr", null, b.head.map((c, k) => h("th", { key: k, style: { textAlign: b.align[k] } }, inline(c))))),
219
+ h("tbody", null, b.rows.map((r, n) => h("tr", { key: n }, r.map((c, k) => h("td", { key: k, style: { textAlign: b.align[k] } }, inline(c))))))));
220
+ }
221
+ return h("p", { key: i, className: "scalio-md-p" }, b.text.split("\n").map((line, k) =>
222
+ h(React.Fragment, { key: k }, k > 0 ? h("br") : null, inline(line))));
223
+ }));
224
+ }
225
+
226
+ // <Markdown text="..." lang="de" /> shows the text; labels.markdown overrides the callout titles.
227
+ function Markdown(props) {
228
+ const L = Object.assign({}, labelsFor(props.lang).markdown, props.labels);
229
+ return h("div", { className: "scalio-md" + (props.className ? " " + props.className : ""), "data-testid": props.testId },
230
+ h(Blocks, { blocks: parseBlocks(props.text), labels: L }));
231
+ }
232
+
233
+ module.exports = {
234
+ Markdown,
235
+ parseMarkdownBlocks: parseBlocks,
236
+ parseMarkdownInline: parseInline,
237
+ markdownOutline: outline,
238
+ markdownHeadingId: headingId,
239
+ safeHref,
240
+ };
package/react/nav.js CHANGED
@@ -312,6 +312,8 @@ const PRODUCTS = [
312
312
  { key: "citadel", name: "Citadel", icon: Icons.ShieldCheck },
313
313
  { key: "beacon", name: "Beacon", icon: Icons.RadioTower },
314
314
  { key: "pulse", name: "Pulse", icon: Icons.Activity },
315
+ { key: "folio", name: "Folio", icon: Icons.Library },
316
+ { key: "atrium", name: "Atrium", icon: Icons.Monitor },
315
317
  ];
316
318
 
317
319
  function productStatus(product, current) {