@volter-ai-dev/supercode-ui 0.1.71 → 0.1.73

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.
Files changed (38) hide show
  1. package/README.md +24 -0
  2. package/activity.mjs +2 -2
  3. package/chunks/{chunk-O7Q2PELK.mjs → chunk-2FG7VKIW.mjs} +1 -1
  4. package/chunks/{chunk-XD2WJYSL.mjs → chunk-4XUMCWPC.mjs} +1 -1
  5. package/chunks/{chunk-LQMYNJPU.mjs → chunk-E65I2I2L.mjs} +1 -1
  6. package/chunks/{chunk-OW42DS6P.mjs → chunk-IL5T2AST.mjs} +4 -4
  7. package/chunks/{chunk-ATCOWFRV.mjs → chunk-TKTOVDXB.mjs} +40 -6
  8. package/chunks/{chunk-SSYNT434.mjs → chunk-WRK5TBX3.mjs} +1 -1
  9. package/components.mjs +6 -6
  10. package/embed.mjs +5 -5
  11. package/logo.mjs +1 -1
  12. package/messenger.mjs +5 -5
  13. package/package.json +21 -3
  14. package/react/activity.mjs +2 -2
  15. package/react/chunks/{chunk-ZM5X5LOF.mjs → chunk-LYRIQE5M.mjs} +1 -1
  16. package/react/chunks/{chunk-ZXD7NZXI.mjs → chunk-NJC6S2AW.mjs} +1 -1
  17. package/react/chunks/{chunk-2RIHDJT6.mjs → chunk-QL6QEYPK.mjs} +4 -4
  18. package/react/chunks/{chunk-TQHX2DQG.mjs → chunk-UGL6AB2K.mjs} +1 -1
  19. package/react/chunks/{chunk-GV5KV5UY.mjs → chunk-VFOVJ4S3.mjs} +40 -6
  20. package/react/chunks/{chunk-GYQOTTZ5.mjs → chunk-YK7SJ6EH.mjs} +1 -1
  21. package/react/components.mjs +6 -6
  22. package/react/logo.mjs +1 -1
  23. package/react/messenger.mjs +5 -5
  24. package/react/sessions.mjs +2 -2
  25. package/react/settings.mjs +2 -2
  26. package/react/subagents.mjs +2 -2
  27. package/react/supervision-components.mjs +1354 -0
  28. package/react/supervision.d.ts +36 -0
  29. package/sessions.mjs +2 -2
  30. package/settings.mjs +2 -2
  31. package/source-inventory.d.ts +240 -0
  32. package/source-inventory.mjs +367 -0
  33. package/styles.css +92 -0
  34. package/subagents.mjs +2 -2
  35. package/supervision-components.d.ts +36 -0
  36. package/supervision-components.mjs +1354 -0
  37. package/supervision.d.ts +242 -0
  38. package/supervision.mjs +349 -0
@@ -0,0 +1,1354 @@
1
+ // src/supervision.jsx
2
+ import { useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState2 } from "react";
3
+
4
+ // src/source-inventory.jsx
5
+ import { useEffect, useLayoutEffect, useRef, useState } from "react";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ var unknown = (value) => value == null ? "unknown" : String(value);
8
+ var yes = (value, positive, negative, absent) => value == null ? absent : value ? positive : negative;
9
+ function Facts({ entries }) {
10
+ return /* @__PURE__ */ jsx("dl", { children: entries.map(([name, value]) => /* @__PURE__ */ jsxs("div", { children: [
11
+ /* @__PURE__ */ jsx("dt", { children: name }),
12
+ /* @__PURE__ */ jsx("dd", { children: unknown(value) })
13
+ ] }, name)) });
14
+ }
15
+ function Rows({ items, children }) {
16
+ return /* @__PURE__ */ jsx("div", { className: "scui-inventory-rows", children: items.map((item) => /* @__PURE__ */ jsx("article", { children: children(item) }, item.key)) });
17
+ }
18
+ function Open({ label: label2, item, onOpen }) {
19
+ return onOpen ? /* @__PURE__ */ jsx(
20
+ "button",
21
+ {
22
+ type: "button",
23
+ onClick: (event) => onOpen(item.key, event.currentTarget),
24
+ "aria-label": label2,
25
+ children: item.name || item.subject
26
+ }
27
+ ) : /* @__PURE__ */ jsx("strong", { children: item.name || item.subject });
28
+ }
29
+ function ProfileList({ profiles = [], onOpen }) {
30
+ return /* @__PURE__ */ jsx(Rows, { items: profiles, children: (item) => /* @__PURE__ */ jsxs(Fragment, { children: [
31
+ /* @__PURE__ */ jsx(
32
+ Open,
33
+ {
34
+ item,
35
+ label: `Inspect profile ${item.name}`,
36
+ onOpen
37
+ }
38
+ ),
39
+ /* @__PURE__ */ jsxs("p", { children: [
40
+ item.harness,
41
+ " \xB7 ",
42
+ item.kind.replaceAll("_", " "),
43
+ item.isDefault ? " \xB7 Default" : ""
44
+ ] }),
45
+ /* @__PURE__ */ jsxs("p", { children: [
46
+ item.model || "Model unknown",
47
+ " \xB7 Sessions ",
48
+ unknown(item.sessions)
49
+ ] })
50
+ ] }) });
51
+ }
52
+ function ProfileDetails({ profile }) {
53
+ return /* @__PURE__ */ jsxs("section", { children: [
54
+ /* @__PURE__ */ jsx("h2", { children: profile.name }),
55
+ /* @__PURE__ */ jsxs("p", { children: [
56
+ profile.harness,
57
+ " \xB7 ",
58
+ profile.kind.replaceAll("_", " ")
59
+ ] }),
60
+ /* @__PURE__ */ jsx(
61
+ Facts,
62
+ {
63
+ entries: [
64
+ ["Model", profile.model],
65
+ ["Default", profile.isDefault ? "Yes" : "No"],
66
+ ["Routes", profile.routes]
67
+ ]
68
+ }
69
+ ),
70
+ /* @__PURE__ */ jsxs("p", { children: [
71
+ "Sessions ",
72
+ unknown(profile.sessions)
73
+ ] }),
74
+ /* @__PURE__ */ jsx("p", { className: "scui-domain-footnote", children: "Read-only native profile. Counts describe the source observation." })
75
+ ] });
76
+ }
77
+ function ChannelList({ channels = [] }) {
78
+ return /* @__PURE__ */ jsx(Rows, { items: channels, children: (item) => /* @__PURE__ */ jsxs(Fragment, { children: [
79
+ /* @__PURE__ */ jsx("h2", { children: item.name }),
80
+ /* @__PURE__ */ jsxs("p", { children: [
81
+ item.harness,
82
+ " \xB7 ",
83
+ item.account || "Account unknown"
84
+ ] }),
85
+ /* @__PURE__ */ jsx("p", { children: yes(
86
+ item.configured,
87
+ "Configured",
88
+ "Not configured",
89
+ "Configuration unknown"
90
+ ) }),
91
+ /* @__PURE__ */ jsx("p", { children: yes(item.enabled, "Enabled", "Disabled", "Enablement unknown") }),
92
+ /* @__PURE__ */ jsxs("p", { children: [
93
+ "Connection ",
94
+ item.connection
95
+ ] }),
96
+ /* @__PURE__ */ jsxs("p", { children: [
97
+ "Sessions ",
98
+ unknown(item.sessions)
99
+ ] })
100
+ ] }) });
101
+ }
102
+ function ProfileTarget({ item, profiles, onOpenProfile }) {
103
+ const target = profiles.find((profile) => profile.key === item.profileKey);
104
+ return target && onOpenProfile ? /* @__PURE__ */ jsxs(
105
+ "button",
106
+ {
107
+ type: "button",
108
+ onClick: (event) => onOpenProfile(target.key, event.currentTarget),
109
+ children: [
110
+ "Inspect profile ",
111
+ target.name
112
+ ]
113
+ }
114
+ ) : /* @__PURE__ */ jsxs("p", { children: [
115
+ "Target: ",
116
+ item.target || item.profile || "unknown",
117
+ " \xB7",
118
+ " ",
119
+ target ? "Profile observed" : "Profile unavailable in this observation"
120
+ ] });
121
+ }
122
+ function RouteList({ routes = [], profiles = [], onOpenProfile }) {
123
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
124
+ /* @__PURE__ */ jsx("p", { children: "Native order retained. Higher specificity wins; equal ranks retain source order." }),
125
+ /* @__PURE__ */ jsx(Rows, { items: routes, children: (item) => /* @__PURE__ */ jsxs(Fragment, { children: [
126
+ /* @__PURE__ */ jsx("h2", { children: item.target || "Unknown target" }),
127
+ /* @__PURE__ */ jsxs("p", { children: [
128
+ item.harness,
129
+ " \xB7 Specificity ",
130
+ unknown(item.specificity),
131
+ item.isDefault ? " \xB7 Default route" : ""
132
+ ] }),
133
+ Object.keys(item.match).length ? /* @__PURE__ */ jsx(Facts, { entries: Object.entries(item.match) }) : /* @__PURE__ */ jsx("p", { children: "No match constraints recorded." }),
134
+ /* @__PURE__ */ jsx(
135
+ ProfileTarget,
136
+ {
137
+ item,
138
+ profiles,
139
+ onOpenProfile
140
+ }
141
+ )
142
+ ] }) })
143
+ ] });
144
+ }
145
+ function TriggerList({ triggers = [], profiles = [], onOpenProfile }) {
146
+ return /* @__PURE__ */ jsx(Rows, { items: triggers, children: (item) => /* @__PURE__ */ jsxs(Fragment, { children: [
147
+ /* @__PURE__ */ jsx("h2", { children: item.name }),
148
+ /* @__PURE__ */ jsxs("p", { children: [
149
+ item.harness,
150
+ " \xB7 ",
151
+ item.kind.replaceAll("_", " ")
152
+ ] }),
153
+ /* @__PURE__ */ jsx("p", { children: item.description }),
154
+ /* @__PURE__ */ jsx(
155
+ Facts,
156
+ {
157
+ entries: [
158
+ ["Route", item.route],
159
+ ["Events", item.events.join(", ") || "unknown"],
160
+ ["Action", item.action],
161
+ ["Session target", item.session],
162
+ ["Delivery destination", item.destination]
163
+ ]
164
+ }
165
+ ),
166
+ /* @__PURE__ */ jsxs("p", { children: [
167
+ yes(item.enabled, "Enabled", "Disabled", "Enablement unknown"),
168
+ " \xB7",
169
+ " ",
170
+ yes(
171
+ item.authenticated,
172
+ "Authentication configured",
173
+ "Authentication not configured",
174
+ "Authentication unknown"
175
+ )
176
+ ] }),
177
+ /* @__PURE__ */ jsx(
178
+ ProfileTarget,
179
+ {
180
+ item,
181
+ profiles,
182
+ onOpenProfile
183
+ }
184
+ )
185
+ ] }) });
186
+ }
187
+ function SkillList({ skills = [], onOpen }) {
188
+ return /* @__PURE__ */ jsx(Rows, { items: skills, children: (item) => /* @__PURE__ */ jsxs(Fragment, { children: [
189
+ /* @__PURE__ */ jsx(
190
+ Open,
191
+ {
192
+ item,
193
+ label: `Inspect skill ${item.name}`,
194
+ onOpen
195
+ }
196
+ ),
197
+ /* @__PURE__ */ jsxs("p", { children: [
198
+ item.harness,
199
+ " \xB7 ",
200
+ item.scope
201
+ ] }),
202
+ /* @__PURE__ */ jsx("p", { children: item.description || "No description supplied." })
203
+ ] }) });
204
+ }
205
+ function SkillDetails({ skill }) {
206
+ return /* @__PURE__ */ jsxs("section", { children: [
207
+ /* @__PURE__ */ jsx("h2", { children: skill.name }),
208
+ /* @__PURE__ */ jsxs("p", { children: [
209
+ skill.harness,
210
+ " \xB7 ",
211
+ skill.scope
212
+ ] }),
213
+ /* @__PURE__ */ jsx("p", { children: skill.description || "No description supplied." }),
214
+ /* @__PURE__ */ jsxs("p", { children: [
215
+ "Version ",
216
+ skill.version || "unknown"
217
+ ] }),
218
+ /* @__PURE__ */ jsx("p", { children: yes(skill.enabled, "Enabled", "Disabled", "Enablement unknown") }),
219
+ /* @__PURE__ */ jsx("p", { className: "scui-domain-footnote", children: "This reader supplies package metadata. Full documentation and installation actions require a separate host capability." })
220
+ ] });
221
+ }
222
+ function MemoryBrowser({ documents = [], onSearch }) {
223
+ const [query, setQuery] = useState(""), [result, setResult] = useState(null), [busy, setBusy] = useState(false), [error, setError] = useState("");
224
+ const request = useRef(0);
225
+ useEffect(
226
+ () => () => {
227
+ request.current++;
228
+ },
229
+ []
230
+ );
231
+ const search = async (event) => {
232
+ event.preventDefault();
233
+ if (!onSearch || !query.trim() || busy) return;
234
+ const id = ++request.current;
235
+ setBusy(true);
236
+ setError("");
237
+ setResult(null);
238
+ try {
239
+ const value = await onSearch(query);
240
+ if (id === request.current) setResult(value);
241
+ } catch (err) {
242
+ if (id === request.current) setError(err.message || "Search failed.");
243
+ } finally {
244
+ if (id === request.current) setBusy(false);
245
+ }
246
+ };
247
+ return /* @__PURE__ */ jsxs("section", { "aria-label": "Memory documents", children: [
248
+ onSearch && /* @__PURE__ */ jsxs("form", { className: "scui-inventory-memory-search", onSubmit: search, children: [
249
+ /* @__PURE__ */ jsxs("label", { children: [
250
+ "Search native memory",
251
+ /* @__PURE__ */ jsx(
252
+ "input",
253
+ {
254
+ type: "search",
255
+ value: query,
256
+ maxLength: 200,
257
+ onInput: (e) => setQuery(e.currentTarget.value)
258
+ }
259
+ )
260
+ ] }),
261
+ /* @__PURE__ */ jsx("button", { type: "submit", disabled: busy || !query.trim(), children: busy ? "Searching\u2026" : "Search memory" }),
262
+ /* @__PURE__ */ jsx(
263
+ "button",
264
+ {
265
+ type: "button",
266
+ onClick: () => {
267
+ request.current++;
268
+ setBusy(false);
269
+ setResult(null);
270
+ setError("");
271
+ setQuery("");
272
+ },
273
+ children: "Clear search"
274
+ }
275
+ )
276
+ ] }),
277
+ error && /* @__PURE__ */ jsx("p", { role: "alert", children: error }),
278
+ busy && /* @__PURE__ */ jsx("p", { role: "status", children: "Searching this source\u2026" }),
279
+ result ? /* @__PURE__ */ jsxs(Fragment, { children: [
280
+ /* @__PURE__ */ jsxs("p", { role: "status", children: [
281
+ result.matches.length,
282
+ " of ",
283
+ result.total,
284
+ " matching lines"
285
+ ] }),
286
+ /* @__PURE__ */ jsx(Rows, { items: result.matches, children: (item) => /* @__PURE__ */ jsxs(Fragment, { children: [
287
+ /* @__PURE__ */ jsxs("h2", { children: [
288
+ item.name,
289
+ " \xB7 line ",
290
+ unknown(item.line)
291
+ ] }),
292
+ /* @__PURE__ */ jsxs("p", { children: [
293
+ item.harness,
294
+ " \xB7 ",
295
+ item.scope,
296
+ item.profile ? ` \xB7 ${item.profile}` : ""
297
+ ] }),
298
+ /* @__PURE__ */ jsx("pre", { tabIndex: 0, "aria-label": "Matching memory text", children: item.excerpt })
299
+ ] }) })
300
+ ] }) : /* @__PURE__ */ jsx(Rows, { items: documents, children: (item) => /* @__PURE__ */ jsxs(Fragment, { children: [
301
+ /* @__PURE__ */ jsx("h2", { children: item.name }),
302
+ /* @__PURE__ */ jsxs("p", { children: [
303
+ item.harness,
304
+ " \xB7 ",
305
+ item.scope,
306
+ item.profile ? ` \xB7 ${item.profile}` : ""
307
+ ] }),
308
+ /* @__PURE__ */ jsxs("p", { children: [
309
+ unknown(item.size),
310
+ " bytes \xB7 Updated",
311
+ " ",
312
+ item.updatedAt || "unknown"
313
+ ] }),
314
+ /* @__PURE__ */ jsx("pre", { tabIndex: 0, "aria-label": "Memory preview", children: item.preview || "No preview supplied." }),
315
+ item.truncated && /* @__PURE__ */ jsx("p", { className: "scui-domain-footnote", children: "Preview only. More content exists in the native document." })
316
+ ] }) })
317
+ ] });
318
+ }
319
+ var titles = {
320
+ profiles: "Profiles",
321
+ channels: "Channels",
322
+ routes: "Routes",
323
+ triggers: "Triggers",
324
+ skills: "Skills",
325
+ memory: "Memory"
326
+ };
327
+ function SourceInspector({
328
+ inventory,
329
+ initialSection = "profiles",
330
+ section: controlledSection,
331
+ selectedKey: controlledKey,
332
+ onNavigate,
333
+ onSearchMemory
334
+ }) {
335
+ const [localSection, setSection] = useState(initialSection), [localKey, setKey] = useState(null), [queries, setQueries] = useState({});
336
+ const section = controlledSection || localSection, selected = controlledKey === void 0 ? localKey : controlledKey;
337
+ const opener = useRef(null), root = useRef(null), detail = useRef(null);
338
+ const current = inventory[section] || {
339
+ status: "unavailable",
340
+ items: [],
341
+ total: 0
342
+ };
343
+ const query = queries[section] || "";
344
+ const items = current.items.filter(
345
+ (item) => `${item.name || item.target || ""} ${item.harness || ""} ${item.description || ""} ${Object.values(item.match || {}).join(" ")}`.toLowerCase().includes(query.toLowerCase())
346
+ );
347
+ const chosen = current.items.find((item) => item.key === selected);
348
+ const navigate = (nextSection, key, element) => {
349
+ if (element) opener.current = element;
350
+ setSection(nextSection);
351
+ setKey(key);
352
+ onNavigate?.(nextSection, key);
353
+ };
354
+ const close = () => {
355
+ navigate(section, null);
356
+ requestAnimationFrame(
357
+ () => (opener.current?.isConnected ? opener.current : root.current)?.focus()
358
+ );
359
+ };
360
+ useLayoutEffect(() => {
361
+ if (selected) detail.current?.focus();
362
+ }, [section, selected]);
363
+ const target = (key, element) => navigate("profiles", key, element);
364
+ const collection = {
365
+ profiles: /* @__PURE__ */ jsx(
366
+ ProfileList,
367
+ {
368
+ profiles: items,
369
+ onOpen: (key, el) => navigate(section, key, el)
370
+ }
371
+ ),
372
+ channels: /* @__PURE__ */ jsx(ChannelList, { channels: items }),
373
+ routes: /* @__PURE__ */ jsx(
374
+ RouteList,
375
+ {
376
+ routes: items,
377
+ profiles: inventory.profiles.items,
378
+ onOpenProfile: target
379
+ }
380
+ ),
381
+ triggers: /* @__PURE__ */ jsx(
382
+ TriggerList,
383
+ {
384
+ triggers: items,
385
+ profiles: inventory.profiles.items,
386
+ onOpenProfile: target
387
+ }
388
+ ),
389
+ skills: /* @__PURE__ */ jsx(
390
+ SkillList,
391
+ {
392
+ skills: items,
393
+ onOpen: (key, el) => navigate(section, key, el)
394
+ }
395
+ ),
396
+ memory: /* @__PURE__ */ jsx(
397
+ MemoryBrowser,
398
+ {
399
+ documents: items,
400
+ onSearch: onSearchMemory
401
+ },
402
+ inventory.source
403
+ )
404
+ }[section];
405
+ return /* @__PURE__ */ jsxs(
406
+ "section",
407
+ {
408
+ className: "scui-root scui-domain scui-source-inspector",
409
+ ref: root,
410
+ tabIndex: -1,
411
+ "aria-label": "Source inspector",
412
+ onKeyDown: (event) => {
413
+ if (event.key === "Escape" && selected) {
414
+ event.stopPropagation();
415
+ close();
416
+ }
417
+ },
418
+ children: [
419
+ /* @__PURE__ */ jsx("header", { className: "scui-domain-header", children: /* @__PURE__ */ jsxs("div", { children: [
420
+ /* @__PURE__ */ jsxs("span", { className: "scui-domain-eyebrow", children: [
421
+ "Source / ",
422
+ inventory.source
423
+ ] }),
424
+ /* @__PURE__ */ jsx("h1", { children: "Source configuration" }),
425
+ /* @__PURE__ */ jsx("p", { children: "Native observations \xB7 Read only" })
426
+ ] }) }),
427
+ /* @__PURE__ */ jsx("nav", { className: "scui-inventory-nav", "aria-label": "Source sections", children: Object.entries(titles).map(([id, title]) => /* @__PURE__ */ jsx(
428
+ "button",
429
+ {
430
+ type: "button",
431
+ "aria-current": section === id ? "page" : void 0,
432
+ onClick: () => navigate(id, null),
433
+ children: title
434
+ },
435
+ id
436
+ )) }),
437
+ /* @__PURE__ */ jsxs("div", { className: "scui-domain-toolbar", children: [
438
+ /* @__PURE__ */ jsxs("label", { className: "scui-domain-search", children: [
439
+ "Filter ",
440
+ titles[section]?.toLowerCase(),
441
+ /* @__PURE__ */ jsx(
442
+ "input",
443
+ {
444
+ type: "search",
445
+ value: query,
446
+ onInput: (event) => setQueries({ ...queries, [section]: event.currentTarget.value })
447
+ }
448
+ )
449
+ ] }),
450
+ /* @__PURE__ */ jsxs("p", { children: [
451
+ current.items.length,
452
+ " of ",
453
+ current.total,
454
+ " observed"
455
+ ] })
456
+ ] }),
457
+ current.status !== "ready" && /* @__PURE__ */ jsx(
458
+ "p",
459
+ {
460
+ className: "scui-domain-banner",
461
+ role: current.status === "error" ? "alert" : "status",
462
+ children: current.status === "loading" ? `Loading ${section}\u2026` : current.error || `This source does not supply ${section}.`
463
+ }
464
+ ),
465
+ /* @__PURE__ */ jsxs(
466
+ "div",
467
+ {
468
+ className: `scui-domain-workspace ${selected ? "scui-domain-has-detail" : ""}`,
469
+ children: [
470
+ /* @__PURE__ */ jsx("div", { className: "scui-domain-collection", children: current.status === "ready" && !items.length ? /* @__PURE__ */ jsx("p", { role: "status", children: current.items.length ? "No matching items." : `No ${section} observed.` }) : collection }),
471
+ selected && /* @__PURE__ */ jsxs("div", { className: "scui-domain-detail", ref: detail, tabIndex: -1, children: [
472
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: close, children: "Close details" }),
473
+ !chosen ? /* @__PURE__ */ jsx("p", { role: "status", children: "This item is unavailable in the current observation." }) : section === "profiles" ? /* @__PURE__ */ jsx(ProfileDetails, { profile: chosen }) : section === "skills" ? /* @__PURE__ */ jsx(SkillDetails, { skill: chosen }) : null
474
+ ] })
475
+ ]
476
+ }
477
+ )
478
+ ]
479
+ }
480
+ );
481
+ }
482
+ function ApprovalDetails({ approval, onResolve }) {
483
+ const [state, setState] = useState(""), [error, setError] = useState("");
484
+ const generation = useRef(0), pending = useRef(false);
485
+ useLayoutEffect(() => {
486
+ generation.current++;
487
+ pending.current = false;
488
+ setState("");
489
+ setError("");
490
+ return () => {
491
+ generation.current++;
492
+ };
493
+ }, [approval.key]);
494
+ const resolve = async (option) => {
495
+ if (!onResolve || pending.current || approval.status !== "pending") return;
496
+ const id = generation.current;
497
+ pending.current = true;
498
+ setState("pending");
499
+ setError("");
500
+ try {
501
+ const result = await onResolve(approval.key, option.id);
502
+ if (id !== generation.current) return;
503
+ if (!result?.resolved || result.key !== approval.key || result.optionId !== option.id)
504
+ throw new Error("The source did not confirm this decision.");
505
+ setState("confirmed");
506
+ } catch (err) {
507
+ if (id === generation.current) {
508
+ pending.current = false;
509
+ setState("");
510
+ setError(err.message || "Decision refused.");
511
+ }
512
+ }
513
+ };
514
+ return /* @__PURE__ */ jsxs("section", { children: [
515
+ /* @__PURE__ */ jsx("h2", { children: approval.subject }),
516
+ /* @__PURE__ */ jsx(
517
+ Facts,
518
+ {
519
+ entries: [
520
+ ["Harness", approval.harness],
521
+ ["Kind", approval.kind],
522
+ ["Native request", approval.id],
523
+ ["Session", approval.session],
524
+ ["Runtime", approval.runtime],
525
+ ["Observed status", approval.status]
526
+ ]
527
+ }
528
+ ),
529
+ /* @__PURE__ */ jsx("p", { children: "Each choice applies to this native request. No broader access policy is implied." }),
530
+ approval.status === "pending" && approval.options.length && onResolve ? /* @__PURE__ */ jsx("div", { className: "scui-inventory-actions", children: approval.options.map((option) => /* @__PURE__ */ jsx(
531
+ "button",
532
+ {
533
+ type: "button",
534
+ disabled: state === "pending" || state === "confirmed",
535
+ onClick: () => resolve(option),
536
+ children: option.label
537
+ },
538
+ option.id
539
+ )) }) : /* @__PURE__ */ jsx("p", { children: "Decisions unavailable through this host." }),
540
+ state && /* @__PURE__ */ jsx("p", { role: "status", children: state === "pending" ? "Awaiting source confirmation\u2026" : "Decision confirmed" }),
541
+ error && /* @__PURE__ */ jsx("p", { role: "alert", children: error })
542
+ ] });
543
+ }
544
+ function ApprovalInbox({ approvals = [], onResolve, status = "ready" }) {
545
+ const [selected, setSelected] = useState(null);
546
+ const opener = useRef(null), detail = useRef(null);
547
+ const approval = approvals.find((item) => item.key === selected);
548
+ useLayoutEffect(() => {
549
+ if (selected) detail.current?.focus();
550
+ }, [selected]);
551
+ const close = () => {
552
+ setSelected(null);
553
+ requestAnimationFrame(() => opener.current?.focus());
554
+ };
555
+ return /* @__PURE__ */ jsxs(
556
+ "section",
557
+ {
558
+ className: "scui-root scui-domain",
559
+ "aria-label": "Approval inbox",
560
+ onKeyDown: (event) => {
561
+ if (event.key === "Escape" && selected) close();
562
+ },
563
+ children: [
564
+ /* @__PURE__ */ jsx("header", { className: "scui-domain-header", children: /* @__PURE__ */ jsx("h1", { children: "Native requests" }) }),
565
+ status !== "ready" ? /* @__PURE__ */ jsxs("p", { role: status === "error" ? "alert" : "status", children: [
566
+ "Requests ",
567
+ status,
568
+ ". Refresh through the owning host."
569
+ ] }) : !approvals.length ? /* @__PURE__ */ jsx("p", { role: "status", children: "No requests observed in this connection." }) : null,
570
+ /* @__PURE__ */ jsxs(
571
+ "div",
572
+ {
573
+ className: `scui-domain-workspace ${selected ? "scui-domain-has-detail" : ""}`,
574
+ children: [
575
+ /* @__PURE__ */ jsx("div", { className: "scui-domain-collection", children: /* @__PURE__ */ jsx(Rows, { items: approvals, children: (item) => /* @__PURE__ */ jsxs(Fragment, { children: [
576
+ /* @__PURE__ */ jsx(
577
+ Open,
578
+ {
579
+ item,
580
+ label: `Inspect request ${item.subject}`,
581
+ onOpen: (key, el) => {
582
+ opener.current = el;
583
+ setSelected(key);
584
+ }
585
+ }
586
+ ),
587
+ /* @__PURE__ */ jsxs("p", { children: [
588
+ item.harness,
589
+ " \xB7 ",
590
+ item.status,
591
+ " \xB7 ",
592
+ item.kind
593
+ ] })
594
+ ] }) }) }),
595
+ selected && /* @__PURE__ */ jsxs("div", { className: "scui-domain-detail", ref: detail, tabIndex: -1, children: [
596
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: close, children: "Close request" }),
597
+ approval ? /* @__PURE__ */ jsx(
598
+ ApprovalDetails,
599
+ {
600
+ approval,
601
+ onResolve: status === "ready" ? onResolve : void 0
602
+ }
603
+ ) : /* @__PURE__ */ jsx("p", { role: "status", children: "This request is no longer in the observation." })
604
+ ] })
605
+ ]
606
+ }
607
+ )
608
+ ]
609
+ }
610
+ );
611
+ }
612
+ function AdapterStatus({ adapters = [] }) {
613
+ return /* @__PURE__ */ jsxs("section", { children: [
614
+ /* @__PURE__ */ jsx("h2", { children: "Adapters" }),
615
+ !adapters.length ? /* @__PURE__ */ jsx("p", { children: "No adapter observations supplied." }) : /* @__PURE__ */ jsx(Rows, { items: adapters.map((item) => ({ ...item, key: item.name })), children: (item) => /* @__PURE__ */ jsxs(Fragment, { children: [
616
+ /* @__PURE__ */ jsx("h3", { children: item.name }),
617
+ /* @__PURE__ */ jsxs("p", { children: [
618
+ "Connection ",
619
+ item.state
620
+ ] }),
621
+ /* @__PURE__ */ jsxs("p", { children: [
622
+ "Recorded failures: ",
623
+ unknown(item.failures)
624
+ ] }),
625
+ item.retryAt && /* @__PURE__ */ jsxs("p", { children: [
626
+ "Breaker until ",
627
+ item.retryAt
628
+ ] })
629
+ ] }) })
630
+ ] });
631
+ }
632
+ function OrchestrationOverview({ model }) {
633
+ return /* @__PURE__ */ jsxs("section", { className: "scui-root scui-domain", children: [
634
+ /* @__PURE__ */ jsx("header", { className: "scui-domain-header", children: /* @__PURE__ */ jsxs("div", { children: [
635
+ /* @__PURE__ */ jsx("h1", { children: "Runtime observation" }),
636
+ /* @__PURE__ */ jsxs("p", { children: [
637
+ model.source,
638
+ " \xB7 Runtime clock ",
639
+ model.observedAt || "unknown"
640
+ ] })
641
+ ] }) }),
642
+ /* @__PURE__ */ jsx("div", { className: "scui-domain-collection", children: model.status !== "ready" ? /* @__PURE__ */ jsx("p", { role: "status", children: "Runtime observation unavailable. Configuration does not establish live health." }) : /* @__PURE__ */ jsxs(Fragment, { children: [
643
+ /* @__PURE__ */ jsx(
644
+ Facts,
645
+ {
646
+ entries: [
647
+ ["Active turns", model.activeTurns],
648
+ ["Leases", model.leases],
649
+ ["Queued messages", model.queuedMessages],
650
+ ["Pending requests", model.pendingRequests]
651
+ ]
652
+ }
653
+ ),
654
+ /* @__PURE__ */ jsx(AdapterStatus, { adapters: model.adapters }),
655
+ /* @__PURE__ */ jsx("p", { className: "scui-domain-footnote", children: "One supplied runtime observation. No aggregate fleet-health or delivery-backlog claim." })
656
+ ] }) })
657
+ ] });
658
+ }
659
+
660
+ // src/supervision.jsx
661
+ import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
662
+ var label = (value) => String(value || "unknown").replaceAll("_", " ");
663
+ var good = (value) => ["completed", "ok", "delivered", "approved"].includes(value);
664
+ var bad = (value) => ["failed", "error", "abandoned", "changes_requested"].includes(value);
665
+ function JobControls({ job, stale = false, onControl }) {
666
+ const [pending, setPending] = useState2(null);
667
+ const [message, setMessage] = useState2("");
668
+ const [confirmDelete, setConfirmDelete] = useState2(false);
669
+ const generation = useRef2(0);
670
+ useLayoutEffect2(() => {
671
+ ++generation.current;
672
+ setPending(null);
673
+ setMessage("");
674
+ setConfirmDelete(false);
675
+ return () => {
676
+ ++generation.current;
677
+ };
678
+ }, [job.key]);
679
+ if (!onControl || !(job.canResume || job.canRun || job.canDelete)) return null;
680
+ const act = async (action) => {
681
+ const version = generation.current;
682
+ setPending(action);
683
+ setMessage("");
684
+ try {
685
+ const result = await onControl(action, job.key);
686
+ if (version !== generation.current) return;
687
+ if (result?.confirmed !== true || result.key !== job.key || result.action !== action || action === "delete" && result.deleted !== true || action === "run" && result.requested !== true) throw new Error("Unconfirmed control");
688
+ setMessage(action === "run" ? "Run requested. Check run history for execution and delivery." : action === "resume" ? "Schedule resumed." : "Schedule deleted.");
689
+ setConfirmDelete(false);
690
+ } catch {
691
+ if (version === generation.current) setMessage("The source did not confirm this action. Refresh before trying again.");
692
+ } finally {
693
+ if (version === generation.current) setPending(null);
694
+ }
695
+ };
696
+ return /* @__PURE__ */ jsxs2("section", { className: "scui-root scui-domain scui-inventory-actions", "aria-label": "Job controls", children: [
697
+ job.canResume && /* @__PURE__ */ jsx2("button", { type: "button", disabled: stale || !!pending, onClick: () => act("resume"), children: "Resume schedule" }),
698
+ job.canRun && /* @__PURE__ */ jsx2("button", { type: "button", disabled: stale || !!pending, onClick: () => act("run"), children: "Run now" }),
699
+ job.canDelete && /* @__PURE__ */ jsx2("button", { type: "button", disabled: stale || !!pending, onClick: () => setConfirmDelete(true), children: "Delete schedule" }),
700
+ confirmDelete && /* @__PURE__ */ jsxs2("span", { children: [
701
+ "Delete this schedule? ",
702
+ /* @__PURE__ */ jsx2("button", { type: "button", disabled: stale || !!pending, onClick: () => act("delete"), children: "Confirm deletion" }),
703
+ " ",
704
+ /* @__PURE__ */ jsx2("button", { type: "button", disabled: !!pending, onClick: () => setConfirmDelete(false), children: "Cancel" })
705
+ ] }),
706
+ pending && /* @__PURE__ */ jsx2("p", { role: "status", children: "Waiting for the source to confirm\u2026" }),
707
+ message && /* @__PURE__ */ jsx2("p", { role: "status", children: message })
708
+ ] });
709
+ }
710
+ function Badge({ value }) {
711
+ return /* @__PURE__ */ jsx2(
712
+ "span",
713
+ {
714
+ className: `scui-domain-badge ${good(value) ? "scui-domain-positive" : bad(value) ? "scui-domain-danger" : ""}`,
715
+ children: label(value)
716
+ }
717
+ );
718
+ }
719
+ function Notice({ status, count, noun }) {
720
+ return status === "loading" ? /* @__PURE__ */ jsxs2("p", { role: "status", children: [
721
+ "Loading ",
722
+ noun,
723
+ "\u2026"
724
+ ] }) : status === "error" ? /* @__PURE__ */ jsxs2("p", { role: "alert", children: [
725
+ "Could not read ",
726
+ noun,
727
+ ". Contents are unknown; refresh to retry."
728
+ ] }) : count === 0 ? /* @__PURE__ */ jsxs2("p", { role: "status", children: [
729
+ "No ",
730
+ noun,
731
+ " found."
732
+ ] }) : null;
733
+ }
734
+ function HandoffCard({ attempt }) {
735
+ if (!attempt.summary && !attempt.evidence) return /* @__PURE__ */ jsx2("p", { children: "No handoff supplied." });
736
+ return /* @__PURE__ */ jsxs2("details", { children: [
737
+ /* @__PURE__ */ jsx2("summary", { children: "Read handoff and evidence" }),
738
+ /* @__PURE__ */ jsx2("p", { children: attempt.summary || "No handoff summary supplied." }),
739
+ attempt.evidence && /* @__PURE__ */ jsx2("pre", { tabIndex: 0, "aria-label": "Handoff evidence", children: attempt.evidence })
740
+ ] });
741
+ }
742
+ function ReviewCard({ review }) {
743
+ return /* @__PURE__ */ jsxs2("article", { className: "scui-domain-callout", children: [
744
+ /* @__PURE__ */ jsx2("h3", { children: label(review.verdict) }),
745
+ /* @__PURE__ */ jsxs2("p", { children: [
746
+ review.by || "Unknown reviewer",
747
+ review.at ? ` \xB7 ${review.at}` : ""
748
+ ] }),
749
+ /* @__PURE__ */ jsx2("p", { children: review.reason || "No review reason supplied." })
750
+ ] });
751
+ }
752
+ function TaskThread({ comments = [] }) {
753
+ return /* @__PURE__ */ jsxs2("section", { "aria-label": "Task discussion", children: [
754
+ /* @__PURE__ */ jsx2("h3", { children: "Discussion" }),
755
+ comments.length ? comments.map((comment, i) => /* @__PURE__ */ jsxs2("article", { children: [
756
+ /* @__PURE__ */ jsx2("strong", { children: comment.author }),
757
+ /* @__PURE__ */ jsx2("small", { children: comment.at }),
758
+ /* @__PURE__ */ jsx2("p", { children: comment.body })
759
+ ] }, i)) : /* @__PURE__ */ jsx2("p", { children: "No discussion supplied." })
760
+ ] });
761
+ }
762
+ function AttemptTimeline({ attempts = [], onOpenSession }) {
763
+ return /* @__PURE__ */ jsxs2("section", { "aria-label": "Task attempts", children: [
764
+ /* @__PURE__ */ jsx2("h3", { children: "Attempts" }),
765
+ attempts.length ? /* @__PURE__ */ jsx2("ol", { className: "scui-domain-timeline", children: attempts.map((attempt) => /* @__PURE__ */ jsxs2("li", { children: [
766
+ /* @__PURE__ */ jsxs2("strong", { children: [
767
+ attempt.key,
768
+ " \xB7 ",
769
+ label(attempt.status)
770
+ ] }),
771
+ /* @__PURE__ */ jsxs2("p", { children: [
772
+ attempt.profile,
773
+ attempt.startedAt ? ` \xB7 ${attempt.startedAt}` : "",
774
+ attempt.endedAt ? ` \u2013 ${attempt.endedAt}` : ""
775
+ ] }),
776
+ attempt.error && /* @__PURE__ */ jsx2("p", { children: attempt.error }),
777
+ /* @__PURE__ */ jsx2(HandoffCard, { attempt }),
778
+ attempt.sessionKey && onOpenSession ? /* @__PURE__ */ jsx2(
779
+ "button",
780
+ {
781
+ type: "button",
782
+ onClick: () => onOpenSession(attempt.sessionKey),
783
+ children: "Open conversation"
784
+ }
785
+ ) : /* @__PURE__ */ jsx2("p", { className: "scui-domain-meta", children: "No linked session was supplied for this attempt." })
786
+ ] }, attempt.key)) }) : /* @__PURE__ */ jsx2("p", { children: "No attempt recorded for this task." })
787
+ ] });
788
+ }
789
+ function DependencyList({ items = [], title = "Depends on", onOpen }) {
790
+ return /* @__PURE__ */ jsxs2("section", { children: [
791
+ /* @__PURE__ */ jsx2("h3", { children: title }),
792
+ items.length ? items.map((item) => /* @__PURE__ */ jsxs2(
793
+ "button",
794
+ {
795
+ type: "button",
796
+ className: "scui-domain-related",
797
+ disabled: !item.available || !onOpen,
798
+ onClick: () => onOpen(item.key),
799
+ children: [
800
+ item.label,
801
+ !item.available ? " \xB7 Target unavailable" : ""
802
+ ]
803
+ },
804
+ item.key
805
+ )) : /* @__PURE__ */ jsx2("p", { children: "No recorded relationships." })
806
+ ] });
807
+ }
808
+ function TaskCard({ task, onOpen }) {
809
+ return /* @__PURE__ */ jsxs2(
810
+ "button",
811
+ {
812
+ type: "button",
813
+ className: "scui-domain-task",
814
+ disabled: !onOpen,
815
+ "aria-label": `Open ${task.id}: ${task.title}`,
816
+ onClick: (event) => onOpen(task.key, event.currentTarget),
817
+ children: [
818
+ /* @__PURE__ */ jsxs2("span", { className: "scui-domain-meta", children: [
819
+ task.id,
820
+ " \xB7 ",
821
+ task.assignee
822
+ ] }),
823
+ /* @__PURE__ */ jsx2("strong", { children: task.title }),
824
+ /* @__PURE__ */ jsxs2("span", { className: "scui-domain-meta", children: [
825
+ label(task.lane),
826
+ task.note ? ` \xB7 ${task.note}` : ""
827
+ ] })
828
+ ]
829
+ }
830
+ );
831
+ }
832
+ function WorkflowList({ tasks = [], onOpen }) {
833
+ return /* @__PURE__ */ jsx2("div", { className: "scui-domain-list", children: tasks.map((task) => /* @__PURE__ */ jsx2(TaskCard, { task, onOpen }, task.key)) });
834
+ }
835
+ function TaskDetails({ task, onOpenTask, onOpenSession, onClose }) {
836
+ const heading = useRef2(null);
837
+ useLayoutEffect2(() => {
838
+ if (onClose) heading.current?.focus();
839
+ }, [task.key]);
840
+ return /* @__PURE__ */ jsxs2(
841
+ "section",
842
+ {
843
+ className: "scui-domain-detail",
844
+ "aria-label": "Task details",
845
+ onKeyDown: (event) => {
846
+ if (event.key === "Escape" && onClose) {
847
+ event.stopPropagation();
848
+ onClose();
849
+ }
850
+ },
851
+ children: [
852
+ /* @__PURE__ */ jsxs2("div", { className: "scui-domain-detail-top", children: [
853
+ /* @__PURE__ */ jsx2("span", { children: task.id }),
854
+ onClose && /* @__PURE__ */ jsx2("button", { type: "button", onClick: onClose, children: "Close task" })
855
+ ] }),
856
+ /* @__PURE__ */ jsx2("h2", { ref: heading, tabIndex: -1, children: task.title }),
857
+ /* @__PURE__ */ jsxs2("div", { className: "scui-domain-inline", children: [
858
+ /* @__PURE__ */ jsx2(Badge, { value: task.lane }),
859
+ /* @__PURE__ */ jsx2("span", { children: task.assignee })
860
+ ] }),
861
+ task.body && /* @__PURE__ */ jsx2("p", { children: task.body }),
862
+ task.note && /* @__PURE__ */ jsx2("p", { className: "scui-domain-callout", children: task.note }),
863
+ (task.attemptCount > task.attempts.length || task.reviewCount > task.reviews.length || task.commentCount > task.comments.length) && /* @__PURE__ */ jsxs2("p", { className: "scui-domain-banner", children: [
864
+ "Bounded history: ",
865
+ task.attempts.length,
866
+ " of ",
867
+ task.attemptCount,
868
+ " ",
869
+ "attempts, ",
870
+ task.reviews.length,
871
+ " of ",
872
+ task.reviewCount,
873
+ " reviews,",
874
+ " ",
875
+ task.comments.length,
876
+ " of ",
877
+ task.commentCount,
878
+ " comments. Older records remain in the source."
879
+ ] }),
880
+ task.reviews?.map((review, i) => /* @__PURE__ */ jsx2(ReviewCard, { review }, i)),
881
+ /* @__PURE__ */ jsx2(DependencyList, { items: task.dependencies, onOpen: onOpenTask }),
882
+ /* @__PURE__ */ jsx2(
883
+ DependencyList,
884
+ {
885
+ title: "Required before",
886
+ items: task.dependents,
887
+ onOpen: onOpenTask
888
+ }
889
+ ),
890
+ /* @__PURE__ */ jsx2(AttemptTimeline, { attempts: task.attempts, onOpenSession }),
891
+ /* @__PURE__ */ jsx2(TaskThread, { comments: task.comments }),
892
+ /* @__PURE__ */ jsx2("p", { className: "scui-domain-footnote", children: "This source supports reading tasks. Make board changes in the owning harness." })
893
+ ]
894
+ }
895
+ );
896
+ }
897
+ function WorkflowBoard({
898
+ board,
899
+ selectedKey,
900
+ onSelect,
901
+ onOpenSession,
902
+ onLoadMore,
903
+ initialLayout = "list"
904
+ }) {
905
+ const [layout, setLayout] = useState2(initialLayout), [query, setQuery] = useState2(""), [selection, setSelection] = useState2(null);
906
+ const opener = useRef2(null), list = useRef2(null);
907
+ const selected = selectedKey === void 0 ? selection : selectedKey;
908
+ const task = board.tasks.find((item) => item.key === selected);
909
+ const select = (value, element) => {
910
+ if (element) opener.current = element;
911
+ setSelection(value);
912
+ onSelect?.(value);
913
+ };
914
+ const close = () => {
915
+ select(null);
916
+ requestAnimationFrame(
917
+ () => (opener.current?.isConnected ? opener.current : list.current)?.focus()
918
+ );
919
+ };
920
+ const visible = board.tasks.filter(
921
+ (item) => `${item.id} ${item.title} ${item.assignee}`.toLowerCase().includes(query.toLowerCase())
922
+ );
923
+ const lanes = [...new Set(visible.map((item) => item.lane))];
924
+ return /* @__PURE__ */ jsxs2("section", { className: "scui-root scui-domain", "aria-label": "Workflow board", children: [
925
+ /* @__PURE__ */ jsxs2("header", { className: "scui-domain-header", children: [
926
+ /* @__PURE__ */ jsxs2("div", { children: [
927
+ /* @__PURE__ */ jsxs2("span", { className: "scui-domain-eyebrow", children: [
928
+ "Workflow / ",
929
+ board.source
930
+ ] }),
931
+ /* @__PURE__ */ jsx2("h1", { children: board.title }),
932
+ /* @__PURE__ */ jsxs2("p", { children: [
933
+ board.tasks.length,
934
+ " of ",
935
+ board.total,
936
+ " tasks \xB7 Read-only board"
937
+ ] })
938
+ ] }),
939
+ /* @__PURE__ */ jsx2(Badge, { value: board.status === "ready" ? "observed" : board.status })
940
+ ] }),
941
+ board.stale && /* @__PURE__ */ jsx2("p", { className: "scui-domain-banner", role: "status", children: "Source unavailable. Showing the last observation." }),
942
+ /* @__PURE__ */ jsxs2("div", { className: "scui-domain-toolbar", children: [
943
+ /* @__PURE__ */ jsxs2("label", { className: "scui-domain-search", children: [
944
+ "Search tasks",
945
+ /* @__PURE__ */ jsx2(
946
+ "input",
947
+ {
948
+ type: "search",
949
+ value: query,
950
+ onInput: (event) => setQuery(event.currentTarget.value)
951
+ }
952
+ )
953
+ ] }),
954
+ /* @__PURE__ */ jsxs2(
955
+ "div",
956
+ {
957
+ className: "scui-domain-switch",
958
+ role: "group",
959
+ "aria-label": "Task layout",
960
+ children: [
961
+ /* @__PURE__ */ jsx2(
962
+ "button",
963
+ {
964
+ type: "button",
965
+ "aria-pressed": layout === "board",
966
+ onClick: () => setLayout("board"),
967
+ children: "Board"
968
+ }
969
+ ),
970
+ /* @__PURE__ */ jsx2(
971
+ "button",
972
+ {
973
+ type: "button",
974
+ "aria-pressed": layout === "list",
975
+ onClick: () => setLayout("list"),
976
+ children: "List"
977
+ }
978
+ )
979
+ ]
980
+ }
981
+ )
982
+ ] }),
983
+ /* @__PURE__ */ jsxs2(
984
+ "div",
985
+ {
986
+ className: `scui-domain-workspace ${task ? "scui-domain-has-detail" : ""}`,
987
+ children: [
988
+ /* @__PURE__ */ jsxs2(
989
+ "section",
990
+ {
991
+ ref: list,
992
+ tabIndex: -1,
993
+ className: "scui-domain-collection",
994
+ "aria-label": "Tasks",
995
+ children: [
996
+ /* @__PURE__ */ jsx2(
997
+ Notice,
998
+ {
999
+ status: board.status,
1000
+ count: board.tasks.length,
1001
+ noun: "tasks"
1002
+ }
1003
+ ),
1004
+ board.status === "ready" && (visible.length ? layout === "board" ? /* @__PURE__ */ jsx2(
1005
+ "div",
1006
+ {
1007
+ className: "scui-domain-board",
1008
+ style: {
1009
+ gridTemplateColumns: `repeat(${Math.max(1, lanes.length)}, minmax(190px, 1fr))`
1010
+ },
1011
+ children: lanes.map((lane) => /* @__PURE__ */ jsxs2(
1012
+ "section",
1013
+ {
1014
+ className: "scui-domain-lane",
1015
+ "aria-label": label(lane),
1016
+ children: [
1017
+ /* @__PURE__ */ jsxs2("h2", { children: [
1018
+ label(lane),
1019
+ " ",
1020
+ /* @__PURE__ */ jsx2("span", { children: visible.filter((item) => item.lane === lane).length })
1021
+ ] }),
1022
+ /* @__PURE__ */ jsx2(
1023
+ WorkflowList,
1024
+ {
1025
+ tasks: visible.filter((item) => item.lane === lane),
1026
+ onOpen: select
1027
+ }
1028
+ )
1029
+ ]
1030
+ },
1031
+ lane
1032
+ ))
1033
+ }
1034
+ ) : /* @__PURE__ */ jsx2(WorkflowList, { tasks: visible, onOpen: select }) : board.tasks.length > 0 && /* @__PURE__ */ jsx2("p", { role: "status", children: "No tasks match this search." })),
1035
+ board.hasMore && /* @__PURE__ */ jsx2("button", { type: "button", disabled: !onLoadMore, onClick: onLoadMore, children: "Load more tasks" })
1036
+ ]
1037
+ }
1038
+ ),
1039
+ task && /* @__PURE__ */ jsx2(
1040
+ TaskDetails,
1041
+ {
1042
+ task,
1043
+ onClose: close,
1044
+ onOpenTask: (key) => select(key),
1045
+ onOpenSession
1046
+ }
1047
+ ),
1048
+ selected && !task && /* @__PURE__ */ jsxs2("p", { role: "status", children: [
1049
+ "The selected task is outside this page or no longer available.",
1050
+ " ",
1051
+ /* @__PURE__ */ jsx2("button", { type: "button", onClick: close, children: "Back to tasks" })
1052
+ ] })
1053
+ ]
1054
+ }
1055
+ )
1056
+ ] });
1057
+ }
1058
+ function DeliveryStatus({ delivery }) {
1059
+ return /* @__PURE__ */ jsx2(Badge, { value: delivery?.state || "unknown" });
1060
+ }
1061
+ function RunList({ runs = [], onOpen }) {
1062
+ return /* @__PURE__ */ jsx2("div", { className: "scui-domain-runs", children: runs.map((run) => /* @__PURE__ */ jsxs2(
1063
+ "button",
1064
+ {
1065
+ type: "button",
1066
+ className: "scui-domain-run",
1067
+ disabled: !onOpen,
1068
+ "aria-label": `Open ${run.id}`,
1069
+ onClick: (event) => onOpen(run.key, event.currentTarget),
1070
+ children: [
1071
+ /* @__PURE__ */ jsxs2("span", { children: [
1072
+ /* @__PURE__ */ jsx2("strong", { children: run.startedAt || "Start time unknown" }),
1073
+ /* @__PURE__ */ jsx2("span", { className: "scui-domain-meta", children: run.id })
1074
+ ] }),
1075
+ /* @__PURE__ */ jsxs2("span", { children: [
1076
+ /* @__PURE__ */ jsx2("span", { className: "scui-domain-meta", children: "Execution" }),
1077
+ /* @__PURE__ */ jsx2(Badge, { value: run.execution })
1078
+ ] }),
1079
+ /* @__PURE__ */ jsxs2("span", { children: [
1080
+ /* @__PURE__ */ jsx2("span", { className: "scui-domain-meta", children: "Delivery" }),
1081
+ /* @__PURE__ */ jsx2(DeliveryStatus, { delivery: run.delivery })
1082
+ ] })
1083
+ ]
1084
+ },
1085
+ run.key
1086
+ )) });
1087
+ }
1088
+ function RunDetails({ run, onClose, onOpenSession }) {
1089
+ const heading = useRef2(null);
1090
+ useLayoutEffect2(() => {
1091
+ if (onClose) heading.current?.focus();
1092
+ }, [run.key]);
1093
+ const completed = good(run.execution);
1094
+ return /* @__PURE__ */ jsxs2(
1095
+ "section",
1096
+ {
1097
+ className: "scui-domain-detail",
1098
+ "aria-label": "Run details",
1099
+ onKeyDown: (event) => {
1100
+ if (event.key === "Escape" && onClose) {
1101
+ event.stopPropagation();
1102
+ onClose();
1103
+ }
1104
+ },
1105
+ children: [
1106
+ /* @__PURE__ */ jsxs2("div", { className: "scui-domain-detail-top", children: [
1107
+ /* @__PURE__ */ jsx2("span", { children: run.id }),
1108
+ onClose && /* @__PURE__ */ jsx2("button", { type: "button", onClick: onClose, children: "Close run" })
1109
+ ] }),
1110
+ /* @__PURE__ */ jsx2("h2", { ref: heading, tabIndex: -1, children: completed ? `Execution completed. Delivery ${label(run.delivery?.state)}.` : `Execution ${label(run.execution)}.` }),
1111
+ /* @__PURE__ */ jsx2("p", { children: run.startedAt || "Start time unknown" }),
1112
+ /* @__PURE__ */ jsx2("h3", { children: "Execution" }),
1113
+ /* @__PURE__ */ jsx2(Badge, { value: run.execution }),
1114
+ run.error && /* @__PURE__ */ jsx2("p", { children: run.error }),
1115
+ /* @__PURE__ */ jsx2("h3", { children: "Delivery" }),
1116
+ /* @__PURE__ */ jsx2(DeliveryStatus, { delivery: run.delivery }),
1117
+ run.delivery ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
1118
+ /* @__PURE__ */ jsx2("p", { children: run.delivery.error }),
1119
+ /* @__PURE__ */ jsxs2("dl", { children: [
1120
+ /* @__PURE__ */ jsx2("dt", { children: "Destination" }),
1121
+ /* @__PURE__ */ jsx2("dd", { children: run.delivery.target || "Unknown" }),
1122
+ /* @__PURE__ */ jsx2("dt", { children: "Recorded attempts" }),
1123
+ /* @__PURE__ */ jsx2("dd", { children: run.delivery.attempts ?? "Unknown" })
1124
+ ] })
1125
+ ] }) : /* @__PURE__ */ jsx2("p", { children: "No matching delivery record was supplied. This does not establish success or failure." }),
1126
+ /* @__PURE__ */ jsx2("p", { className: "scui-domain-footnote", children: "Delivery retry is unavailable for this source. Running the job again would start new work." }),
1127
+ /* @__PURE__ */ jsxs2("details", { children: [
1128
+ /* @__PURE__ */ jsx2("summary", { children: "Source evidence" }),
1129
+ /* @__PURE__ */ jsxs2("dl", { children: [
1130
+ /* @__PURE__ */ jsx2("dt", { children: "Native execution status" }),
1131
+ /* @__PURE__ */ jsx2("dd", { children: run.execution }),
1132
+ /* @__PURE__ */ jsx2("dt", { children: "Native delivery state" }),
1133
+ /* @__PURE__ */ jsx2("dd", { children: run.delivery?.state || "Not supplied" }),
1134
+ /* @__PURE__ */ jsx2("dt", { children: "Finished at" }),
1135
+ /* @__PURE__ */ jsx2("dd", { children: run.finishedAt || "Unknown" })
1136
+ ] })
1137
+ ] }),
1138
+ /* @__PURE__ */ jsx2("h3", { children: "Conversation" }),
1139
+ run.sessionKey && onOpenSession ? /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => onOpenSession(run.sessionKey), children: "Open conversation" }) : /* @__PURE__ */ jsx2("p", { children: "No linked conversation was supplied for this run." })
1140
+ ]
1141
+ }
1142
+ );
1143
+ }
1144
+ function JobList({ jobs = [], onOpen }) {
1145
+ return /* @__PURE__ */ jsx2("div", { className: "scui-domain-list", children: jobs.map((job) => /* @__PURE__ */ jsxs2(
1146
+ "button",
1147
+ {
1148
+ type: "button",
1149
+ className: "scui-domain-task",
1150
+ disabled: !onOpen,
1151
+ onClick: () => onOpen(job.key),
1152
+ children: [
1153
+ /* @__PURE__ */ jsx2("strong", { children: job.title }),
1154
+ /* @__PURE__ */ jsxs2("span", { children: [
1155
+ job.source,
1156
+ " \xB7 ",
1157
+ job.profile || "Default profile"
1158
+ ] }),
1159
+ /* @__PURE__ */ jsxs2("span", { children: [
1160
+ job.schedule,
1161
+ " \xB7 ",
1162
+ label(job.state)
1163
+ ] })
1164
+ ]
1165
+ },
1166
+ job.key
1167
+ )) });
1168
+ }
1169
+ function JobActions({ job, stale, onPause }) {
1170
+ const [action, setAction] = useState2("idle"), [confirmed, setConfirmed] = useState2(null);
1171
+ const generation = useRef2(0);
1172
+ useLayoutEffect2(() => {
1173
+ generation.current++;
1174
+ setAction("idle");
1175
+ setConfirmed(null);
1176
+ return () => {
1177
+ generation.current++;
1178
+ };
1179
+ }, [job.key, job.enabled]);
1180
+ const pause = async () => {
1181
+ const revision = generation.current;
1182
+ setAction("pending");
1183
+ try {
1184
+ const result = await onPause(job.key);
1185
+ if (generation.current !== revision) return;
1186
+ if (result?.confirmed !== true || result.job?.key !== job.key || result.job.enabled !== false)
1187
+ throw new Error("Pause unconfirmed");
1188
+ setConfirmed(result.job);
1189
+ setAction("confirmed");
1190
+ } catch {
1191
+ if (generation.current === revision) setAction("failed");
1192
+ }
1193
+ };
1194
+ return /* @__PURE__ */ jsxs2("div", { children: [
1195
+ job.canPause && onPause ? /* @__PURE__ */ jsx2(
1196
+ "button",
1197
+ {
1198
+ type: "button",
1199
+ disabled: stale || action === "pending" || action === "confirmed",
1200
+ onClick: pause,
1201
+ children: action === "pending" ? "Pausing\u2026" : action === "confirmed" ? "Job paused" : "Pause schedule"
1202
+ }
1203
+ ) : /* @__PURE__ */ jsx2("span", { className: "scui-domain-meta", children: "Schedule controls unavailable for this source." }),
1204
+ action !== "idle" && /* @__PURE__ */ jsx2("p", { role: "status", children: action === "pending" ? "Pause requested. Waiting for the source to confirm." : confirmed ? "Schedule paused. Existing runs and delivery attempts are unchanged." : "Pause was not confirmed. The last observed schedule is still shown." })
1205
+ ] });
1206
+ }
1207
+ function JobDetails({ job }) {
1208
+ return /* @__PURE__ */ jsxs2(Fragment2, { children: [
1209
+ /* @__PURE__ */ jsxs2("header", { className: "scui-domain-header", children: [
1210
+ /* @__PURE__ */ jsxs2("div", { children: [
1211
+ /* @__PURE__ */ jsxs2("span", { className: "scui-domain-eyebrow", children: [
1212
+ "Jobs / ",
1213
+ job.source,
1214
+ " / ",
1215
+ job.profile || "Default"
1216
+ ] }),
1217
+ /* @__PURE__ */ jsx2("h1", { children: job.title }),
1218
+ /* @__PURE__ */ jsx2("p", { children: job.schedule })
1219
+ ] }),
1220
+ /* @__PURE__ */ jsx2(Badge, { value: job.state })
1221
+ ] }),
1222
+ /* @__PURE__ */ jsxs2("div", { className: "scui-domain-schedule", children: [
1223
+ /* @__PURE__ */ jsxs2("div", { children: [
1224
+ /* @__PURE__ */ jsx2("span", { children: "Next scheduled run" }),
1225
+ /* @__PURE__ */ jsx2("strong", { children: job.enabled === false ? "Paused" : job.nextRunAt || "Unknown" })
1226
+ ] }),
1227
+ /* @__PURE__ */ jsxs2("div", { children: [
1228
+ /* @__PURE__ */ jsx2("span", { children: "Destination" }),
1229
+ /* @__PURE__ */ jsx2("strong", { children: job.destination || "Unknown" })
1230
+ ] }),
1231
+ /* @__PURE__ */ jsxs2("div", { children: [
1232
+ /* @__PURE__ */ jsx2("span", { children: "Channel connection" }),
1233
+ /* @__PURE__ */ jsx2("strong", { children: job.channelConnection || "Unknown" })
1234
+ ] })
1235
+ ] })
1236
+ ] });
1237
+ }
1238
+ function OrchestrationJobs({
1239
+ job,
1240
+ runs = [],
1241
+ status = "ready",
1242
+ stale = false,
1243
+ selectedKey,
1244
+ onSelect,
1245
+ onPause,
1246
+ onOpenSession
1247
+ }) {
1248
+ const [selection, setSelection] = useState2(null), [filter, setFilter] = useState2("all");
1249
+ const opener = useRef2(null), collection = useRef2(null);
1250
+ const selected = selectedKey === void 0 ? selection : selectedKey;
1251
+ const run = runs.find((item) => item.key === selected);
1252
+ const select = (key, element) => {
1253
+ if (element) opener.current = element;
1254
+ setSelection(key);
1255
+ onSelect?.(key);
1256
+ };
1257
+ const close = () => {
1258
+ select(null);
1259
+ requestAnimationFrame(
1260
+ () => (opener.current?.isConnected ? opener.current : collection.current)?.focus()
1261
+ );
1262
+ };
1263
+ const visible = runs.filter(
1264
+ (item) => filter === "all" || bad(item.delivery?.state)
1265
+ );
1266
+ return /* @__PURE__ */ jsxs2("section", { className: "scui-root scui-domain", "aria-label": "Job investigation", children: [
1267
+ /* @__PURE__ */ jsx2(JobDetails, { job }),
1268
+ stale && /* @__PURE__ */ jsx2("p", { role: "status", className: "scui-domain-banner", children: "Source unavailable. Showing the last observation. Controls are unavailable until refreshed." }),
1269
+ /* @__PURE__ */ jsxs2("div", { className: "scui-domain-toolbar", children: [
1270
+ /* @__PURE__ */ jsxs2("label", { children: [
1271
+ "Run history",
1272
+ /* @__PURE__ */ jsxs2(
1273
+ "select",
1274
+ {
1275
+ value: filter,
1276
+ onChange: (event) => setFilter(event.currentTarget.value),
1277
+ children: [
1278
+ /* @__PURE__ */ jsx2("option", { value: "all", children: "All runs" }),
1279
+ /* @__PURE__ */ jsx2("option", { value: "attention", children: "Delivery needs attention" })
1280
+ ]
1281
+ }
1282
+ )
1283
+ ] }),
1284
+ /* @__PURE__ */ jsx2(
1285
+ JobActions,
1286
+ {
1287
+ job,
1288
+ stale: stale || status !== "ready",
1289
+ onPause
1290
+ }
1291
+ )
1292
+ ] }),
1293
+ /* @__PURE__ */ jsxs2(
1294
+ "div",
1295
+ {
1296
+ className: `scui-domain-workspace ${run ? "scui-domain-has-detail" : ""}`,
1297
+ children: [
1298
+ /* @__PURE__ */ jsxs2(
1299
+ "section",
1300
+ {
1301
+ ref: collection,
1302
+ tabIndex: -1,
1303
+ className: "scui-domain-collection",
1304
+ "aria-label": "Run history",
1305
+ children: [
1306
+ /* @__PURE__ */ jsx2(Notice, { status, count: runs.length, noun: "runs" }),
1307
+ status === "ready" && /* @__PURE__ */ jsx2(RunList, { runs: visible, onOpen: select }),
1308
+ status === "ready" && runs.length > 0 && !visible.length && /* @__PURE__ */ jsx2("p", { role: "status", children: "No runs match this filter." })
1309
+ ]
1310
+ }
1311
+ ),
1312
+ run && /* @__PURE__ */ jsx2(RunDetails, { run, onClose: close, onOpenSession }),
1313
+ selected && !run && /* @__PURE__ */ jsxs2("p", { role: "status", children: [
1314
+ "The selected run is no longer available.",
1315
+ " ",
1316
+ /* @__PURE__ */ jsx2("button", { type: "button", onClick: close, children: "Back to runs" })
1317
+ ] })
1318
+ ]
1319
+ }
1320
+ )
1321
+ ] });
1322
+ }
1323
+ export {
1324
+ AdapterStatus,
1325
+ ApprovalDetails,
1326
+ ApprovalInbox,
1327
+ AttemptTimeline,
1328
+ ChannelList,
1329
+ DeliveryStatus,
1330
+ DependencyList,
1331
+ HandoffCard,
1332
+ JobActions,
1333
+ JobControls,
1334
+ JobDetails,
1335
+ JobList,
1336
+ MemoryBrowser,
1337
+ OrchestrationJobs,
1338
+ OrchestrationOverview,
1339
+ ProfileDetails,
1340
+ ProfileList,
1341
+ ReviewCard,
1342
+ RouteList,
1343
+ RunDetails,
1344
+ RunList,
1345
+ SkillDetails,
1346
+ SkillList,
1347
+ SourceInspector,
1348
+ TaskCard,
1349
+ TaskDetails,
1350
+ TaskThread,
1351
+ TriggerList,
1352
+ WorkflowBoard,
1353
+ WorkflowList
1354
+ };