@kukeon/console 0.0.0-stage → 0.10.0-edge.gaa95c2af
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assignments-Biqg1AT0.js +257 -0
- package/dist/assignments-tab.d.ts +4 -0
- package/dist/assignments.d.mts +40 -0
- package/dist/auth.d.ts +39 -0
- package/dist/bulk-ui.d.ts +49 -0
- package/dist/bulk.d.mts +14 -0
- package/dist/catalog-ChPGZP2a.js +1949 -0
- package/dist/catalog-url-Dr9e92Yq.js +19 -0
- package/dist/catalog-url.d.mts +4 -0
- package/dist/catalog.d.ts +40 -0
- package/dist/cell-filter.d.ts +10 -0
- package/dist/cell-sidebar.d.ts +26 -0
- package/dist/cells.d.mts +29 -0
- package/dist/cgroup-format.d.ts +17 -0
- package/dist/cgroup.d.ts +4 -0
- package/dist/config-form.d.mts +66 -0
- package/dist/connector-ui-CG9kLZ5s.js +2716 -0
- package/dist/connector-ui.d.ts +129 -0
- package/dist/connectors-page-C8459TcH.js +241 -0
- package/dist/connectors-page.d.ts +8 -0
- package/dist/connectors.d.mts +154 -0
- package/dist/container-log.d.ts +11 -0
- package/dist/create.d.ts +11 -0
- package/dist/creation-schema.d.mts +15 -0
- package/dist/daemon-DxP5hn4p.js +394 -0
- package/dist/daemon.d.ts +24 -0
- package/dist/display-name.d.ts +10 -0
- package/dist/drift-diff.d.ts +4 -0
- package/dist/exec.d.ts +15 -0
- package/dist/extensions.d.ts +111 -0
- package/dist/get-started.d.ts +9 -0
- package/dist/health.d.ts +22 -0
- package/dist/identities-page-CJ_ukj0Q.js +2137 -0
- package/dist/identities-page.d.ts +15 -0
- package/dist/identities.d.mts +24 -0
- package/dist/image-format.d.ts +6 -0
- package/dist/image-inventory.d.ts +12 -0
- package/dist/images.d.ts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5241 -0
- package/dist/initialize-CAOkMhlL.js +146 -0
- package/dist/initialize.d.ts +21 -0
- package/dist/inventory.d.ts +66 -0
- package/dist/lifecycle-policy.d.ts +11 -0
- package/dist/lifecycle.d.ts +24 -0
- package/dist/log-buffer.d.ts +8 -0
- package/dist/main.d.ts +13 -0
- package/dist/majordomo-CikLz0g9.js +3064 -0
- package/dist/majordomo.d.ts +102 -0
- package/dist/manage-nav.d.ts +4 -0
- package/dist/manifest-diff.d.mts +11 -0
- package/dist/merged-values-CBzWsNOS.js +739 -0
- package/dist/merged-values.d.ts +24 -0
- package/dist/network-format.d.ts +30 -0
- package/dist/network.d.ts +13 -0
- package/dist/new-agent-BweyzBnY.js +201 -0
- package/dist/new-agent.d.ts +27 -0
- package/dist/new-cell-Iceq2Zfv.js +1985 -0
- package/dist/new-cell.d.ts +29 -0
- package/dist/new-config-C9NSC9Ou.js +1541 -0
- package/dist/new-config.d.ts +7 -0
- package/dist/notifications.d.ts +26 -0
- package/dist/onboarding-oZBJXTy0.js +395 -0
- package/dist/onboarding.d.mts +40 -0
- package/dist/panel-cells.d.mts +8 -0
- package/dist/registry-credentials.d.ts +13 -0
- package/dist/relationships.d.mts +12 -0
- package/dist/request.d.ts +16 -0
- package/dist/router.d.ts +12 -0
- package/dist/routes.d.ts +43 -0
- package/dist/schedule-DzQ3Homi.js +113 -0
- package/dist/schedule-format.d.mts +9 -0
- package/dist/schedule.d.ts +16 -0
- package/dist/scope-actions.d.ts +9 -0
- package/dist/screens.d.ts +6 -0
- package/dist/secret-form.d.ts +24 -0
- package/dist/settings-nav.d.ts +5 -0
- package/dist/settings-page.d.ts +4 -0
- package/dist/settings-values.d.mts +18 -0
- package/dist/settings.d.ts +50 -0
- package/dist/sidebar-shell.d.ts +55 -0
- package/dist/sources-page-CxMSM-sz.js +423 -0
- package/dist/sources-page.d.ts +5 -0
- package/dist/space-subnets.d.ts +3 -0
- package/dist/style.css +2 -0
- package/dist/team-form.d.mts +56 -0
- package/dist/team-plan-CFOIv1lN.js +735 -0
- package/dist/team-plan.d.ts +22 -0
- package/dist/team-wizard.d.ts +8 -0
- package/dist/teams-page-C6UGy4Fw.js +2216 -0
- package/dist/teams-page.d.ts +9 -0
- package/dist/teams.d.mts +114 -0
- package/dist/terminal-palette.d.ts +8 -0
- package/dist/terminal.d.ts +98 -0
- package/dist/unread.d.mts +19 -0
- package/dist/use-unread.d.ts +4 -0
- package/dist/user-menu.d.ts +7 -0
- package/dist/views.d.mts +8 -0
- package/dist/workbench.d.ts +16 -0
- package/package.json +45 -4
- package/README.md +0 -3
|
@@ -0,0 +1,3064 @@
|
|
|
1
|
+
import { $ as e, B as t, Bt as n, Gn as r, Kn as i, L as a, T as o, Un as s, Wn as c, bn as l, cn as u, in as d, j as f, zt as p } from "./connector-ui-CG9kLZ5s.js";
|
|
2
|
+
import { A as m, C as h, E as g, L as _, P as v, T as y, _ as b, g as x, w as S, x as C, y as w } from "./onboarding-oZBJXTy0.js";
|
|
3
|
+
import { t as T } from "./initialize-CAOkMhlL.js";
|
|
4
|
+
import { createContext as E, useCallback as D, useContext as ee, useEffect as O, useId as k, useMemo as A, useRef as j, useState as M, useSyncExternalStore as N } from "react";
|
|
5
|
+
import { apiFetch as P, apiSocket as F, onUnauthorized as I } from "@kukeon/api-client";
|
|
6
|
+
import { Fragment as te, jsx as L, jsxs as R } from "react/jsx-runtime";
|
|
7
|
+
import { DriftBadge as z, Icon as B, RollupDot as V, ScopePath as H, StateBadge as U, rememberFocus as W, stateTone as G, useModalDialog as K } from "@kukeon/ui";
|
|
8
|
+
import { createPortal as ne } from "react-dom";
|
|
9
|
+
import { Terminal as q } from "@xterm/xterm";
|
|
10
|
+
import { FitAddon as J } from "@xterm/addon-fit";
|
|
11
|
+
// src/cgroup-format.js
|
|
12
|
+
var re = "Unlimited", Y = "Not available (controller not enabled)", ie = "Unreadable", ae = "Not set", oe = 1024, X = [
|
|
13
|
+
"B",
|
|
14
|
+
"KiB",
|
|
15
|
+
"MiB",
|
|
16
|
+
"GiB",
|
|
17
|
+
"TiB"
|
|
18
|
+
];
|
|
19
|
+
function Z(e) {
|
|
20
|
+
let t = e, n = 0;
|
|
21
|
+
for (; Math.abs(t) >= oe && n < X.length - 1;) t /= oe, n++;
|
|
22
|
+
return n === 0 ? `${t} B` : `${Number(t.toFixed(t >= 100 ? 0 : t >= 10 ? 1 : 2))} ${X[n]}`;
|
|
23
|
+
}
|
|
24
|
+
function se(e) {
|
|
25
|
+
if (!e || e.state === "absent") return Y;
|
|
26
|
+
if (e.state === "unreadable") return ie;
|
|
27
|
+
if (e.state === "max") return re;
|
|
28
|
+
}
|
|
29
|
+
function Q(e, t = "count") {
|
|
30
|
+
let n = se(e);
|
|
31
|
+
if (n) return {
|
|
32
|
+
text: n,
|
|
33
|
+
raw: e?.raw
|
|
34
|
+
};
|
|
35
|
+
if (typeof e.value != "number") return {
|
|
36
|
+
text: e.raw || "Not available (controller not enabled)",
|
|
37
|
+
raw: e.raw
|
|
38
|
+
};
|
|
39
|
+
let r = e.value;
|
|
40
|
+
return t === "bytes" ? {
|
|
41
|
+
text: Z(r),
|
|
42
|
+
raw: e.raw
|
|
43
|
+
} : t === "weight" ? {
|
|
44
|
+
text: r === 100 ? "100 (default)" : String(r),
|
|
45
|
+
raw: e.raw
|
|
46
|
+
} : t === "usec" ? {
|
|
47
|
+
text: `${Number((r / 1e6).toFixed(r >= 1e8 ? 0 : 2))} s`,
|
|
48
|
+
raw: e.raw
|
|
49
|
+
} : {
|
|
50
|
+
text: String(r),
|
|
51
|
+
raw: e.raw
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function ce(e) {
|
|
55
|
+
let t = se(e);
|
|
56
|
+
if (t) return {
|
|
57
|
+
text: t,
|
|
58
|
+
raw: e?.raw
|
|
59
|
+
};
|
|
60
|
+
if (typeof e.quotaMicros != "number" || typeof e.periodMicros != "number" || e.periodMicros <= 0) return {
|
|
61
|
+
text: e.raw || "Not available (controller not enabled)",
|
|
62
|
+
raw: e.raw
|
|
63
|
+
};
|
|
64
|
+
let n = e.quotaMicros / e.periodMicros;
|
|
65
|
+
return {
|
|
66
|
+
text: `${Number(n.toFixed(2))} CPU (${Number((n * 100).toFixed(1))}%)`,
|
|
67
|
+
raw: e.raw
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function le(e) {
|
|
71
|
+
return se(e) || (e.values?.length ? e.values.join(" ") : "None");
|
|
72
|
+
}
|
|
73
|
+
function ue(e) {
|
|
74
|
+
let t = se(e);
|
|
75
|
+
return t ? [t] : e.entries?.length ? e.entries.map((e) => `${e.device} ${Object.entries(e.limits ?? {}).map(([e, t]) => `${e}=${t === "max" ? re : t}`).join(" ")}`) : ["No device limits"];
|
|
76
|
+
}
|
|
77
|
+
var de = {
|
|
78
|
+
container: "Container spec",
|
|
79
|
+
"space-default": "Inherited space default"
|
|
80
|
+
};
|
|
81
|
+
function fe(e) {
|
|
82
|
+
return !e || e.source === "unset" || typeof e.value != "number" ? {
|
|
83
|
+
text: ae,
|
|
84
|
+
source: ae
|
|
85
|
+
} : {
|
|
86
|
+
text: e.field === "memoryLimitBytes" ? Z(e.value) : String(e.value),
|
|
87
|
+
source: de[e.source] ?? e.source
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function pe(e) {
|
|
91
|
+
if (!e?.exists) return "Cgroup not present";
|
|
92
|
+
let t = e.live?.memory, n = [e.ready ? "Ready" : "Not ready"], r = t?.current?.state === "set" ? Q(t.current, "bytes").text : "", i = ["set", "max"].includes(t?.max?.state) ? Q(t.max, "bytes").text : "";
|
|
93
|
+
r ? n.push(`memory ${r}${i ? ` / ${i}` : ""}`) : i && n.push(`memory limit ${i}`);
|
|
94
|
+
let a = e.live?.pids?.current;
|
|
95
|
+
return a?.state === "set" && typeof a.value == "number" && n.push(`${a.value} ${a.value === 1 ? "PID" : "PIDs"}`), n.join(" · ");
|
|
96
|
+
}
|
|
97
|
+
// src/unread.mjs
|
|
98
|
+
var me = 3e3, he = "kukeon-terminal-seen", ge = (e) => !!e && typeof e == "object" && typeof e.startedAt == "string" && Number.isFinite(e.bytes) && e.bytes >= 0;
|
|
99
|
+
function _e(e) {
|
|
100
|
+
if (typeof e != "string") return {};
|
|
101
|
+
let t;
|
|
102
|
+
try {
|
|
103
|
+
t = JSON.parse(e);
|
|
104
|
+
} catch {
|
|
105
|
+
return {};
|
|
106
|
+
}
|
|
107
|
+
if (!t || typeof t != "object" || Array.isArray(t)) return {};
|
|
108
|
+
let n = {};
|
|
109
|
+
for (let [e, r] of Object.entries(t)) ge(r) && (n[e] = {
|
|
110
|
+
startedAt: r.startedAt,
|
|
111
|
+
bytes: r.bytes
|
|
112
|
+
});
|
|
113
|
+
return n;
|
|
114
|
+
}
|
|
115
|
+
function ve(e) {
|
|
116
|
+
let t = {}, n = e && typeof e == "object" && Array.isArray(e.cells) ? e.cells : [];
|
|
117
|
+
for (let e of n) {
|
|
118
|
+
if (!e || !Array.isArray(e.scope) || e.scope.length !== 4 || !e.scope.every((e) => typeof e == "string")) continue;
|
|
119
|
+
let n = JSON.stringify(e.scope);
|
|
120
|
+
typeof e.unavailable == "string" ? t[n] = { unavailable: e.unavailable } : typeof e.startedAt == "string" && Number.isFinite(e.bytesOut) && e.bytesOut >= 0 && Number.isFinite(e.idleMs) && (t[n] = {
|
|
121
|
+
startedAt: e.startedAt,
|
|
122
|
+
bytesOut: e.bytesOut,
|
|
123
|
+
idleMs: e.idleMs
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return t;
|
|
127
|
+
}
|
|
128
|
+
var ye = (e) => !!e && !e.unavailable;
|
|
129
|
+
function be(e, t, n) {
|
|
130
|
+
return ye(t) ? n || !e ? {
|
|
131
|
+
startedAt: t.startedAt,
|
|
132
|
+
bytes: t.bytesOut
|
|
133
|
+
} : e.startedAt === t.startedAt ? e : {
|
|
134
|
+
startedAt: t.startedAt,
|
|
135
|
+
bytes: 0
|
|
136
|
+
} : e;
|
|
137
|
+
}
|
|
138
|
+
function xe(e, t) {
|
|
139
|
+
return !ye(t) || !e ? 0 : e.startedAt === t.startedAt ? Math.max(0, t.bytesOut - e.bytes) : t.bytesOut;
|
|
140
|
+
}
|
|
141
|
+
function Se(e, t, n = me) {
|
|
142
|
+
return e > 0 && t >= n;
|
|
143
|
+
}
|
|
144
|
+
function Ce(e, t) {
|
|
145
|
+
let n = new Set(t), r = {};
|
|
146
|
+
for (let [t, i] of Object.entries(e)) n.has(t) && (r[t] = i);
|
|
147
|
+
return r;
|
|
148
|
+
}
|
|
149
|
+
function we(e, t, n) {
|
|
150
|
+
let r = { ...e }, i = [];
|
|
151
|
+
for (let [a, o] of Object.entries(t)) {
|
|
152
|
+
let t = be(e[a], o, n.has(a));
|
|
153
|
+
!t || e[a] && t.startedAt === e[a].startedAt && t.bytes === e[a].bytes || (r[a] = t, i.push(a));
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
markers: r,
|
|
157
|
+
changed: i
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function Te(e) {
|
|
161
|
+
return [...new Set(e.filter(Boolean))];
|
|
162
|
+
}
|
|
163
|
+
function Ee(e, t) {
|
|
164
|
+
let n = new Set(t);
|
|
165
|
+
return [...new Set(e)].filter((e) => !n.has(e));
|
|
166
|
+
}
|
|
167
|
+
function De(e, t, n, r = me) {
|
|
168
|
+
let i = {};
|
|
169
|
+
for (let [a, o] of Object.entries(t)) {
|
|
170
|
+
if (!ye(o) || n.has(a)) continue;
|
|
171
|
+
let t = xe(be(e[a], o, !1), o), s = Se(t, o.idleMs, r);
|
|
172
|
+
s && (i[a] = {
|
|
173
|
+
unreadBytes: t,
|
|
174
|
+
marked: s
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return i;
|
|
178
|
+
}
|
|
179
|
+
function Oe(e, t) {
|
|
180
|
+
return e > 0 ? t ? `, ${Z(e)} unread output` : ", unread output" : "";
|
|
181
|
+
}
|
|
182
|
+
function ke(e) {
|
|
183
|
+
return Z(e);
|
|
184
|
+
}
|
|
185
|
+
// src/cell-sidebar.tsx
|
|
186
|
+
var Ae = "kukeon-cell-collapsed-groups", je = 100, Me = 25, Ne = "others";
|
|
187
|
+
function Pe() {
|
|
188
|
+
try {
|
|
189
|
+
let e = JSON.parse(localStorage.getItem(Ae) ?? "[]");
|
|
190
|
+
return Array.isArray(e) && e.every((e) => typeof e == "string") ? e : [];
|
|
191
|
+
} catch {
|
|
192
|
+
return [];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function Fe(e, t) {
|
|
196
|
+
try {
|
|
197
|
+
localStorage.setItem(e, t);
|
|
198
|
+
} catch {}
|
|
199
|
+
}
|
|
200
|
+
var Ie = (e, t) => t.length === 4 && e.every((e, n) => e === t[n]);
|
|
201
|
+
function Le({ bytes: e, showBytes: t }) {
|
|
202
|
+
return /* @__PURE__ */ R(te, { children: [/* @__PURE__ */ L("span", {
|
|
203
|
+
className: "unread-dot",
|
|
204
|
+
"aria-hidden": "true"
|
|
205
|
+
}), t && /* @__PURE__ */ L("span", {
|
|
206
|
+
className: "cell-unread-count",
|
|
207
|
+
"aria-hidden": "true",
|
|
208
|
+
children: ke(e)
|
|
209
|
+
})] });
|
|
210
|
+
}
|
|
211
|
+
function Re(e, t) {
|
|
212
|
+
return e.reduce((e, n) => e + (t[JSON.stringify(n.scope)]?.unreadBytes ?? 0), 0);
|
|
213
|
+
}
|
|
214
|
+
function ze({ hidden: e }) {
|
|
215
|
+
return e > 0 ? /* @__PURE__ */ R("a", {
|
|
216
|
+
className: "cell-stopped-link",
|
|
217
|
+
href: t(3, [], "inactive"),
|
|
218
|
+
children: ["Stopped · ", e]
|
|
219
|
+
}) : null;
|
|
220
|
+
}
|
|
221
|
+
function Be({ row: t, selectedScope: n, terminalStates: r, showScope: i, showTerminalStatus: a, labels: o, unread: s, showUnreadBytes: c }) {
|
|
222
|
+
let l = t.scope.join(" / "), u = r[JSON.stringify(t.scope)], d = o.get(JSON.stringify(t.scope)), f = s[JSON.stringify(t.scope)]?.unreadBytes ?? 0;
|
|
223
|
+
return /* @__PURE__ */ L("li", { children: /* @__PURE__ */ R("a", {
|
|
224
|
+
className: `cell-link${f ? " has-unread" : ""}`,
|
|
225
|
+
href: e(t.scope),
|
|
226
|
+
"aria-current": Ie(t.scope, n) ? "page" : void 0,
|
|
227
|
+
"aria-label": `Open ${d ? `${d} (${l})` : l}${Oe(f, c)}`,
|
|
228
|
+
title: l,
|
|
229
|
+
children: [
|
|
230
|
+
/* @__PURE__ */ R("span", {
|
|
231
|
+
className: "cell-link-name",
|
|
232
|
+
children: [d ?? t.doc.metadata.name, f > 0 && /* @__PURE__ */ L(Le, {
|
|
233
|
+
bytes: f,
|
|
234
|
+
showBytes: c
|
|
235
|
+
})]
|
|
236
|
+
}),
|
|
237
|
+
d && /* @__PURE__ */ L("span", {
|
|
238
|
+
className: "cell-link-cell mono-id",
|
|
239
|
+
children: t.doc.metadata.name
|
|
240
|
+
}),
|
|
241
|
+
i && /* @__PURE__ */ L("span", {
|
|
242
|
+
className: "cell-link-scope",
|
|
243
|
+
children: /* @__PURE__ */ L(H, { parts: t.scope.slice(0, 3) })
|
|
244
|
+
}),
|
|
245
|
+
/* @__PURE__ */ L(U, { state: t.doc.status?.state }),
|
|
246
|
+
/* @__PURE__ */ L(z, { status: t.doc.status }),
|
|
247
|
+
a && u && /* @__PURE__ */ R("span", {
|
|
248
|
+
className: `cell-terminal-state ${u}`,
|
|
249
|
+
children: ["Terminal ", u]
|
|
250
|
+
})
|
|
251
|
+
]
|
|
252
|
+
}) });
|
|
253
|
+
}
|
|
254
|
+
function Ve({ inventory: t, selectedScope: n, terminalStates: r, filter: i, listStyle: a = "default", showSearch: o = !0, showGroupBy: s = !0, showScope: c = !0, showTerminalStatus: l = !0, unread: u = {}, showUnreadBytes: d = !1 }) {
|
|
255
|
+
let { search: f, setSearch: p, groupBy: _, setGroupBy: v } = i, C = a === "agent", [T, E] = M(Pe), [D, ee] = M({}), [O, k] = M(Me), j = t.data?.rows[3] ?? [], N = A(() => x(j, n), [j, n]), P = j.length - N.length, F = A(() => y(N, _), [N, _]), I = A(() => N.filter((e) => w(e, f)), [N, f]), U = A(() => S(I, _), [I, _]), W = t.data?.configs, G = A(() => b(N, W), [N, W]), { agents: K, others: ne } = A(() => h(G, (e) => w(e, f)), [G, f]), q = A(() => new Map(G.agents.map((e) => [e.id, e.rows.length])), [G]), J = A(() => C ? g(j, W) : /* @__PURE__ */ new Map(), [
|
|
256
|
+
C,
|
|
257
|
+
j,
|
|
258
|
+
W
|
|
259
|
+
]), re = I.length && I.every((e) => e.scope.slice(0, 3).join(" / ") === I[0].scope.slice(0, 3).join(" / ")) ? I[0].scope.slice(0, 3).join(" / ") : "", Y = !!t.error || !!t.data?.failures.length, ie = {
|
|
260
|
+
selectedScope: n,
|
|
261
|
+
terminalStates: r,
|
|
262
|
+
showScope: c && !re,
|
|
263
|
+
showTerminalStatus: l,
|
|
264
|
+
labels: J,
|
|
265
|
+
unread: u,
|
|
266
|
+
showUnreadBytes: d
|
|
267
|
+
}, ae = s && !C;
|
|
268
|
+
function oe() {
|
|
269
|
+
ee({}), k(Me);
|
|
270
|
+
}
|
|
271
|
+
function X(e) {
|
|
272
|
+
let t = T.includes(e) ? T.filter((t) => t !== e) : [...T, e];
|
|
273
|
+
E(t), Fe(Ae, JSON.stringify(t));
|
|
274
|
+
}
|
|
275
|
+
function Z(e, t, n) {
|
|
276
|
+
let r = D[e] ?? je;
|
|
277
|
+
return /* @__PURE__ */ R(te, { children: [/* @__PURE__ */ L("ul", {
|
|
278
|
+
className: n,
|
|
279
|
+
children: t.slice(0, r).map((e) => /* @__PURE__ */ L(Be, {
|
|
280
|
+
row: e,
|
|
281
|
+
...ie
|
|
282
|
+
}, JSON.stringify(e.scope)))
|
|
283
|
+
}), t.length > r && /* @__PURE__ */ R("button", {
|
|
284
|
+
className: "cell-more",
|
|
285
|
+
onClick: () => ee((t) => ({
|
|
286
|
+
...t,
|
|
287
|
+
[e]: r + je
|
|
288
|
+
})),
|
|
289
|
+
children: [
|
|
290
|
+
"Show ",
|
|
291
|
+
Math.min(je, t.length - r),
|
|
292
|
+
" more cells"
|
|
293
|
+
]
|
|
294
|
+
})] });
|
|
295
|
+
}
|
|
296
|
+
let se = [...K.map((e) => ({
|
|
297
|
+
id: e.id,
|
|
298
|
+
agent: e
|
|
299
|
+
})), ...ne.length ? [{
|
|
300
|
+
id: Ne,
|
|
301
|
+
agent: void 0
|
|
302
|
+
}] : []], Q = se.slice(0, O), ce = C ? se.length : U.length;
|
|
303
|
+
return /* @__PURE__ */ R("section", {
|
|
304
|
+
className: "cell-navigation",
|
|
305
|
+
"aria-label": "All cells",
|
|
306
|
+
children: [
|
|
307
|
+
/* @__PURE__ */ R("div", {
|
|
308
|
+
className: "cell-navigation-heading",
|
|
309
|
+
children: [/* @__PURE__ */ L("h2", { children: "Cells" }), /* @__PURE__ */ L("span", { children: N.length })]
|
|
310
|
+
}),
|
|
311
|
+
(o || ae) && /* @__PURE__ */ R("div", {
|
|
312
|
+
className: "cell-navigation-controls",
|
|
313
|
+
children: [o && /* @__PURE__ */ R("label", { children: ["Search cells", /* @__PURE__ */ L("input", {
|
|
314
|
+
type: "search",
|
|
315
|
+
value: f,
|
|
316
|
+
placeholder: "Name or scope",
|
|
317
|
+
onChange: (e) => {
|
|
318
|
+
p(e.target.value), oe();
|
|
319
|
+
}
|
|
320
|
+
})] }), ae && /* @__PURE__ */ R("label", { children: ["Group by", /* @__PURE__ */ R("select", {
|
|
321
|
+
value: _,
|
|
322
|
+
onChange: (e) => {
|
|
323
|
+
v(e.target.value), oe();
|
|
324
|
+
},
|
|
325
|
+
children: [
|
|
326
|
+
/* @__PURE__ */ L("option", {
|
|
327
|
+
value: "",
|
|
328
|
+
children: "None"
|
|
329
|
+
}),
|
|
330
|
+
F.map((e) => /* @__PURE__ */ L("option", {
|
|
331
|
+
value: e,
|
|
332
|
+
children: e
|
|
333
|
+
}, e)),
|
|
334
|
+
_ && !F.includes(_) && /* @__PURE__ */ R("option", {
|
|
335
|
+
value: _,
|
|
336
|
+
children: [_, " (not in current inventory)"]
|
|
337
|
+
})
|
|
338
|
+
]
|
|
339
|
+
})] })]
|
|
340
|
+
}),
|
|
341
|
+
/* @__PURE__ */ R("div", {
|
|
342
|
+
className: "cell-navigation-results",
|
|
343
|
+
"aria-live": "polite",
|
|
344
|
+
children: [
|
|
345
|
+
t.loading && !t.data && /* @__PURE__ */ L("p", {
|
|
346
|
+
role: "status",
|
|
347
|
+
children: "Loading cells…"
|
|
348
|
+
}),
|
|
349
|
+
Y && /* @__PURE__ */ L("p", {
|
|
350
|
+
className: "cell-inventory-warning",
|
|
351
|
+
children: t.data ? "Inventory incomplete or stale. Refresh to retry." : "Cells unavailable. Refresh to retry."
|
|
352
|
+
}),
|
|
353
|
+
!t.loading && !Y && !N.length && /* @__PURE__ */ L("p", { children: P ? "No active cells." : "No cells found." }),
|
|
354
|
+
!!N.length && !I.length && /* @__PURE__ */ L("p", { children: "No matching cells." }),
|
|
355
|
+
!!I.length && /* @__PURE__ */ R("p", {
|
|
356
|
+
className: "cell-result-count",
|
|
357
|
+
children: [
|
|
358
|
+
I.length,
|
|
359
|
+
" ",
|
|
360
|
+
I.length === 1 ? "cell" : "cells",
|
|
361
|
+
Y ? " in retained inventory" : ""
|
|
362
|
+
]
|
|
363
|
+
})
|
|
364
|
+
]
|
|
365
|
+
}),
|
|
366
|
+
/* @__PURE__ */ R("nav", {
|
|
367
|
+
className: "cell-navigation-list",
|
|
368
|
+
"aria-label": "Cell navigation",
|
|
369
|
+
children: [
|
|
370
|
+
c && re && /* @__PURE__ */ L("p", {
|
|
371
|
+
className: "cell-group-scope",
|
|
372
|
+
title: "Scope shared by every listed cell",
|
|
373
|
+
children: /* @__PURE__ */ L(H, { parts: I[0].scope.slice(0, 3) })
|
|
374
|
+
}),
|
|
375
|
+
C ? /* @__PURE__ */ R(te, { children: [K.length > 0 && /* @__PURE__ */ L("h3", {
|
|
376
|
+
className: "cell-list-heading",
|
|
377
|
+
children: "Agents"
|
|
378
|
+
}), Q.map(({ id: t, agent: i }) => {
|
|
379
|
+
if (!i) return /* @__PURE__ */ R("section", {
|
|
380
|
+
className: "cell-group",
|
|
381
|
+
"aria-label": "Other cells",
|
|
382
|
+
children: [/* @__PURE__ */ L("h3", {
|
|
383
|
+
className: "cell-list-heading",
|
|
384
|
+
children: "Other cells"
|
|
385
|
+
}), Z(t, ne)]
|
|
386
|
+
}, t);
|
|
387
|
+
let a = Re(i.rows, u), o = Oe(a, d), s = a ? " has-unread" : "", c = /* @__PURE__ */ R("span", {
|
|
388
|
+
className: "agent-name",
|
|
389
|
+
children: [
|
|
390
|
+
/* @__PURE__ */ L(B, { name: "agent" }),
|
|
391
|
+
/* @__PURE__ */ R("span", { children: [i.displayName, a > 0 && /* @__PURE__ */ L(Le, {
|
|
392
|
+
bytes: a,
|
|
393
|
+
showBytes: d
|
|
394
|
+
})] }),
|
|
395
|
+
i.named && /* @__PURE__ */ L("span", {
|
|
396
|
+
className: "agent-internal mono-id",
|
|
397
|
+
children: i.name
|
|
398
|
+
}),
|
|
399
|
+
i.context && /* @__PURE__ */ L("span", {
|
|
400
|
+
className: "agent-context",
|
|
401
|
+
children: i.context
|
|
402
|
+
})
|
|
403
|
+
]
|
|
404
|
+
}), f = /* @__PURE__ */ R("small", { children: [i.rows.length, /* @__PURE__ */ R("span", {
|
|
405
|
+
className: "sr-only",
|
|
406
|
+
children: [" ", i.rows.length === 1 ? "instance" : "instances"]
|
|
407
|
+
})] }), p = m(i.rows);
|
|
408
|
+
if (q.get(t) === 1) {
|
|
409
|
+
let a = i.rows[0], u = a.scope.join(" / "), d = r[JSON.stringify(a.scope)];
|
|
410
|
+
return /* @__PURE__ */ L("section", {
|
|
411
|
+
className: "cell-group cell-agent",
|
|
412
|
+
"aria-label": `${i.displayName} agent`,
|
|
413
|
+
children: /* @__PURE__ */ R("a", {
|
|
414
|
+
className: `agent-row agent-link${s}`,
|
|
415
|
+
href: e(a.scope),
|
|
416
|
+
"aria-current": Ie(a.scope, n) ? "page" : void 0,
|
|
417
|
+
"aria-label": `${i.displayName}: open ${u} (${p || "state not reported"})${o}`,
|
|
418
|
+
title: u,
|
|
419
|
+
children: [
|
|
420
|
+
c,
|
|
421
|
+
f,
|
|
422
|
+
/* @__PURE__ */ L(V, { state: p }),
|
|
423
|
+
/* @__PURE__ */ L(z, { status: a.doc.status }),
|
|
424
|
+
l && d && /* @__PURE__ */ R("span", {
|
|
425
|
+
className: `cell-terminal-state ${d}`,
|
|
426
|
+
children: ["Terminal ", d]
|
|
427
|
+
})
|
|
428
|
+
]
|
|
429
|
+
})
|
|
430
|
+
}, t);
|
|
431
|
+
}
|
|
432
|
+
let h = T.includes(t), g = h && i.rows.some((e) => Ie(e.scope, n));
|
|
433
|
+
return /* @__PURE__ */ R("section", {
|
|
434
|
+
className: "cell-group cell-agent",
|
|
435
|
+
"aria-label": `${i.displayName} agent`,
|
|
436
|
+
children: [/* @__PURE__ */ R("button", {
|
|
437
|
+
className: `cell-group-toggle agent-row${g ? " has-current" : ""}${s}`,
|
|
438
|
+
"aria-expanded": !h,
|
|
439
|
+
onClick: () => X(t),
|
|
440
|
+
children: [
|
|
441
|
+
/* @__PURE__ */ L("span", {
|
|
442
|
+
"aria-hidden": "true",
|
|
443
|
+
children: h ? "▸" : "▾"
|
|
444
|
+
}),
|
|
445
|
+
c,
|
|
446
|
+
g && /* @__PURE__ */ L("span", {
|
|
447
|
+
className: "sr-only",
|
|
448
|
+
children: ", contains the open cell"
|
|
449
|
+
}),
|
|
450
|
+
f,
|
|
451
|
+
/* @__PURE__ */ L(V, { state: p }),
|
|
452
|
+
o && /* @__PURE__ */ L("span", {
|
|
453
|
+
className: "sr-only",
|
|
454
|
+
children: o
|
|
455
|
+
})
|
|
456
|
+
]
|
|
457
|
+
}), !h && Z(t, i.rows, "agent-instances")]
|
|
458
|
+
}, t);
|
|
459
|
+
})] }) : U.slice(0, O).map(({ id: e, label: t, rows: n }) => {
|
|
460
|
+
let r = !!_ && T.includes(e);
|
|
461
|
+
return /* @__PURE__ */ R("section", {
|
|
462
|
+
className: "cell-group",
|
|
463
|
+
"aria-label": _ ? `${t} group` : void 0,
|
|
464
|
+
children: [_ && /* @__PURE__ */ R("button", {
|
|
465
|
+
className: "cell-group-toggle",
|
|
466
|
+
"aria-expanded": !r,
|
|
467
|
+
onClick: () => X(e),
|
|
468
|
+
children: [
|
|
469
|
+
/* @__PURE__ */ L("span", {
|
|
470
|
+
"aria-hidden": "true",
|
|
471
|
+
children: r ? "▸" : "▾"
|
|
472
|
+
}),
|
|
473
|
+
/* @__PURE__ */ L("span", { children: t }),
|
|
474
|
+
/* @__PURE__ */ L("small", { children: n.length })
|
|
475
|
+
]
|
|
476
|
+
}), !r && Z(e, n)]
|
|
477
|
+
}, e);
|
|
478
|
+
}),
|
|
479
|
+
ce > O && /* @__PURE__ */ R("button", {
|
|
480
|
+
className: "cell-more",
|
|
481
|
+
onClick: () => k((e) => e + Me),
|
|
482
|
+
children: [
|
|
483
|
+
"Show ",
|
|
484
|
+
Math.min(Me, ce - O),
|
|
485
|
+
" more groups"
|
|
486
|
+
]
|
|
487
|
+
})
|
|
488
|
+
]
|
|
489
|
+
}),
|
|
490
|
+
/* @__PURE__ */ L(ze, { hidden: P })
|
|
491
|
+
]
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
// src/sidebar-shell.tsx
|
|
495
|
+
var He = "kukeon-sidebar-collapsed", Ue = "kukeon-sidebar-width", We = {
|
|
496
|
+
min: 208,
|
|
497
|
+
max: 480,
|
|
498
|
+
initial: 264,
|
|
499
|
+
step: 16
|
|
500
|
+
};
|
|
501
|
+
function Ge(e) {
|
|
502
|
+
return Math.round(Math.min(We.max, Math.max(We.min, e)));
|
|
503
|
+
}
|
|
504
|
+
function Ke() {
|
|
505
|
+
try {
|
|
506
|
+
return localStorage.getItem(He) === "true";
|
|
507
|
+
} catch {
|
|
508
|
+
return !1;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
function qe() {
|
|
512
|
+
try {
|
|
513
|
+
let e = Number(localStorage.getItem(Ue));
|
|
514
|
+
return Number.isFinite(e) && e > 0 ? Ge(e) : We.initial;
|
|
515
|
+
} catch {
|
|
516
|
+
return We.initial;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function Je(e, t) {
|
|
520
|
+
try {
|
|
521
|
+
localStorage.setItem(e, t);
|
|
522
|
+
} catch {}
|
|
523
|
+
}
|
|
524
|
+
function Ye() {
|
|
525
|
+
let [e, t] = M(Ke), [n, r] = M(qe);
|
|
526
|
+
return O(() => {
|
|
527
|
+
Je(He, String(e));
|
|
528
|
+
}, [e]), O(() => {
|
|
529
|
+
Je(Ue, String(n));
|
|
530
|
+
}, [n]), {
|
|
531
|
+
collapsed: e,
|
|
532
|
+
setCollapsed: t,
|
|
533
|
+
width: n,
|
|
534
|
+
setWidth: (e) => r(Ge(e))
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
function Xe() {
|
|
538
|
+
return /* @__PURE__ */ L("span", {
|
|
539
|
+
className: "mark",
|
|
540
|
+
"aria-hidden": "true",
|
|
541
|
+
children: /* @__PURE__ */ L(B, { name: "tornado" })
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
function Ze({ collapsed: e, onToggle: t }) {
|
|
545
|
+
let n = e ? "Expand sidebar" : "Collapse sidebar";
|
|
546
|
+
return /* @__PURE__ */ L("button", {
|
|
547
|
+
type: "button",
|
|
548
|
+
className: "icon-button sidebar-toggle",
|
|
549
|
+
"aria-label": n,
|
|
550
|
+
title: n,
|
|
551
|
+
"aria-expanded": !e,
|
|
552
|
+
"aria-controls": "cell-sidebar",
|
|
553
|
+
onClick: t,
|
|
554
|
+
children: /* @__PURE__ */ L(B, { name: e ? "sidebarExpand" : "sidebarCollapse" })
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
function Qe({ width: e, onResize: t }) {
|
|
558
|
+
let n = j(null);
|
|
559
|
+
function r(t) {
|
|
560
|
+
t.button === 0 && (t.preventDefault(), n.current = {
|
|
561
|
+
x: t.clientX,
|
|
562
|
+
width: e
|
|
563
|
+
}, t.currentTarget.setPointerCapture(t.pointerId));
|
|
564
|
+
}
|
|
565
|
+
function i(e) {
|
|
566
|
+
n.current && t(n.current.width + e.clientX - n.current.x);
|
|
567
|
+
}
|
|
568
|
+
function a(e) {
|
|
569
|
+
n.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId);
|
|
570
|
+
}
|
|
571
|
+
function o(n) {
|
|
572
|
+
let r = n.key === "ArrowLeft" ? e - We.step : n.key === "ArrowRight" ? e + We.step : n.key === "Home" ? We.min : n.key === "End" ? We.max : null;
|
|
573
|
+
r !== null && (n.preventDefault(), t(r));
|
|
574
|
+
}
|
|
575
|
+
return /* @__PURE__ */ L("div", {
|
|
576
|
+
className: "sidebar-resizer",
|
|
577
|
+
role: "separator",
|
|
578
|
+
"aria-orientation": "vertical",
|
|
579
|
+
"aria-label": "Resize sidebar",
|
|
580
|
+
"aria-controls": "cell-sidebar",
|
|
581
|
+
"aria-valuenow": e,
|
|
582
|
+
"aria-valuemin": We.min,
|
|
583
|
+
"aria-valuemax": We.max,
|
|
584
|
+
tabIndex: 0,
|
|
585
|
+
onPointerDown: r,
|
|
586
|
+
onPointerMove: i,
|
|
587
|
+
onPointerUp: a,
|
|
588
|
+
onPointerCancel: a,
|
|
589
|
+
onKeyDown: o
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
function $e(e) {
|
|
593
|
+
return e ? e.startsWith("v") ? e : `v${e}` : void 0;
|
|
594
|
+
}
|
|
595
|
+
function et(e, t) {
|
|
596
|
+
let n = $e(e), r = $e(t), i = !!n && !!r && n !== r;
|
|
597
|
+
return {
|
|
598
|
+
web: n,
|
|
599
|
+
daemon: r,
|
|
600
|
+
mismatch: i,
|
|
601
|
+
summary: `web ${n ?? "unknown"} · daemon ${r ?? "unknown"}`,
|
|
602
|
+
warning: i ? `Version mismatch: web ${n} ≠ daemon ${r}` : ""
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
function tt({ label: e }) {
|
|
606
|
+
return /* @__PURE__ */ L("span", {
|
|
607
|
+
className: "version-warning",
|
|
608
|
+
role: "img",
|
|
609
|
+
"aria-label": e,
|
|
610
|
+
title: e,
|
|
611
|
+
children: /* @__PURE__ */ L(B, { name: "warning" })
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
function nt({ info: e }) {
|
|
615
|
+
return /* @__PURE__ */ R("div", {
|
|
616
|
+
className: "connection-versions",
|
|
617
|
+
children: [/* @__PURE__ */ R("dl", {
|
|
618
|
+
"aria-label": "Versions",
|
|
619
|
+
children: [/* @__PURE__ */ R("div", { children: [/* @__PURE__ */ L("dt", { children: "web" }), /* @__PURE__ */ L("dd", { children: e.web ?? "unknown" })] }), /* @__PURE__ */ R("div", { children: [/* @__PURE__ */ L("dt", { children: "daemon" }), /* @__PURE__ */ L("dd", { children: e.daemon ?? "unknown" })] })]
|
|
620
|
+
}), e.mismatch && /* @__PURE__ */ L(tt, { label: e.warning })]
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
function rt({ view: t, inventory: n, selectedScope: r, connection: i, onExpand: o, majordomo: s, listStyle: c = "default", unread: l = {}, showUnreadBytes: u = !1 }) {
|
|
624
|
+
let d = x(n.data?.rows[3] ?? [], r), f = n.data?.configs, { agents: p, others: h } = b(d, f), _ = c === "agent" ? g(n.data?.rows[3] ?? [], f) : /* @__PURE__ */ new Map(), v = `Daemon: ${i.status} · ${i.info.summary}`, y = (e) => r.length === 4 && e.scope.every((e, t) => e === r[t]), S = (t) => {
|
|
625
|
+
let n = t.doc.status?.state, r = _.get(JSON.stringify(t.scope)), i = l[JSON.stringify(t.scope)]?.unreadBytes ?? 0, a = `Open ${r ? `${r} (${t.scope.join(" / ")})` : t.scope.join(" / ")} (${n || "state not reported"})${Oe(i, u)}`;
|
|
626
|
+
return /* @__PURE__ */ L("li", { children: /* @__PURE__ */ L("a", {
|
|
627
|
+
className: `rail-cell tone-${G(n)}${i ? " has-unread" : ""}`,
|
|
628
|
+
href: e(t.scope),
|
|
629
|
+
"aria-label": a,
|
|
630
|
+
title: a,
|
|
631
|
+
"aria-current": y(t) ? "page" : void 0,
|
|
632
|
+
children: /* @__PURE__ */ L("span", {
|
|
633
|
+
className: "state-dot",
|
|
634
|
+
"aria-hidden": "true"
|
|
635
|
+
})
|
|
636
|
+
}) }, JSON.stringify(t.scope));
|
|
637
|
+
};
|
|
638
|
+
return /* @__PURE__ */ R("div", {
|
|
639
|
+
className: "sidebar-rail",
|
|
640
|
+
children: [
|
|
641
|
+
/* @__PURE__ */ L("a", {
|
|
642
|
+
className: "rail-brand",
|
|
643
|
+
href: a(),
|
|
644
|
+
"aria-label": "kukeon home",
|
|
645
|
+
title: "kukeon",
|
|
646
|
+
children: /* @__PURE__ */ L(Xe, {})
|
|
647
|
+
}),
|
|
648
|
+
/* @__PURE__ */ L(Ze, {
|
|
649
|
+
collapsed: !0,
|
|
650
|
+
onToggle: o
|
|
651
|
+
}),
|
|
652
|
+
s,
|
|
653
|
+
t === "workbench" ? /* @__PURE__ */ L("nav", {
|
|
654
|
+
className: "rail-cells",
|
|
655
|
+
"aria-label": "Cell shortcuts",
|
|
656
|
+
children: c === "agent" ? /* @__PURE__ */ R("ul", { children: [p.map((t) => {
|
|
657
|
+
let n = `${t.rows.length} ${t.rows.length === 1 ? "instance" : "instances"}`, r = Re(t.rows, l), i = Oe(r, u), a = `Agent ${t.displayName}${t.context ? ` (${t.context})` : ""}, ${n}`, o = `rail-agent-glyph tone-${G(m(t.rows))}${r ? " has-unread" : ""}`;
|
|
658
|
+
if (t.rows.length === 1) {
|
|
659
|
+
let n = t.rows[0], r = `${a}: open ${n.scope.join(" / ")} (${n.doc.status?.state || "state not reported"})${i}`;
|
|
660
|
+
return /* @__PURE__ */ L("li", {
|
|
661
|
+
className: "rail-agent",
|
|
662
|
+
children: /* @__PURE__ */ L("a", {
|
|
663
|
+
className: o,
|
|
664
|
+
href: e(n.scope),
|
|
665
|
+
"aria-label": r,
|
|
666
|
+
title: r,
|
|
667
|
+
"aria-current": y(n) ? "page" : void 0,
|
|
668
|
+
children: /* @__PURE__ */ L(B, { name: "agent" })
|
|
669
|
+
})
|
|
670
|
+
}, t.id);
|
|
671
|
+
}
|
|
672
|
+
return /* @__PURE__ */ R("li", {
|
|
673
|
+
className: "rail-agent",
|
|
674
|
+
children: [/* @__PURE__ */ L("span", {
|
|
675
|
+
className: o,
|
|
676
|
+
role: "img",
|
|
677
|
+
"aria-label": a + i,
|
|
678
|
+
title: a + i,
|
|
679
|
+
children: /* @__PURE__ */ L(B, { name: "agent" })
|
|
680
|
+
}), /* @__PURE__ */ L("ul", { children: t.rows.map(S) })]
|
|
681
|
+
}, t.id);
|
|
682
|
+
}), h.length > 0 && /* @__PURE__ */ L("li", {
|
|
683
|
+
className: "rail-others",
|
|
684
|
+
children: /* @__PURE__ */ L("ul", {
|
|
685
|
+
"aria-label": "Other cells",
|
|
686
|
+
children: h.map(S)
|
|
687
|
+
})
|
|
688
|
+
})] }) : /* @__PURE__ */ L("ul", { children: d.map(S) })
|
|
689
|
+
}) : /* @__PURE__ */ L("div", { className: "rail-spacer" }),
|
|
690
|
+
/* @__PURE__ */ R("div", {
|
|
691
|
+
className: "rail-connection",
|
|
692
|
+
children: [/* @__PURE__ */ L("span", {
|
|
693
|
+
className: "rail-connection-dot",
|
|
694
|
+
role: "status",
|
|
695
|
+
"aria-label": v,
|
|
696
|
+
title: v,
|
|
697
|
+
children: /* @__PURE__ */ L("span", {
|
|
698
|
+
className: `dot ${i.tone}`,
|
|
699
|
+
"aria-hidden": "true"
|
|
700
|
+
})
|
|
701
|
+
}), i.info.mismatch && /* @__PURE__ */ L(tt, { label: i.info.warning })]
|
|
702
|
+
})
|
|
703
|
+
]
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
// src/auth.tsx
|
|
707
|
+
var it = "root", at = "kuke get secret web-ui-admin --realm kuke-system -o yaml";
|
|
708
|
+
async function ot(e) {
|
|
709
|
+
try {
|
|
710
|
+
let t = await e.json();
|
|
711
|
+
if (t?.error && typeof t.error.code == "string") return {
|
|
712
|
+
code: t.error.code,
|
|
713
|
+
message: String(t.error.message ?? "")
|
|
714
|
+
};
|
|
715
|
+
} catch {}
|
|
716
|
+
return {
|
|
717
|
+
code: e.status === 401 ? "unauthenticated" : "unavailable",
|
|
718
|
+
message: `HTTP ${e.status}`
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
var st = {
|
|
722
|
+
async session() {
|
|
723
|
+
try {
|
|
724
|
+
let e = await P("/session", { headers: { Accept: "application/json" } });
|
|
725
|
+
if (e.ok) {
|
|
726
|
+
let t = await e.json();
|
|
727
|
+
return {
|
|
728
|
+
phase: "signed-in",
|
|
729
|
+
user: typeof t?.user == "string" ? t.user : it
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
return e.status === 401 ? { phase: "signed-out" } : {
|
|
733
|
+
phase: "unavailable",
|
|
734
|
+
error: await ot(e)
|
|
735
|
+
};
|
|
736
|
+
} catch (e) {
|
|
737
|
+
return {
|
|
738
|
+
phase: "unavailable",
|
|
739
|
+
error: r(e)
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
},
|
|
743
|
+
async signOut() {
|
|
744
|
+
try {
|
|
745
|
+
await P("/logout", {
|
|
746
|
+
method: "POST",
|
|
747
|
+
headers: {
|
|
748
|
+
Accept: "application/json",
|
|
749
|
+
"Content-Type": "application/json"
|
|
750
|
+
},
|
|
751
|
+
body: "{}"
|
|
752
|
+
});
|
|
753
|
+
} catch {}
|
|
754
|
+
},
|
|
755
|
+
endsSession: (e) => e !== "/login",
|
|
756
|
+
SignIn: ht
|
|
757
|
+
}, ct = st;
|
|
758
|
+
function lt(e = st) {
|
|
759
|
+
ct = e;
|
|
760
|
+
}
|
|
761
|
+
function ut() {
|
|
762
|
+
return ct;
|
|
763
|
+
}
|
|
764
|
+
var dt = /* @__PURE__ */ new Set();
|
|
765
|
+
function ft() {
|
|
766
|
+
for (let e of [...dt]) e();
|
|
767
|
+
}
|
|
768
|
+
function pt() {
|
|
769
|
+
ct.session().then((e) => {
|
|
770
|
+
e.phase === "signed-out" && ft();
|
|
771
|
+
}, () => {});
|
|
772
|
+
}
|
|
773
|
+
function mt() {
|
|
774
|
+
let [e, t] = M({ phase: "checking" }), n = D(async () => {
|
|
775
|
+
t({ phase: "checking" });
|
|
776
|
+
try {
|
|
777
|
+
t(await ct.session());
|
|
778
|
+
} catch (e) {
|
|
779
|
+
t({
|
|
780
|
+
phase: "unavailable",
|
|
781
|
+
error: r(e)
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
}, []);
|
|
785
|
+
return O(() => {
|
|
786
|
+
n();
|
|
787
|
+
}, [n]), O(() => {
|
|
788
|
+
let e = () => t((e) => e.phase === "signed-in" ? { phase: "signed-out" } : e), n = I((t) => {
|
|
789
|
+
ct.endsSession(t) && e();
|
|
790
|
+
});
|
|
791
|
+
return dt.add(e), () => {
|
|
792
|
+
n(), dt.delete(e);
|
|
793
|
+
};
|
|
794
|
+
}, []), {
|
|
795
|
+
session: e,
|
|
796
|
+
retry: n,
|
|
797
|
+
signedIn: D((e) => t({
|
|
798
|
+
phase: "signed-in",
|
|
799
|
+
user: e
|
|
800
|
+
}), []),
|
|
801
|
+
signOut: D(async () => {
|
|
802
|
+
try {
|
|
803
|
+
await ct.signOut();
|
|
804
|
+
} catch {}
|
|
805
|
+
t({ phase: "signed-out" });
|
|
806
|
+
}, [])
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
function ht({ notice: e, checking: t, onRetry: n, onSignedIn: i }) {
|
|
810
|
+
let [a, o] = M(it), [s, l] = M(""), [u, d] = M(), [f, p] = M(!1);
|
|
811
|
+
async function m(e) {
|
|
812
|
+
if (e.preventDefault(), !f) {
|
|
813
|
+
p(!0), d(void 0);
|
|
814
|
+
try {
|
|
815
|
+
let e = await P("/login", {
|
|
816
|
+
method: "POST",
|
|
817
|
+
headers: {
|
|
818
|
+
Accept: "application/json",
|
|
819
|
+
"Content-Type": "application/json"
|
|
820
|
+
},
|
|
821
|
+
body: JSON.stringify({
|
|
822
|
+
username: a,
|
|
823
|
+
password: s
|
|
824
|
+
})
|
|
825
|
+
});
|
|
826
|
+
if (e.ok) {
|
|
827
|
+
let t = await e.json().catch(() => ({}));
|
|
828
|
+
i(typeof t?.user == "string" ? t.user : a);
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
d(await ot(e)), l("");
|
|
832
|
+
} catch (e) {
|
|
833
|
+
d(r(e));
|
|
834
|
+
} finally {
|
|
835
|
+
p(!1);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
return /* @__PURE__ */ L("main", {
|
|
840
|
+
className: "login-screen",
|
|
841
|
+
id: "main-content",
|
|
842
|
+
children: /* @__PURE__ */ R("form", {
|
|
843
|
+
className: "login-card",
|
|
844
|
+
onSubmit: m,
|
|
845
|
+
"aria-labelledby": "login-title",
|
|
846
|
+
children: [
|
|
847
|
+
/* @__PURE__ */ R("div", {
|
|
848
|
+
className: "login-brand",
|
|
849
|
+
children: [/* @__PURE__ */ L(Xe, {}), /* @__PURE__ */ L("span", {
|
|
850
|
+
className: "brand-title",
|
|
851
|
+
children: "kukeon"
|
|
852
|
+
})]
|
|
853
|
+
}),
|
|
854
|
+
/* @__PURE__ */ L("h1", {
|
|
855
|
+
id: "login-title",
|
|
856
|
+
children: "Sign in"
|
|
857
|
+
}),
|
|
858
|
+
t && /* @__PURE__ */ L("p", {
|
|
859
|
+
className: "login-status",
|
|
860
|
+
role: "status",
|
|
861
|
+
children: "Checking session…"
|
|
862
|
+
}),
|
|
863
|
+
e && /* @__PURE__ */ R("div", {
|
|
864
|
+
className: "error",
|
|
865
|
+
role: "alert",
|
|
866
|
+
children: [
|
|
867
|
+
/* @__PURE__ */ L("strong", { children: c(e) }),
|
|
868
|
+
/* @__PURE__ */ L("p", { children: e.message }),
|
|
869
|
+
/* @__PURE__ */ L("button", {
|
|
870
|
+
type: "button",
|
|
871
|
+
onClick: n,
|
|
872
|
+
children: "Retry"
|
|
873
|
+
})
|
|
874
|
+
]
|
|
875
|
+
}),
|
|
876
|
+
/* @__PURE__ */ R("label", { children: ["User", /* @__PURE__ */ L("input", {
|
|
877
|
+
name: "username",
|
|
878
|
+
autoComplete: "username",
|
|
879
|
+
value: a,
|
|
880
|
+
onChange: (e) => o(e.target.value),
|
|
881
|
+
required: !0
|
|
882
|
+
})] }),
|
|
883
|
+
/* @__PURE__ */ R("label", { children: ["Password", /* @__PURE__ */ L("input", {
|
|
884
|
+
name: "password",
|
|
885
|
+
type: "password",
|
|
886
|
+
autoComplete: "current-password",
|
|
887
|
+
value: s,
|
|
888
|
+
onChange: (e) => l(e.target.value),
|
|
889
|
+
required: !0,
|
|
890
|
+
autoFocus: !0
|
|
891
|
+
})] }),
|
|
892
|
+
u && /* @__PURE__ */ L("div", {
|
|
893
|
+
className: "error",
|
|
894
|
+
role: "alert",
|
|
895
|
+
children: /* @__PURE__ */ L("p", { children: u.message })
|
|
896
|
+
}),
|
|
897
|
+
/* @__PURE__ */ L("button", {
|
|
898
|
+
className: "primary-action",
|
|
899
|
+
type: "submit",
|
|
900
|
+
disabled: f,
|
|
901
|
+
children: f ? "Signing in…" : "Sign in"
|
|
902
|
+
}),
|
|
903
|
+
/* @__PURE__ */ R("p", {
|
|
904
|
+
className: "login-hint",
|
|
905
|
+
children: ["Print the password on the host with ", /* @__PURE__ */ L("code", { children: at })]
|
|
906
|
+
})
|
|
907
|
+
]
|
|
908
|
+
})
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
// src/container-log.tsx
|
|
912
|
+
var gt = 262144, _t = 2e3, vt = 8;
|
|
913
|
+
async function yt(e, t, n, r) {
|
|
914
|
+
let i = `${f(e)}/containers/${encodeURIComponent(t)}/log?offset=${n}&maxBytes=${gt}`, a = await P(i, {
|
|
915
|
+
signal: r,
|
|
916
|
+
headers: { Accept: "application/json" }
|
|
917
|
+
}), o = {};
|
|
918
|
+
try {
|
|
919
|
+
o = await a.json();
|
|
920
|
+
} catch {}
|
|
921
|
+
if (a.status === 404 && o.error?.code === "log_unavailable") return null;
|
|
922
|
+
if (!a.ok) throw o.error ?? {
|
|
923
|
+
code: "http_error",
|
|
924
|
+
message: `HTTP ${a.status}`
|
|
925
|
+
};
|
|
926
|
+
return o;
|
|
927
|
+
}
|
|
928
|
+
var bt = (e) => e ? Uint8Array.from(atob(e), (e) => e.charCodeAt(0)) : /* @__PURE__ */ new Uint8Array();
|
|
929
|
+
function xt({ scope: e, container: t, attachable: n, live: i, cellState: a, revision: o, theme: c, expanded: l }) {
|
|
930
|
+
let u = j(null), d = j(null), f = j(() => {}), p = j(null), m = j(null), h = j(!1), g = j(!1), [_, v] = M(!1), [y, b] = M(!1), [x, S] = M();
|
|
931
|
+
async function C(n) {
|
|
932
|
+
if (h.current) g.current = !0;
|
|
933
|
+
else {
|
|
934
|
+
h.current = !0;
|
|
935
|
+
try {
|
|
936
|
+
for (let r = 0; r < vt; r++) {
|
|
937
|
+
let r = m.current === null, i = await yt(e, t, r ? -1 : m.current, n);
|
|
938
|
+
if (n.aborted) return;
|
|
939
|
+
if (S(void 0), i === null) {
|
|
940
|
+
v(!0);
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
if (!r && (i.size ?? 0) < m.current) {
|
|
944
|
+
m.current = null;
|
|
945
|
+
continue;
|
|
946
|
+
}
|
|
947
|
+
r && (d.current?.reset(), b(!!i.truncated));
|
|
948
|
+
let a = bt(i.data);
|
|
949
|
+
if (a.length && d.current?.write(a), m.current = i.next ?? m.current, v((i.size ?? 0) === 0), !i.more) return;
|
|
950
|
+
}
|
|
951
|
+
} catch (e) {
|
|
952
|
+
n.aborted || S(r(e));
|
|
953
|
+
} finally {
|
|
954
|
+
h.current = !1;
|
|
955
|
+
let e = p.current?.signal;
|
|
956
|
+
g.current && e && !e.aborted && (g.current = !1, C(e));
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
let w = j(C);
|
|
961
|
+
return w.current = C, O(() => {
|
|
962
|
+
if (!u.current) return;
|
|
963
|
+
let e = new q({
|
|
964
|
+
disableStdin: !0,
|
|
965
|
+
cursorBlink: !1,
|
|
966
|
+
cursorStyle: "underline",
|
|
967
|
+
cursorInactiveStyle: "none",
|
|
968
|
+
convertEol: !n,
|
|
969
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace",
|
|
970
|
+
fontSize: 14,
|
|
971
|
+
scrollback: 1e4,
|
|
972
|
+
theme: Zt(c)
|
|
973
|
+
}), t = new J();
|
|
974
|
+
d.current = e, p.current = new AbortController(), m.current = null, e.loadAddon(t), e.open(u.current);
|
|
975
|
+
let r = 0, i = () => {
|
|
976
|
+
r && cancelAnimationFrame(r), r = requestAnimationFrame(() => {
|
|
977
|
+
r = 0, u.current?.clientWidth && u.current.clientHeight && t.fit();
|
|
978
|
+
});
|
|
979
|
+
};
|
|
980
|
+
f.current = i;
|
|
981
|
+
let a = new ResizeObserver(i);
|
|
982
|
+
return a.observe(u.current), u.current.parentElement && a.observe(u.current.parentElement), window.addEventListener("resize", i), window.visualViewport?.addEventListener("resize", i), () => {
|
|
983
|
+
a.disconnect(), window.removeEventListener("resize", i), window.visualViewport?.removeEventListener("resize", i), r && cancelAnimationFrame(r), p.current?.abort(), p.current = null, e.dispose(), d.current = null, f.current = () => {};
|
|
984
|
+
};
|
|
985
|
+
}, []), O(() => {
|
|
986
|
+
let e = () => {
|
|
987
|
+
d.current && (d.current.options.theme = Zt(c));
|
|
988
|
+
};
|
|
989
|
+
if (e(), c !== "system") return;
|
|
990
|
+
let t = window.matchMedia("(prefers-color-scheme: dark)");
|
|
991
|
+
return t.addEventListener("change", e), () => t.removeEventListener("change", e);
|
|
992
|
+
}, [c]), O(() => {
|
|
993
|
+
let e = requestAnimationFrame(() => f.current());
|
|
994
|
+
return () => cancelAnimationFrame(e);
|
|
995
|
+
}, [l]), O(() => {
|
|
996
|
+
let e = p.current?.signal;
|
|
997
|
+
e && w.current(e);
|
|
998
|
+
}, [o, a]), O(() => {
|
|
999
|
+
if (!i) return;
|
|
1000
|
+
let e = setInterval(() => {
|
|
1001
|
+
let e = p.current?.signal;
|
|
1002
|
+
e && document.visibilityState === "visible" && w.current(e);
|
|
1003
|
+
}, _t);
|
|
1004
|
+
return () => clearInterval(e);
|
|
1005
|
+
}, [i]), /* @__PURE__ */ R("div", {
|
|
1006
|
+
className: "terminal-session terminal-log",
|
|
1007
|
+
children: [
|
|
1008
|
+
_ && !x && /* @__PURE__ */ L("p", {
|
|
1009
|
+
className: "empty-state terminal-empty",
|
|
1010
|
+
role: "status",
|
|
1011
|
+
children: "No output yet."
|
|
1012
|
+
}),
|
|
1013
|
+
x && /* @__PURE__ */ L(s, {
|
|
1014
|
+
error: x,
|
|
1015
|
+
kind: "Container log"
|
|
1016
|
+
}),
|
|
1017
|
+
y && !_ && /* @__PURE__ */ L("p", {
|
|
1018
|
+
className: "terminal-log-omitted",
|
|
1019
|
+
children: "Earlier output is not shown."
|
|
1020
|
+
}),
|
|
1021
|
+
/* @__PURE__ */ L("div", {
|
|
1022
|
+
className: "terminal-screen",
|
|
1023
|
+
hidden: _,
|
|
1024
|
+
"aria-label": `Log for ${e.join(" / ")} / ${t}`,
|
|
1025
|
+
children: /* @__PURE__ */ L("div", {
|
|
1026
|
+
ref: u,
|
|
1027
|
+
className: "terminal-mount"
|
|
1028
|
+
})
|
|
1029
|
+
})
|
|
1030
|
+
]
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
// src/exec.tsx
|
|
1034
|
+
var St = [{
|
|
1035
|
+
id: "run",
|
|
1036
|
+
label: "Run command"
|
|
1037
|
+
}, {
|
|
1038
|
+
id: "terminal",
|
|
1039
|
+
label: "Terminal"
|
|
1040
|
+
}];
|
|
1041
|
+
function Ct({ container: e, open: t, reason: n, onToggle: r }) {
|
|
1042
|
+
let i = n || (t ? `Close Exec for ${e}` : `Exec: run a command or open a shell in ${e}`);
|
|
1043
|
+
return /* @__PURE__ */ L("button", {
|
|
1044
|
+
type: "button",
|
|
1045
|
+
className: "icon-button exec-button",
|
|
1046
|
+
"aria-label": "Exec",
|
|
1047
|
+
"aria-expanded": t,
|
|
1048
|
+
title: i,
|
|
1049
|
+
"data-tooltip": i,
|
|
1050
|
+
disabled: !!n,
|
|
1051
|
+
onClick: r,
|
|
1052
|
+
children: /* @__PURE__ */ L(B, { name: "exec" })
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
function wt({ target: e, onCancel: t, onConfirm: n }) {
|
|
1056
|
+
let r = j(null);
|
|
1057
|
+
return K(r), /* @__PURE__ */ L("dialog", {
|
|
1058
|
+
className: "cell-action-dialog exec-root-dialog",
|
|
1059
|
+
ref: r,
|
|
1060
|
+
"aria-labelledby": "exec-root-dialog-title",
|
|
1061
|
+
"aria-describedby": "exec-root-dialog-description",
|
|
1062
|
+
onCancel: (e) => {
|
|
1063
|
+
e.preventDefault(), t();
|
|
1064
|
+
},
|
|
1065
|
+
onClick: (e) => {
|
|
1066
|
+
e.target === e.currentTarget && t();
|
|
1067
|
+
},
|
|
1068
|
+
children: /* @__PURE__ */ R("form", {
|
|
1069
|
+
onSubmit: (e) => {
|
|
1070
|
+
e.preventDefault(), n();
|
|
1071
|
+
},
|
|
1072
|
+
children: [
|
|
1073
|
+
/* @__PURE__ */ L("h2", {
|
|
1074
|
+
id: "exec-root-dialog-title",
|
|
1075
|
+
children: "Run as root"
|
|
1076
|
+
}),
|
|
1077
|
+
/* @__PURE__ */ L("p", {
|
|
1078
|
+
id: "exec-root-dialog-description",
|
|
1079
|
+
children: "Commands and shells started from this panel will run as root (uid 0, gid 0) inside the container, whatever user the container itself runs as. kukeond records every root exec in its log. Changes made this way are lost when the cell is recreated."
|
|
1080
|
+
}),
|
|
1081
|
+
/* @__PURE__ */ R("dl", {
|
|
1082
|
+
className: "cell-action-target",
|
|
1083
|
+
children: [/* @__PURE__ */ L("dt", { children: "Container" }), /* @__PURE__ */ L("dd", { children: /* @__PURE__ */ L("code", { children: e }) })]
|
|
1084
|
+
}),
|
|
1085
|
+
/* @__PURE__ */ R("div", {
|
|
1086
|
+
className: "cell-action-dialog-buttons",
|
|
1087
|
+
children: [/* @__PURE__ */ L("button", {
|
|
1088
|
+
type: "button",
|
|
1089
|
+
onClick: t,
|
|
1090
|
+
children: "Cancel"
|
|
1091
|
+
}), /* @__PURE__ */ L("button", {
|
|
1092
|
+
className: "danger-action",
|
|
1093
|
+
type: "submit",
|
|
1094
|
+
children: "Run as root"
|
|
1095
|
+
})]
|
|
1096
|
+
})
|
|
1097
|
+
]
|
|
1098
|
+
})
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
function Tt({ scope: e, container: t, theme: n, visible: i, expanded: a, onClose: o }) {
|
|
1102
|
+
let c = k(), l = [...e, t].join(" / "), u = `${f(e)}/containers/${encodeURIComponent(t)}/exec`, d = j(null), p = j(null), [m, h] = M("container"), [g, _] = M(!1), [v, y] = M(!1), [b, x] = M("run"), [S, C] = M(""), [w, T] = M(!1), [E, ee] = M(), [N, F] = M(), [I, z] = M(!1), [B, V] = M({
|
|
1103
|
+
generation: 0,
|
|
1104
|
+
state: "connecting",
|
|
1105
|
+
message: "Connecting…"
|
|
1106
|
+
}), H = m === "root" && g;
|
|
1107
|
+
O(() => {
|
|
1108
|
+
let e = W();
|
|
1109
|
+
return p.current?.focus(), e;
|
|
1110
|
+
}, []);
|
|
1111
|
+
let U = (e) => {
|
|
1112
|
+
e !== m && (e === "root" && !g ? y(!0) : (h(e), K()));
|
|
1113
|
+
}, G = () => {
|
|
1114
|
+
y(!1), _(!0), h("root"), K();
|
|
1115
|
+
}, K = () => V((e) => ({
|
|
1116
|
+
generation: e.generation + 1,
|
|
1117
|
+
state: "connecting",
|
|
1118
|
+
message: "Connecting…"
|
|
1119
|
+
}));
|
|
1120
|
+
async function ne(e) {
|
|
1121
|
+
if (e.preventDefault(), !w && S.trim()) {
|
|
1122
|
+
T(!0), F(void 0);
|
|
1123
|
+
try {
|
|
1124
|
+
let e = await P(u, {
|
|
1125
|
+
method: "POST",
|
|
1126
|
+
headers: {
|
|
1127
|
+
Accept: "application/json",
|
|
1128
|
+
"Content-Type": "application/json"
|
|
1129
|
+
},
|
|
1130
|
+
body: JSON.stringify({
|
|
1131
|
+
command: S,
|
|
1132
|
+
identity: H ? "root" : "container",
|
|
1133
|
+
...H ? { confirmRoot: !0 } : {}
|
|
1134
|
+
})
|
|
1135
|
+
}), t = await e.json();
|
|
1136
|
+
if (!e.ok) throw t.error ?? {
|
|
1137
|
+
code: "http_error",
|
|
1138
|
+
message: `HTTP ${e.status}`
|
|
1139
|
+
};
|
|
1140
|
+
ee(t);
|
|
1141
|
+
} catch (e) {
|
|
1142
|
+
ee(void 0), F(r(e));
|
|
1143
|
+
} finally {
|
|
1144
|
+
T(!1);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
let q = JSON.stringify(e), J = A(() => ({
|
|
1149
|
+
id: `exec:${Jt(e, t)}`,
|
|
1150
|
+
scope: e,
|
|
1151
|
+
container: t,
|
|
1152
|
+
view: "main",
|
|
1153
|
+
state: B.state,
|
|
1154
|
+
message: B.message,
|
|
1155
|
+
generation: B.generation
|
|
1156
|
+
}), [
|
|
1157
|
+
q,
|
|
1158
|
+
t,
|
|
1159
|
+
B.state,
|
|
1160
|
+
B.message,
|
|
1161
|
+
B.generation
|
|
1162
|
+
]), re = D((e, t, n, r) => {
|
|
1163
|
+
V((e) => e.generation === t ? {
|
|
1164
|
+
...e,
|
|
1165
|
+
state: n,
|
|
1166
|
+
message: r
|
|
1167
|
+
} : e);
|
|
1168
|
+
}, []), Y = A(() => ({
|
|
1169
|
+
path: `${u}/terminal?identity=${H ? "root&confirmRoot=1" : "container"}`,
|
|
1170
|
+
label: `Exec terminal for ${l}`
|
|
1171
|
+
}), [
|
|
1172
|
+
u,
|
|
1173
|
+
H,
|
|
1174
|
+
l
|
|
1175
|
+
]), ie = (e) => {
|
|
1176
|
+
x(e), e === "terminal" && z(!0);
|
|
1177
|
+
};
|
|
1178
|
+
function ae(e) {
|
|
1179
|
+
let t = St.findIndex((e) => e.id === b), n = e.key === "ArrowRight" ? t + 1 : e.key === "ArrowLeft" ? t - 1 : e.key === "Home" ? 0 : e.key === "End" ? St.length - 1 : null;
|
|
1180
|
+
n !== null && (e.preventDefault(), ie(St[(n + St.length) % St.length].id), requestAnimationFrame(() => d.current?.querySelector("[role=\"tab\"][aria-selected=\"true\"]")?.focus()));
|
|
1181
|
+
}
|
|
1182
|
+
function oe(e) {
|
|
1183
|
+
e.key !== "Escape" || e.target.closest(".terminal-screen, dialog") || (e.preventDefault(), e.stopPropagation(), o());
|
|
1184
|
+
}
|
|
1185
|
+
let X = B.state === "disconnected";
|
|
1186
|
+
return /* @__PURE__ */ R("section", {
|
|
1187
|
+
className: `exec-panel${a ? " is-expanded" : ""}`,
|
|
1188
|
+
ref: d,
|
|
1189
|
+
role: "group",
|
|
1190
|
+
"aria-labelledby": `${c}-title`,
|
|
1191
|
+
onKeyDown: oe,
|
|
1192
|
+
children: [
|
|
1193
|
+
/* @__PURE__ */ R("header", {
|
|
1194
|
+
className: "exec-panel-header",
|
|
1195
|
+
children: [
|
|
1196
|
+
/* @__PURE__ */ R("h2", {
|
|
1197
|
+
id: `${c}-title`,
|
|
1198
|
+
children: ["Exec in ", /* @__PURE__ */ L("code", { children: t })]
|
|
1199
|
+
}),
|
|
1200
|
+
/* @__PURE__ */ R("fieldset", {
|
|
1201
|
+
className: "exec-identity",
|
|
1202
|
+
children: [
|
|
1203
|
+
/* @__PURE__ */ L("legend", { children: "Run as" }),
|
|
1204
|
+
/* @__PURE__ */ R("label", { children: [/* @__PURE__ */ L("input", {
|
|
1205
|
+
type: "radio",
|
|
1206
|
+
name: `${c}-identity`,
|
|
1207
|
+
checked: m === "container",
|
|
1208
|
+
onChange: () => U("container")
|
|
1209
|
+
}), "Container user"] }),
|
|
1210
|
+
/* @__PURE__ */ R("label", { children: [/* @__PURE__ */ L("input", {
|
|
1211
|
+
type: "radio",
|
|
1212
|
+
name: `${c}-identity`,
|
|
1213
|
+
checked: m === "root",
|
|
1214
|
+
onChange: () => U("root")
|
|
1215
|
+
}), "root"] })
|
|
1216
|
+
]
|
|
1217
|
+
}),
|
|
1218
|
+
/* @__PURE__ */ L("div", {
|
|
1219
|
+
className: "exec-tabs",
|
|
1220
|
+
role: "tablist",
|
|
1221
|
+
"aria-label": "Exec mode",
|
|
1222
|
+
onKeyDown: ae,
|
|
1223
|
+
children: St.map((e) => /* @__PURE__ */ L("button", {
|
|
1224
|
+
type: "button",
|
|
1225
|
+
role: "tab",
|
|
1226
|
+
className: "exec-tab",
|
|
1227
|
+
id: `${c}-tab-${e.id}`,
|
|
1228
|
+
"aria-selected": b === e.id,
|
|
1229
|
+
"aria-controls": `${c}-panel-${e.id}`,
|
|
1230
|
+
tabIndex: b === e.id ? 0 : -1,
|
|
1231
|
+
onClick: () => ie(e.id),
|
|
1232
|
+
children: e.label
|
|
1233
|
+
}, e.id))
|
|
1234
|
+
}),
|
|
1235
|
+
/* @__PURE__ */ L("button", {
|
|
1236
|
+
type: "button",
|
|
1237
|
+
className: "exec-close",
|
|
1238
|
+
"aria-label": "Close Exec",
|
|
1239
|
+
onClick: o,
|
|
1240
|
+
children: "Close"
|
|
1241
|
+
})
|
|
1242
|
+
]
|
|
1243
|
+
}),
|
|
1244
|
+
/* @__PURE__ */ R("div", {
|
|
1245
|
+
className: "exec-run",
|
|
1246
|
+
role: "tabpanel",
|
|
1247
|
+
id: `${c}-panel-run`,
|
|
1248
|
+
"aria-labelledby": `${c}-tab-run`,
|
|
1249
|
+
hidden: b !== "run",
|
|
1250
|
+
children: [
|
|
1251
|
+
/* @__PURE__ */ R("form", {
|
|
1252
|
+
className: "exec-run-form",
|
|
1253
|
+
onSubmit: ne,
|
|
1254
|
+
children: [/* @__PURE__ */ R("label", {
|
|
1255
|
+
htmlFor: `${c}-command`,
|
|
1256
|
+
children: ["Command ", /* @__PURE__ */ R("span", {
|
|
1257
|
+
className: "exec-hint",
|
|
1258
|
+
children: [
|
|
1259
|
+
"one line, run as ",
|
|
1260
|
+
/* @__PURE__ */ L("code", { children: "sh -c" }),
|
|
1261
|
+
H ? " as root" : ""
|
|
1262
|
+
]
|
|
1263
|
+
})]
|
|
1264
|
+
}), /* @__PURE__ */ R("div", {
|
|
1265
|
+
className: "exec-run-line",
|
|
1266
|
+
children: [/* @__PURE__ */ L("input", {
|
|
1267
|
+
ref: p,
|
|
1268
|
+
id: `${c}-command`,
|
|
1269
|
+
className: "mono-id",
|
|
1270
|
+
autoComplete: "off",
|
|
1271
|
+
autoCapitalize: "off",
|
|
1272
|
+
spellCheck: !1,
|
|
1273
|
+
placeholder: "id -u",
|
|
1274
|
+
value: S,
|
|
1275
|
+
onChange: (e) => C(e.target.value)
|
|
1276
|
+
}), /* @__PURE__ */ L("button", {
|
|
1277
|
+
type: "submit",
|
|
1278
|
+
className: "primary-action",
|
|
1279
|
+
disabled: w || !S.trim(),
|
|
1280
|
+
children: w ? "Running…" : "Run"
|
|
1281
|
+
})]
|
|
1282
|
+
})]
|
|
1283
|
+
}),
|
|
1284
|
+
N && /* @__PURE__ */ L(s, {
|
|
1285
|
+
error: N,
|
|
1286
|
+
kind: "Container"
|
|
1287
|
+
}),
|
|
1288
|
+
E && /* @__PURE__ */ R("div", {
|
|
1289
|
+
className: "exec-result",
|
|
1290
|
+
role: "status",
|
|
1291
|
+
children: [
|
|
1292
|
+
/* @__PURE__ */ L("p", {
|
|
1293
|
+
className: "exec-exit",
|
|
1294
|
+
children: E.timedOut ? "Stopped after the time limit; no exit code." : /* @__PURE__ */ R(te, { children: ["Exit code ", /* @__PURE__ */ L("code", { children: E.exitCode })] })
|
|
1295
|
+
}),
|
|
1296
|
+
E.timedOut && /* @__PURE__ */ L("p", {
|
|
1297
|
+
className: "stale",
|
|
1298
|
+
children: "The command ran longer than 60 seconds and was killed. The output up to that point is below."
|
|
1299
|
+
}),
|
|
1300
|
+
E.truncated && /* @__PURE__ */ L("p", {
|
|
1301
|
+
className: "stale",
|
|
1302
|
+
children: "Output above 1 MiB per stream was dropped."
|
|
1303
|
+
}),
|
|
1304
|
+
/* @__PURE__ */ L("h3", {
|
|
1305
|
+
id: `${c}-stdout`,
|
|
1306
|
+
children: "stdout"
|
|
1307
|
+
}),
|
|
1308
|
+
/* @__PURE__ */ L("pre", {
|
|
1309
|
+
className: "exec-output",
|
|
1310
|
+
"aria-labelledby": `${c}-stdout`,
|
|
1311
|
+
tabIndex: 0,
|
|
1312
|
+
children: E.stdout || /* @__PURE__ */ L("span", {
|
|
1313
|
+
className: "exec-empty",
|
|
1314
|
+
children: "(empty)"
|
|
1315
|
+
})
|
|
1316
|
+
}),
|
|
1317
|
+
/* @__PURE__ */ L("h3", {
|
|
1318
|
+
id: `${c}-stderr`,
|
|
1319
|
+
children: "stderr"
|
|
1320
|
+
}),
|
|
1321
|
+
/* @__PURE__ */ L("pre", {
|
|
1322
|
+
className: "exec-output",
|
|
1323
|
+
"aria-labelledby": `${c}-stderr`,
|
|
1324
|
+
tabIndex: 0,
|
|
1325
|
+
children: E.stderr || /* @__PURE__ */ L("span", {
|
|
1326
|
+
className: "exec-empty",
|
|
1327
|
+
children: "(empty)"
|
|
1328
|
+
})
|
|
1329
|
+
})
|
|
1330
|
+
]
|
|
1331
|
+
})
|
|
1332
|
+
]
|
|
1333
|
+
}),
|
|
1334
|
+
/* @__PURE__ */ R("div", {
|
|
1335
|
+
className: "exec-terminal",
|
|
1336
|
+
role: "tabpanel",
|
|
1337
|
+
id: `${c}-panel-terminal`,
|
|
1338
|
+
"aria-labelledby": `${c}-tab-terminal`,
|
|
1339
|
+
hidden: b !== "terminal",
|
|
1340
|
+
children: [/* @__PURE__ */ R("div", {
|
|
1341
|
+
className: "exec-terminal-status",
|
|
1342
|
+
children: [/* @__PURE__ */ R("p", {
|
|
1343
|
+
role: "status",
|
|
1344
|
+
children: [B.message, H && !X ? " (root)" : ""]
|
|
1345
|
+
}), X && /* @__PURE__ */ L("button", {
|
|
1346
|
+
type: "button",
|
|
1347
|
+
onClick: K,
|
|
1348
|
+
children: "New shell"
|
|
1349
|
+
})]
|
|
1350
|
+
}), I && /* @__PURE__ */ L(en, {
|
|
1351
|
+
session: J,
|
|
1352
|
+
active: i && b === "terminal",
|
|
1353
|
+
expanded: a,
|
|
1354
|
+
theme: n,
|
|
1355
|
+
update: re,
|
|
1356
|
+
endpoint: Y
|
|
1357
|
+
}, `${m}:${B.generation}`)]
|
|
1358
|
+
}),
|
|
1359
|
+
v && /* @__PURE__ */ L(wt, {
|
|
1360
|
+
target: l,
|
|
1361
|
+
onCancel: () => y(!1),
|
|
1362
|
+
onConfirm: G
|
|
1363
|
+
})
|
|
1364
|
+
]
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
// src/lifecycle-policy.js
|
|
1368
|
+
function Et(e) {
|
|
1369
|
+
return e === "Ready" ? ["stop", "restart"] : ["start"];
|
|
1370
|
+
}
|
|
1371
|
+
function Dt(e, t, n, r) {
|
|
1372
|
+
return e === "purge" ? n === r : t === !0;
|
|
1373
|
+
}
|
|
1374
|
+
function Ot(e = !1, t = !1) {
|
|
1375
|
+
return {
|
|
1376
|
+
force: e === !0,
|
|
1377
|
+
cascade: t === !0
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
function kt(e, t) {
|
|
1381
|
+
return e === !0 || t === !1;
|
|
1382
|
+
}
|
|
1383
|
+
function At(e) {
|
|
1384
|
+
return e.metadataDeleted === !0 && e.cgroupDeleted === !0;
|
|
1385
|
+
}
|
|
1386
|
+
function jt(e) {
|
|
1387
|
+
return e.purgeSucceeded === !0 && e.metadataDeleted === !0 && e.cgroupDeleted === !0;
|
|
1388
|
+
}
|
|
1389
|
+
var Mt = "kuke-system";
|
|
1390
|
+
function Nt(e) {
|
|
1391
|
+
return e.length >= 1 && e.length <= 3 && (e.length !== 1 || e[0] !== "kuke-system");
|
|
1392
|
+
}
|
|
1393
|
+
function Pt(e) {
|
|
1394
|
+
return e[0] === Mt;
|
|
1395
|
+
}
|
|
1396
|
+
function Ft(e, t) {
|
|
1397
|
+
return t.length > e.length && e.every((e, n) => t[n] === e);
|
|
1398
|
+
}
|
|
1399
|
+
function It(e, t) {
|
|
1400
|
+
let n = [];
|
|
1401
|
+
for (let r = t.length; r < 4; r++) n.push((e[r] ?? []).filter((e) => Ft(t, e.scope)).length);
|
|
1402
|
+
return n;
|
|
1403
|
+
}
|
|
1404
|
+
function Lt(e, t) {
|
|
1405
|
+
return (e[3] ?? []).filter((e) => Ft(t, e.scope)).map((e) => e.scope);
|
|
1406
|
+
}
|
|
1407
|
+
// src/terminal-palette.js
|
|
1408
|
+
var Rt = "#0d1421", zt = "#f8fafc", Bt = {
|
|
1409
|
+
black: "#000000",
|
|
1410
|
+
red: "#cd0000",
|
|
1411
|
+
green: "#00cd00",
|
|
1412
|
+
yellow: "#cdcd00",
|
|
1413
|
+
blue: "#0000ee",
|
|
1414
|
+
magenta: "#cd00cd",
|
|
1415
|
+
cyan: "#00cdcd",
|
|
1416
|
+
white: "#e5e5e5",
|
|
1417
|
+
brightBlack: "#7f7f7f",
|
|
1418
|
+
brightRed: "#ff0000",
|
|
1419
|
+
brightGreen: "#00ff00",
|
|
1420
|
+
brightYellow: "#ffff00",
|
|
1421
|
+
brightBlue: "#5c5cff",
|
|
1422
|
+
brightMagenta: "#ff00ff",
|
|
1423
|
+
brightCyan: "#00ffff",
|
|
1424
|
+
brightWhite: "#ffffff"
|
|
1425
|
+
}, Vt = {
|
|
1426
|
+
black: "#1f2328",
|
|
1427
|
+
red: "#b3261e",
|
|
1428
|
+
green: "#1a7f37",
|
|
1429
|
+
yellow: "#8a6100",
|
|
1430
|
+
blue: "#0b57d0",
|
|
1431
|
+
magenta: "#8e24aa",
|
|
1432
|
+
cyan: "#00748a",
|
|
1433
|
+
white: "#6e7781",
|
|
1434
|
+
brightBlack: "#57606a",
|
|
1435
|
+
brightRed: "#d1242f",
|
|
1436
|
+
brightGreen: "#1f883d",
|
|
1437
|
+
brightYellow: "#9a6700",
|
|
1438
|
+
brightBlue: "#0969da",
|
|
1439
|
+
brightMagenta: "#a626a4",
|
|
1440
|
+
brightCyan: "#0e7d8f",
|
|
1441
|
+
brightWhite: "#808891"
|
|
1442
|
+
}, Ht = 20, Ut = 150, Wt = 2e3, Gt = 20, Kt = [
|
|
1443
|
+
1e3,
|
|
1444
|
+
2e3,
|
|
1445
|
+
5e3
|
|
1446
|
+
], qt = 1e4, $ = (e) => JSON.stringify(e), Jt = (e, t, n = "main") => JSON.stringify([
|
|
1447
|
+
...e,
|
|
1448
|
+
t,
|
|
1449
|
+
n
|
|
1450
|
+
]), Yt = /* @__PURE__ */ new Set([
|
|
1451
|
+
"Stopped",
|
|
1452
|
+
"Stopping",
|
|
1453
|
+
"Exited",
|
|
1454
|
+
"Deleted",
|
|
1455
|
+
"Failed",
|
|
1456
|
+
"Error",
|
|
1457
|
+
"Pending",
|
|
1458
|
+
"Unknown"
|
|
1459
|
+
]), Xt = {
|
|
1460
|
+
cursorAccent: "#000000",
|
|
1461
|
+
selectionBackground: "#4d4d4d"
|
|
1462
|
+
};
|
|
1463
|
+
function Zt(e) {
|
|
1464
|
+
let t = e === "dark" || e === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
1465
|
+
return {
|
|
1466
|
+
...Xt,
|
|
1467
|
+
...t ? Bt : Vt,
|
|
1468
|
+
background: t ? Rt : zt,
|
|
1469
|
+
foreground: t ? "#e5e6ec" : "#20232b",
|
|
1470
|
+
cursor: t ? "#e5e6ec" : "#20232b"
|
|
1471
|
+
};
|
|
1472
|
+
}
|
|
1473
|
+
function Qt(e) {
|
|
1474
|
+
let [t, n] = M([]), [r, i] = M({}), a = j(/* @__PURE__ */ new Set()), [o, s] = M({}), c = j(0), l = D((e, t) => {
|
|
1475
|
+
c.current += 1;
|
|
1476
|
+
let n = c.current;
|
|
1477
|
+
s((r) => ({
|
|
1478
|
+
...r,
|
|
1479
|
+
[e]: {
|
|
1480
|
+
text: t,
|
|
1481
|
+
nonce: n
|
|
1482
|
+
}
|
|
1483
|
+
}));
|
|
1484
|
+
}, []), u = D((e, t) => {
|
|
1485
|
+
s((n) => {
|
|
1486
|
+
if (n[e]?.nonce !== t) return n;
|
|
1487
|
+
let r = { ...n };
|
|
1488
|
+
return delete r[e], r;
|
|
1489
|
+
});
|
|
1490
|
+
}, []), d = j({}), f = (e) => {
|
|
1491
|
+
let t = Object.fromEntries(Object.entries(d.current).filter(([t]) => e(t)));
|
|
1492
|
+
Object.keys(t).length !== Object.keys(d.current).length && (d.current = t);
|
|
1493
|
+
}, p = D((e, t) => {
|
|
1494
|
+
d.current = {
|
|
1495
|
+
...d.current,
|
|
1496
|
+
[$(e)]: t
|
|
1497
|
+
}, i((n) => ({
|
|
1498
|
+
...n,
|
|
1499
|
+
[$(e)]: t
|
|
1500
|
+
}));
|
|
1501
|
+
}, []), m = D((e, t, r = "main") => {
|
|
1502
|
+
let i = Jt(e, t, r);
|
|
1503
|
+
n((n) => {
|
|
1504
|
+
let a = n.find((e) => e.id === i);
|
|
1505
|
+
return a?.state === "attached" || a?.state === "connecting" || n.filter((e) => e.state === "attached" || e.state === "connecting").length >= Ht || !a && n.length >= Gt ? n : a ? n.map((e) => e.id === i ? {
|
|
1506
|
+
...e,
|
|
1507
|
+
generation: e.generation + 1,
|
|
1508
|
+
state: "connecting",
|
|
1509
|
+
message: "Connecting…"
|
|
1510
|
+
} : e) : [...n, {
|
|
1511
|
+
id: i,
|
|
1512
|
+
scope: [...e],
|
|
1513
|
+
container: t,
|
|
1514
|
+
view: r,
|
|
1515
|
+
state: "connecting",
|
|
1516
|
+
message: "Connecting…",
|
|
1517
|
+
generation: 0
|
|
1518
|
+
}];
|
|
1519
|
+
}), r === "main" && p(e, t);
|
|
1520
|
+
}, [p]), h = D((e, t, n) => {
|
|
1521
|
+
d.current[$(e)] === n && m(e, t);
|
|
1522
|
+
}, [m]), g = D((e) => n((t) => t.filter((t) => t.id !== e)), []), _ = D((e, t) => {
|
|
1523
|
+
let r = $(e);
|
|
1524
|
+
n((e) => e.some((e) => e.view === t && $(e.scope) === r) ? e.filter((e) => e.view !== t || $(e.scope) !== r) : e);
|
|
1525
|
+
}, []), v = D((e) => {
|
|
1526
|
+
let t = $(e);
|
|
1527
|
+
a.current.delete(t), n((e) => e.filter((e) => $(e.scope) !== t)), f((e) => e !== t), i((e) => {
|
|
1528
|
+
if (!(t in e)) return e;
|
|
1529
|
+
let n = { ...e };
|
|
1530
|
+
return delete n[t], n;
|
|
1531
|
+
});
|
|
1532
|
+
}, []), y = D((e, t, r = !1) => {
|
|
1533
|
+
let i = $(e);
|
|
1534
|
+
n((e) => e.map((e) => $(e.scope) === i ? {
|
|
1535
|
+
...e,
|
|
1536
|
+
generation: e.generation + 1,
|
|
1537
|
+
state: "interrupted",
|
|
1538
|
+
message: t,
|
|
1539
|
+
reattach: r
|
|
1540
|
+
} : e));
|
|
1541
|
+
}, []), b = D((e) => {
|
|
1542
|
+
let t = $(e);
|
|
1543
|
+
n((e) => e.filter((e) => $(e.scope) !== t || e.state !== "interrupted"));
|
|
1544
|
+
}, []), x = D((e) => {
|
|
1545
|
+
a.current.add($(e));
|
|
1546
|
+
}, []), S = D((e) => {
|
|
1547
|
+
a.current.delete($(e));
|
|
1548
|
+
}, []), C = D((e, t, r, i) => {
|
|
1549
|
+
n((n) => n.map((n) => n.id === e && n.generation === t ? {
|
|
1550
|
+
...n,
|
|
1551
|
+
state: r,
|
|
1552
|
+
message: i
|
|
1553
|
+
} : n));
|
|
1554
|
+
}, []);
|
|
1555
|
+
return O(() => {
|
|
1556
|
+
if (!e.data || e.loading || e.error || e.data.failures.length) return;
|
|
1557
|
+
let t = new Map(e.data.rows[3].map((e) => [$(e.scope), e.doc.status?.state ?? ""]));
|
|
1558
|
+
n((e) => e.filter((e) => {
|
|
1559
|
+
let n = $(e.scope), r = t.get(n);
|
|
1560
|
+
return r === void 0 ? !1 : a.current.has(n) ? !0 : !Yt.has(r) || e.state === "interrupted";
|
|
1561
|
+
})), f((e) => t.has(e)), i((e) => {
|
|
1562
|
+
let n = !1, r = { ...e };
|
|
1563
|
+
for (let e of Object.keys(r)) t.has(e) || (delete r[e], n = !0);
|
|
1564
|
+
return n ? r : e;
|
|
1565
|
+
});
|
|
1566
|
+
}, [
|
|
1567
|
+
e.data,
|
|
1568
|
+
e.loading,
|
|
1569
|
+
e.error
|
|
1570
|
+
]), {
|
|
1571
|
+
sessions: t,
|
|
1572
|
+
selection: r,
|
|
1573
|
+
select: p,
|
|
1574
|
+
attach: m,
|
|
1575
|
+
autoAttach: h,
|
|
1576
|
+
detach: g,
|
|
1577
|
+
detachView: _,
|
|
1578
|
+
removeCell: v,
|
|
1579
|
+
interruptCell: y,
|
|
1580
|
+
dropInterrupted: b,
|
|
1581
|
+
holdCell: x,
|
|
1582
|
+
releaseCell: S,
|
|
1583
|
+
update: C,
|
|
1584
|
+
cellStates: A(() => {
|
|
1585
|
+
let e = {};
|
|
1586
|
+
for (let n of t) {
|
|
1587
|
+
let t = $(n.scope);
|
|
1588
|
+
(n.state === "attached" || n.state === "connecting" && e[t] !== "attached" || !e[t]) && (e[t] = n.state);
|
|
1589
|
+
}
|
|
1590
|
+
return e;
|
|
1591
|
+
}, [t]),
|
|
1592
|
+
pastes: o,
|
|
1593
|
+
paste: l,
|
|
1594
|
+
pasteDelivered: u
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
function $t(e, t, n) {
|
|
1598
|
+
let r = j({}), i = j(n);
|
|
1599
|
+
return i.current = n, O(() => {
|
|
1600
|
+
if (!e) return;
|
|
1601
|
+
let n = r.current[e.id] ??= { count: 0 };
|
|
1602
|
+
if (e.state === "attached") {
|
|
1603
|
+
n.attachedAt ??= Date.now();
|
|
1604
|
+
return;
|
|
1605
|
+
}
|
|
1606
|
+
if (e.state === "connecting" || (n.attachedAt !== void 0 && (Date.now() - n.attachedAt >= qt && (n.count = 0), n.attachedAt = void 0), e.state === "interrupted" && e.reattach && (n.count = 0), !t || e.state === "interrupted" && !e.reattach || n.count >= Kt.length)) return;
|
|
1607
|
+
let a = e, o = window.setTimeout(() => {
|
|
1608
|
+
n.count += 1, i.current(a);
|
|
1609
|
+
}, e.state === "interrupted" ? 0 : Kt[n.count]);
|
|
1610
|
+
return () => window.clearTimeout(o);
|
|
1611
|
+
}, [
|
|
1612
|
+
e?.id,
|
|
1613
|
+
e?.state,
|
|
1614
|
+
e?.generation,
|
|
1615
|
+
e?.reattach,
|
|
1616
|
+
t
|
|
1617
|
+
]), D((e) => {
|
|
1618
|
+
delete r.current[e];
|
|
1619
|
+
}, []);
|
|
1620
|
+
}
|
|
1621
|
+
function en({ session: e, active: t, expanded: n, theme: r, update: i, pending: a, onPasted: o, endpoint: s }) {
|
|
1622
|
+
let c = j(null), l = j(null), u = j(null), d = j(() => {}), p = j(""), m = j(t), h = j(!1), g = j({
|
|
1623
|
+
received: 0,
|
|
1624
|
+
parsed: 0
|
|
1625
|
+
}), [_, v] = M(0);
|
|
1626
|
+
m.current = t, O(() => {
|
|
1627
|
+
if (!c.current) return;
|
|
1628
|
+
let e = new q({
|
|
1629
|
+
cursorBlink: !0,
|
|
1630
|
+
cursorStyle: "underline",
|
|
1631
|
+
cursorInactiveStyle: "outline",
|
|
1632
|
+
convertEol: !1,
|
|
1633
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace",
|
|
1634
|
+
fontSize: 14,
|
|
1635
|
+
scrollback: 2e3,
|
|
1636
|
+
theme: Zt(r)
|
|
1637
|
+
}), t = new J();
|
|
1638
|
+
l.current = e, e.loadAddon(t), e.open(c.current);
|
|
1639
|
+
let n = 0, i = !1, a = (r = !1) => {
|
|
1640
|
+
m.current && (i ||= r, n && cancelAnimationFrame(n), n = requestAnimationFrame(() => {
|
|
1641
|
+
if (n = 0, !m.current || !c.current?.clientWidth || !c.current.clientHeight) return;
|
|
1642
|
+
t.fit();
|
|
1643
|
+
let r = `${e.cols}x${e.rows}`;
|
|
1644
|
+
u.current?.readyState !== WebSocket.OPEN || r === p.current && !i || (i = !1, p.current = r, u.current.send(JSON.stringify({
|
|
1645
|
+
type: "resize",
|
|
1646
|
+
cols: e.cols,
|
|
1647
|
+
rows: e.rows
|
|
1648
|
+
})));
|
|
1649
|
+
}));
|
|
1650
|
+
};
|
|
1651
|
+
d.current = a;
|
|
1652
|
+
let o = () => a(), s = () => a(!0), f = new ResizeObserver(o);
|
|
1653
|
+
f.observe(c.current), c.current.parentElement && f.observe(c.current.parentElement), window.addEventListener("resize", o), window.visualViewport?.addEventListener("resize", o);
|
|
1654
|
+
let h = c.current;
|
|
1655
|
+
h.addEventListener("focusin", s);
|
|
1656
|
+
let g = e.onData((e) => {
|
|
1657
|
+
m.current && u.current?.readyState === WebSocket.OPEN && u.current.send(new TextEncoder().encode(e));
|
|
1658
|
+
});
|
|
1659
|
+
return () => {
|
|
1660
|
+
f.disconnect(), window.removeEventListener("resize", o), window.visualViewport?.removeEventListener("resize", o), h.removeEventListener("focusin", s), n && cancelAnimationFrame(n), g.dispose(), e.dispose(), l.current = null, d.current = () => {};
|
|
1661
|
+
};
|
|
1662
|
+
}, []), O(() => {
|
|
1663
|
+
let e = () => {
|
|
1664
|
+
l.current && (l.current.options.theme = Zt(r));
|
|
1665
|
+
};
|
|
1666
|
+
if (e(), r !== "system") return;
|
|
1667
|
+
let t = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1668
|
+
return t.addEventListener("change", e), () => t.removeEventListener("change", e);
|
|
1669
|
+
}, [r]), O(() => {
|
|
1670
|
+
e.state === "interrupted" ? (l.current?.reset(), l.current?.write(e.reattach ? "\r\nPrevious terminal session ended. Attaching to the current process…\r\n" : "\r\nPrevious terminal session ended. Reconnect to attach to the current process.\r\n"), h.current = !0) : e.state === "connecting" && h.current && (l.current?.reset(), h.current = !1);
|
|
1671
|
+
}, [e.state, e.generation]), O(() => {
|
|
1672
|
+
if (e.state === "disconnected" || e.state === "interrupted") return;
|
|
1673
|
+
let t;
|
|
1674
|
+
try {
|
|
1675
|
+
t = F(s?.path ?? `${f(e.scope)}/containers/${encodeURIComponent(e.container)}/attach`);
|
|
1676
|
+
} catch {
|
|
1677
|
+
i(e.id, e.generation, "disconnected", "Terminal connection failed. Check the server and retry.");
|
|
1678
|
+
return;
|
|
1679
|
+
}
|
|
1680
|
+
u.current = t, g.current = {
|
|
1681
|
+
received: 0,
|
|
1682
|
+
parsed: 0
|
|
1683
|
+
}, t.binaryType = "arraybuffer";
|
|
1684
|
+
let n = "", r = !1, a = !1, o = !1;
|
|
1685
|
+
t.onopen = () => {
|
|
1686
|
+
o = !0, p.current = "", d.current();
|
|
1687
|
+
}, t.onmessage = (o) => {
|
|
1688
|
+
if (o.data instanceof ArrayBuffer) {
|
|
1689
|
+
let t = g.current;
|
|
1690
|
+
t.received += 1, l.current?.write(new Uint8Array(o.data), () => {
|
|
1691
|
+
t.parsed += 1, g.current === t && t.parsed === t.received && v((e) => e + 1);
|
|
1692
|
+
}), a || (a = !0, r && i(e.id, e.generation, "attached", s ? "Connected" : "Attached"));
|
|
1693
|
+
} else if (typeof o.data == "string") {
|
|
1694
|
+
try {
|
|
1695
|
+
let t = JSON.parse(o.data);
|
|
1696
|
+
t.type === "ready" ? (r = !0, i(e.id, e.generation, "attached", s ? "Connected" : a ? "Attached" : "Attached — waiting for container output. A prompt appears when the container runs an interactive shell.")) : t.type === "exit" && s ? (n = `Process exited with code ${typeof t.code == "number" ? t.code : "unknown"}`, l.current?.write(`\r\n${n}\r\n`)) : n = t.type === "error" ? typeof t.message == "string" ? t.message : "Terminal server error." : "Invalid terminal response.";
|
|
1697
|
+
} catch {
|
|
1698
|
+
n = "Invalid terminal response.";
|
|
1699
|
+
}
|
|
1700
|
+
n && (i(e.id, e.generation, "disconnected", n), t.close());
|
|
1701
|
+
}
|
|
1702
|
+
};
|
|
1703
|
+
let c = () => {
|
|
1704
|
+
o || (o = !0, pt());
|
|
1705
|
+
};
|
|
1706
|
+
return t.onerror = () => {
|
|
1707
|
+
c(), n ||= "Terminal connection failed. Check the server and retry.", i(e.id, e.generation, "disconnected", n), t.close();
|
|
1708
|
+
}, t.onclose = () => {
|
|
1709
|
+
c(), i(e.id, e.generation, "disconnected", n || (s ? "Terminal connection closed." : "Terminal connection closed. Reconnect to attach again."));
|
|
1710
|
+
}, () => {
|
|
1711
|
+
t.onopen = t.onmessage = t.onerror = t.onclose = null, t.close(), u.current === t && (u.current = null);
|
|
1712
|
+
};
|
|
1713
|
+
}, [
|
|
1714
|
+
e.id,
|
|
1715
|
+
e.generation,
|
|
1716
|
+
e.scope,
|
|
1717
|
+
e.container,
|
|
1718
|
+
i,
|
|
1719
|
+
s?.path
|
|
1720
|
+
]), O(() => {
|
|
1721
|
+
if (!t) {
|
|
1722
|
+
l.current?.blur();
|
|
1723
|
+
return;
|
|
1724
|
+
}
|
|
1725
|
+
let e = requestAnimationFrame(() => {
|
|
1726
|
+
d.current(!0), document.activeElement?.closest("[role=\"tablist\"]") || l.current?.focus();
|
|
1727
|
+
});
|
|
1728
|
+
return () => cancelAnimationFrame(e);
|
|
1729
|
+
}, [t]);
|
|
1730
|
+
let y = j(null);
|
|
1731
|
+
return O(() => {
|
|
1732
|
+
if (!a || !t || e.state !== "attached" || u.current?.readyState !== WebSocket.OPEN) return;
|
|
1733
|
+
y.current?.nonce !== a.nonce && (y.current = {
|
|
1734
|
+
nonce: a.nonce,
|
|
1735
|
+
at: Date.now()
|
|
1736
|
+
});
|
|
1737
|
+
let { received: n, parsed: r } = g.current, i = n > 0 && r === n, s = Math.max(0, y.current.at + Wt - Date.now()), c = setTimeout(() => {
|
|
1738
|
+
l.current?.paste(a.text), l.current?.focus(), o?.(e.id, a.nonce);
|
|
1739
|
+
}, i ? Math.min(Ut, s) : s);
|
|
1740
|
+
return () => clearTimeout(c);
|
|
1741
|
+
}, [
|
|
1742
|
+
a,
|
|
1743
|
+
t,
|
|
1744
|
+
e.state,
|
|
1745
|
+
e.id,
|
|
1746
|
+
o,
|
|
1747
|
+
_
|
|
1748
|
+
]), O(() => {
|
|
1749
|
+
if (!t || !n) return;
|
|
1750
|
+
let e = requestAnimationFrame(() => {
|
|
1751
|
+
d.current(), l.current?.focus();
|
|
1752
|
+
});
|
|
1753
|
+
return () => cancelAnimationFrame(e);
|
|
1754
|
+
}, [t, n]), /* @__PURE__ */ L("div", {
|
|
1755
|
+
className: "terminal-session",
|
|
1756
|
+
hidden: !t,
|
|
1757
|
+
"aria-hidden": !t,
|
|
1758
|
+
children: /* @__PURE__ */ L("div", {
|
|
1759
|
+
className: "terminal-screen",
|
|
1760
|
+
"aria-label": s?.label ?? `Terminal for ${e.scope.join(" / ")} / ${e.container}`,
|
|
1761
|
+
children: /* @__PURE__ */ L("div", {
|
|
1762
|
+
ref: c,
|
|
1763
|
+
className: "terminal-mount"
|
|
1764
|
+
})
|
|
1765
|
+
})
|
|
1766
|
+
});
|
|
1767
|
+
}
|
|
1768
|
+
function tn({ scope: e, revision: t, inventory: n, manager: r, theme: a, autoAttach: o = !0, visible: c = !0, controlsHost: l, onExpandedChange: u, inPanel: d = !1, onOpenInPanel: p, operation: m, onLifecycleAction: h }) {
|
|
1769
|
+
let [g, _] = M(!1), [v, y] = M(""), [b, x] = M(""), S = j(null), C = j(null);
|
|
1770
|
+
O(() => {
|
|
1771
|
+
e || (_(!1), u(!1));
|
|
1772
|
+
}, [e, u]), O(() => {
|
|
1773
|
+
!c && g && (_(!1), u(!1));
|
|
1774
|
+
}, [
|
|
1775
|
+
c,
|
|
1776
|
+
g,
|
|
1777
|
+
u
|
|
1778
|
+
]), O(() => {
|
|
1779
|
+
if (!g) return;
|
|
1780
|
+
let e = (e) => {
|
|
1781
|
+
e.key !== "Escape" || C.current?.contains(e.target) || e.target?.closest?.("details[open]") || (e.preventDefault(), e.stopPropagation(), _(!1), u(!1), requestAnimationFrame(() => S.current?.focus()));
|
|
1782
|
+
};
|
|
1783
|
+
return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
|
|
1784
|
+
}, [g]);
|
|
1785
|
+
let w = e?.length === 4 ? `${f(e)}/containers` : null, T = i(w, t), E = T.data?.filter((e) => !e.root) ?? [], D = E.filter((e) => e.attachable), ee = E.filter((e) => !e.attachable), k = e ? $(e) : "", A = r.sessions.filter((e) => e.view === "main"), N = A.filter((e) => $(e.scope) === k), P = [
|
|
1786
|
+
...D.map((e) => e.id),
|
|
1787
|
+
...ee.map((e) => e.id),
|
|
1788
|
+
...N.map((e) => e.container).filter((e) => !E.some((t) => t.id === e))
|
|
1789
|
+
], F = P.includes(r.selection[k]) ? r.selection[k] : P[0] ?? "", I = e && F ? Jt(e, F) : "", z = A.find((e) => e.id === I), V = D.some((e) => e.id === F), H = r.sessions.filter((e) => e.state === "attached" || e.state === "connecting").length, U = n.data?.rows[3].find((e) => $(e.scope) === k)?.doc.status?.state, W = U && Yt.has(U), G = E.some((e) => e.id === F), K = (e && G && (!V || W) ? "logs" : "terminal") == "logs", q = !!I && b === I && G && !W, J = !z && (H >= Ht || r.sessions.length >= Gt), re = (z?.state === "disconnected" || z?.state === "interrupted") && H >= Ht;
|
|
1790
|
+
O(() => {
|
|
1791
|
+
y("");
|
|
1792
|
+
}, [k]);
|
|
1793
|
+
let Y = o && c && !!e && !K && !!n.data && !T.loading && !T.error && !!F && V && !W && m?.phase !== "pending" && v !== I;
|
|
1794
|
+
O(() => {
|
|
1795
|
+
!Y || J || z || r.autoAttach(e, F, r.selection[k]);
|
|
1796
|
+
}, [
|
|
1797
|
+
Y,
|
|
1798
|
+
k,
|
|
1799
|
+
F,
|
|
1800
|
+
J,
|
|
1801
|
+
z,
|
|
1802
|
+
r.autoAttach
|
|
1803
|
+
]);
|
|
1804
|
+
let ie = $t(z, Y && !re, (e) => r.attach(e.scope, e.container)), ae = !!I && !z && (v === I || !o), oe = K ? "Logs" : z?.state === "attached" ? "Attached" : z?.message || (v === I && I ? "Detached" : J ? "Connection limit reached" : W ? `Unavailable: ${U}` : T.loading ? "Loading containers…" : T.error ? "Container list unavailable" : D.length ? V ? o ? "Connecting…" : "Detached" : "Container unavailable" : "No attachable containers"), X = !!e && !T.loading && !T.error && !E.length && !P.length, Z = z?.state === "attached" || z?.state === "connecting", se = "Terminal limit reached. Detach another terminal to free a connection or retained slot.", Q = T.error && T.data ? "Container list is stale. Refresh before attaching." : "", ce = K ? W ? `Cell is ${U}. Showing the last output of ${F}.` : `Showing the output of ${F}.` : J || re ? se : W && !Z ? `Terminal unavailable: cell is ${U}.` : T.error && !Z ? `${oe}: ${T.error.message}` : Q && !Z ? Q : z?.message || oe, le = !e || X || Z || K || q ? null : J || re ? /* @__PURE__ */ L("p", {
|
|
1805
|
+
className: "terminal-limit",
|
|
1806
|
+
role: "status",
|
|
1807
|
+
children: se
|
|
1808
|
+
}) : W ? /* @__PURE__ */ R("p", {
|
|
1809
|
+
className: "terminal-unavailable",
|
|
1810
|
+
role: "status",
|
|
1811
|
+
children: [
|
|
1812
|
+
"Terminal unavailable: cell is ",
|
|
1813
|
+
U,
|
|
1814
|
+
"."
|
|
1815
|
+
]
|
|
1816
|
+
}) : T.error ? /* @__PURE__ */ R(te, { children: [/* @__PURE__ */ L(s, {
|
|
1817
|
+
error: T.error,
|
|
1818
|
+
kind: "Containers"
|
|
1819
|
+
}), Q && /* @__PURE__ */ L("p", {
|
|
1820
|
+
className: "stale",
|
|
1821
|
+
children: Q
|
|
1822
|
+
})] }) : T.loading && !T.data ? /* @__PURE__ */ L("p", {
|
|
1823
|
+
role: "status",
|
|
1824
|
+
children: "Loading containers…"
|
|
1825
|
+
}) : null, ue = K ? "logs" : z?.state ?? (v === I && I || J || W || T.error || !D.length || !V || !o ? "disconnected" : "connecting"), de = () => {
|
|
1826
|
+
let e = !g;
|
|
1827
|
+
_(e), u(e);
|
|
1828
|
+
}, fe = () => {
|
|
1829
|
+
y(""), ie(I), r.attach(e, F);
|
|
1830
|
+
}, pe = (e, t, n) => /* @__PURE__ */ L("button", {
|
|
1831
|
+
type: "button",
|
|
1832
|
+
className: "icon-button",
|
|
1833
|
+
"aria-label": e,
|
|
1834
|
+
"data-tooltip": e,
|
|
1835
|
+
disabled: t,
|
|
1836
|
+
onClick: n,
|
|
1837
|
+
children: /* @__PURE__ */ L(B, { name: e === "Attach" ? "attach" : e === "Detach" ? "detach" : "reconnect" })
|
|
1838
|
+
}), me = z?.state === "attached" || z?.state === "connecting" ? pe("Detach", !1, () => {
|
|
1839
|
+
y(z.id), r.detach(z.id);
|
|
1840
|
+
}) : z ? /* @__PURE__ */ R(te, { children: [pe("Reconnect", re || !V || !!W || !!T.error, fe), pe("Detach", !1, () => {
|
|
1841
|
+
y(z.id), r.detach(z.id);
|
|
1842
|
+
})] }) : ae ? pe("Attach", !!J || !V || !!W || !!T.error, fe) : null, he = (e) => D.some((t) => t.id === e) ? e : ee.some((t) => t.id === e) ? `${e} (logs)` : `${e} (unavailable)`, ge = e && /* @__PURE__ */ R("div", {
|
|
1843
|
+
className: "terminal-workspace-tools",
|
|
1844
|
+
children: [!X && /* @__PURE__ */ R("span", {
|
|
1845
|
+
className: `terminal-connection-state ${ue}`,
|
|
1846
|
+
role: "status",
|
|
1847
|
+
tabIndex: 0,
|
|
1848
|
+
title: ce,
|
|
1849
|
+
"data-tooltip": ce,
|
|
1850
|
+
children: [/* @__PURE__ */ L("span", {
|
|
1851
|
+
className: "state-dot",
|
|
1852
|
+
"aria-hidden": "true"
|
|
1853
|
+
}), /* @__PURE__ */ L("span", {
|
|
1854
|
+
className: "sr-only",
|
|
1855
|
+
children: oe
|
|
1856
|
+
})]
|
|
1857
|
+
}), /* @__PURE__ */ R("div", {
|
|
1858
|
+
className: "terminal-controls",
|
|
1859
|
+
children: [
|
|
1860
|
+
!!P.length && /* @__PURE__ */ R(te, { children: [
|
|
1861
|
+
/* @__PURE__ */ L("label", {
|
|
1862
|
+
htmlFor: "terminal-container",
|
|
1863
|
+
className: "sr-only",
|
|
1864
|
+
children: "Container"
|
|
1865
|
+
}),
|
|
1866
|
+
/* @__PURE__ */ L("select", {
|
|
1867
|
+
id: "terminal-container",
|
|
1868
|
+
className: "mono-id",
|
|
1869
|
+
value: F,
|
|
1870
|
+
onChange: (t) => r.select(e, t.target.value),
|
|
1871
|
+
children: P.map((e) => /* @__PURE__ */ L("option", {
|
|
1872
|
+
value: e,
|
|
1873
|
+
children: he(e)
|
|
1874
|
+
}, e))
|
|
1875
|
+
}),
|
|
1876
|
+
!K && me,
|
|
1877
|
+
G && /* @__PURE__ */ L(Ct, {
|
|
1878
|
+
container: F,
|
|
1879
|
+
open: q,
|
|
1880
|
+
reason: W ? `Exec unavailable: cell is ${U}.` : "",
|
|
1881
|
+
onToggle: () => x(q ? "" : I)
|
|
1882
|
+
})
|
|
1883
|
+
] }),
|
|
1884
|
+
!d && p && /* @__PURE__ */ L("button", {
|
|
1885
|
+
type: "button",
|
|
1886
|
+
className: "icon-button",
|
|
1887
|
+
"aria-label": "Open in side panel",
|
|
1888
|
+
"data-tooltip": "Open in side panel",
|
|
1889
|
+
onClick: () => p(e),
|
|
1890
|
+
children: /* @__PURE__ */ L(B, { name: "sidePanel" })
|
|
1891
|
+
}),
|
|
1892
|
+
!X && /* @__PURE__ */ L("button", {
|
|
1893
|
+
ref: S,
|
|
1894
|
+
type: "button",
|
|
1895
|
+
className: "icon-button",
|
|
1896
|
+
"aria-label": g ? "Collapse terminal" : "Expand terminal",
|
|
1897
|
+
"data-tooltip": g ? "Collapse terminal" : "Expand terminal",
|
|
1898
|
+
"aria-expanded": g,
|
|
1899
|
+
"aria-controls": "terminal-screens",
|
|
1900
|
+
onClick: de,
|
|
1901
|
+
children: /* @__PURE__ */ L(B, { name: g ? "collapse" : "expand" })
|
|
1902
|
+
})
|
|
1903
|
+
]
|
|
1904
|
+
})]
|
|
1905
|
+
});
|
|
1906
|
+
return /* @__PURE__ */ R(te, { children: [ge && l && ne(ge, l), /* @__PURE__ */ R("section", {
|
|
1907
|
+
className: `panel terminal-workspace${g ? " is-expanded" : ""}${X ? " is-empty" : ""}`,
|
|
1908
|
+
id: "cell-terminal",
|
|
1909
|
+
hidden: !e,
|
|
1910
|
+
"aria-label": "Terminal workspace",
|
|
1911
|
+
children: [
|
|
1912
|
+
X && /* @__PURE__ */ L("p", {
|
|
1913
|
+
className: "empty-state terminal-empty",
|
|
1914
|
+
role: "status",
|
|
1915
|
+
children: "No containers are available."
|
|
1916
|
+
}),
|
|
1917
|
+
le && /* @__PURE__ */ L("div", {
|
|
1918
|
+
className: "terminal-overlay",
|
|
1919
|
+
children: le
|
|
1920
|
+
}),
|
|
1921
|
+
K && W && /* @__PURE__ */ R("div", {
|
|
1922
|
+
className: "terminal-log-status",
|
|
1923
|
+
role: "status",
|
|
1924
|
+
children: [/* @__PURE__ */ R("span", { children: [
|
|
1925
|
+
"Cell is ",
|
|
1926
|
+
U,
|
|
1927
|
+
". Showing the last output of ",
|
|
1928
|
+
/* @__PURE__ */ L("code", { children: F }),
|
|
1929
|
+
"."
|
|
1930
|
+
] }), Et(U).includes("start") && /* @__PURE__ */ L("button", {
|
|
1931
|
+
type: "button",
|
|
1932
|
+
disabled: m?.phase === "pending",
|
|
1933
|
+
onClick: () => h?.(e, "start", U),
|
|
1934
|
+
children: "Start"
|
|
1935
|
+
})]
|
|
1936
|
+
}),
|
|
1937
|
+
/* @__PURE__ */ R("div", {
|
|
1938
|
+
className: "terminal-screens",
|
|
1939
|
+
id: "terminal-screens",
|
|
1940
|
+
ref: C,
|
|
1941
|
+
children: [
|
|
1942
|
+
A.map((t) => /* @__PURE__ */ L(en, {
|
|
1943
|
+
session: t,
|
|
1944
|
+
active: !!e && c && !K && !q && t.id === I,
|
|
1945
|
+
expanded: g,
|
|
1946
|
+
theme: a,
|
|
1947
|
+
update: r.update,
|
|
1948
|
+
pending: r.pastes[t.id],
|
|
1949
|
+
onPasted: r.pasteDelivered
|
|
1950
|
+
}, t.id)),
|
|
1951
|
+
c && K && !q && /* @__PURE__ */ L(xt, {
|
|
1952
|
+
scope: e,
|
|
1953
|
+
container: F,
|
|
1954
|
+
attachable: V,
|
|
1955
|
+
live: !W,
|
|
1956
|
+
cellState: U,
|
|
1957
|
+
revision: t,
|
|
1958
|
+
theme: a,
|
|
1959
|
+
expanded: g
|
|
1960
|
+
}, Jt(e, F)),
|
|
1961
|
+
q && /* @__PURE__ */ L(Tt, {
|
|
1962
|
+
scope: e,
|
|
1963
|
+
container: F,
|
|
1964
|
+
theme: a,
|
|
1965
|
+
visible: c,
|
|
1966
|
+
expanded: g,
|
|
1967
|
+
onClose: () => x("")
|
|
1968
|
+
}, I)
|
|
1969
|
+
]
|
|
1970
|
+
})
|
|
1971
|
+
]
|
|
1972
|
+
})] });
|
|
1973
|
+
}
|
|
1974
|
+
// src/settings-values.mjs
|
|
1975
|
+
function nn(e, t) {
|
|
1976
|
+
let n = typeof e == "string" ? e.trim() : "";
|
|
1977
|
+
if (!/^\d+$/.test(n)) return;
|
|
1978
|
+
let r = Number(n);
|
|
1979
|
+
return t.includes(r) ? r : void 0;
|
|
1980
|
+
}
|
|
1981
|
+
var rn = [
|
|
1982
|
+
5,
|
|
1983
|
+
10,
|
|
1984
|
+
30,
|
|
1985
|
+
60
|
|
1986
|
+
];
|
|
1987
|
+
function an(e) {
|
|
1988
|
+
return nn(e, rn);
|
|
1989
|
+
}
|
|
1990
|
+
var on = [
|
|
1991
|
+
1,
|
|
1992
|
+
2,
|
|
1993
|
+
5,
|
|
1994
|
+
10,
|
|
1995
|
+
30
|
|
1996
|
+
];
|
|
1997
|
+
function sn(e) {
|
|
1998
|
+
return nn(e, on);
|
|
1999
|
+
}
|
|
2000
|
+
var cn = [
|
|
2001
|
+
2,
|
|
2002
|
+
5,
|
|
2003
|
+
10,
|
|
2004
|
+
30
|
|
2005
|
+
];
|
|
2006
|
+
function ln(e) {
|
|
2007
|
+
return nn(e, cn);
|
|
2008
|
+
}
|
|
2009
|
+
var un = [
|
|
2010
|
+
0,
|
|
2011
|
+
1,
|
|
2012
|
+
3,
|
|
2013
|
+
5,
|
|
2014
|
+
10
|
|
2015
|
+
];
|
|
2016
|
+
function dn(e) {
|
|
2017
|
+
return nn(e, un);
|
|
2018
|
+
}
|
|
2019
|
+
function fn(e) {
|
|
2020
|
+
if (e === "true" || e === "auto" || e === "shown") return !0;
|
|
2021
|
+
if (e === "false" || e === "hidden") return !1;
|
|
2022
|
+
}
|
|
2023
|
+
function pn(e) {
|
|
2024
|
+
return e === "true" || e !== "false" && void 0;
|
|
2025
|
+
}
|
|
2026
|
+
// src/settings.ts
|
|
2027
|
+
var mn = [
|
|
2028
|
+
"system",
|
|
2029
|
+
"light",
|
|
2030
|
+
"dark"
|
|
2031
|
+
], hn = {
|
|
2032
|
+
system: "System",
|
|
2033
|
+
light: "Light",
|
|
2034
|
+
dark: "Dark"
|
|
2035
|
+
}, gn = ["agent", "default"], _n = {
|
|
2036
|
+
agent: "Agent",
|
|
2037
|
+
default: "Default"
|
|
2038
|
+
}, vn = "Applies to the Default cell list style.", yn = (e, t, n, r) => ({
|
|
2039
|
+
key: e,
|
|
2040
|
+
label: t,
|
|
2041
|
+
defaultValue: n,
|
|
2042
|
+
note: r,
|
|
2043
|
+
parse: pn,
|
|
2044
|
+
format: (e) => String(e)
|
|
2045
|
+
}), bn = {
|
|
2046
|
+
theme: {
|
|
2047
|
+
key: "kukeon-theme",
|
|
2048
|
+
label: "Appearance",
|
|
2049
|
+
defaultValue: "system",
|
|
2050
|
+
parse: (e) => mn.includes(e) ? e : void 0,
|
|
2051
|
+
format: (e) => e
|
|
2052
|
+
},
|
|
2053
|
+
cellListStyle: {
|
|
2054
|
+
key: "kukeon-cell-list-style",
|
|
2055
|
+
label: "Cell list style",
|
|
2056
|
+
defaultValue: "agent",
|
|
2057
|
+
parse: (e) => gn.includes(e) ? e : void 0,
|
|
2058
|
+
format: (e) => e
|
|
2059
|
+
},
|
|
2060
|
+
defaultGroupBy: {
|
|
2061
|
+
key: "kukeon-default-group-by",
|
|
2062
|
+
label: "Default Group by",
|
|
2063
|
+
defaultValue: C,
|
|
2064
|
+
note: vn,
|
|
2065
|
+
parse: (e) => e,
|
|
2066
|
+
format: (e) => e
|
|
2067
|
+
},
|
|
2068
|
+
showCellScope: yn("kukeon-sidebar-show-scope", "Show cell scope in sidebar", !0),
|
|
2069
|
+
showTerminalStatus: yn("kukeon-sidebar-show-terminal-status", "Show terminal status in sidebar", !0),
|
|
2070
|
+
showUnreadBytes: yn("kukeon-show-unread-bytes", "Show unread bytes", !1),
|
|
2071
|
+
showSidebarSearch: yn("kukeon-sidebar-show-search", "Show search in sidebar", !1),
|
|
2072
|
+
showSidebarGroupBy: yn("kukeon-sidebar-show-group-by", "Show Group by in sidebar", !1, vn),
|
|
2073
|
+
showGridSearch: yn("kukeon-grid-show-search", "Show search in grid", !0),
|
|
2074
|
+
showGridGroupBy: yn("kukeon-grid-show-group-by", "Show Group by in grid", !0, vn),
|
|
2075
|
+
autoAttach: yn("kukeon-terminal-auto-attach", "Auto-attach terminals", !0),
|
|
2076
|
+
refreshSeconds: {
|
|
2077
|
+
key: "kukeon-refresh-seconds",
|
|
2078
|
+
label: "Refresh interval",
|
|
2079
|
+
defaultValue: 10,
|
|
2080
|
+
note: "How often the inventory is read while this tab is visible.",
|
|
2081
|
+
parse: an,
|
|
2082
|
+
format: (e) => String(e)
|
|
2083
|
+
},
|
|
2084
|
+
unreadPollSeconds: {
|
|
2085
|
+
key: "kukeon-unread-poll-seconds",
|
|
2086
|
+
label: "Unread check interval",
|
|
2087
|
+
defaultValue: 2,
|
|
2088
|
+
note: "How often terminal output is checked for the unread marks in the sidebar, the collapsed rail and the grid tile badges.",
|
|
2089
|
+
parse: sn,
|
|
2090
|
+
format: (e) => String(e)
|
|
2091
|
+
},
|
|
2092
|
+
gridScreenSeconds: {
|
|
2093
|
+
key: "kukeon-grid-screen-seconds",
|
|
2094
|
+
label: "Thumbnail refresh interval",
|
|
2095
|
+
defaultValue: 5,
|
|
2096
|
+
note: "How often the Workbench grid tiles' terminal thumbnails are read.",
|
|
2097
|
+
parse: ln,
|
|
2098
|
+
format: (e) => String(e)
|
|
2099
|
+
},
|
|
2100
|
+
unreadQuietSeconds: {
|
|
2101
|
+
key: "kukeon-unread-quiet-seconds",
|
|
2102
|
+
label: "Mark unread after quiet for",
|
|
2103
|
+
defaultValue: 0,
|
|
2104
|
+
note: "How long a terminal must be quiet before its new output marks the cell. Off marks it on the first new byte.",
|
|
2105
|
+
parse: dn,
|
|
2106
|
+
format: (e) => String(e)
|
|
2107
|
+
},
|
|
2108
|
+
showGetStarted: {
|
|
2109
|
+
key: "kukeon-get-started",
|
|
2110
|
+
label: "Show Get started",
|
|
2111
|
+
defaultValue: !0,
|
|
2112
|
+
parse: fn,
|
|
2113
|
+
format: (e) => String(e)
|
|
2114
|
+
}
|
|
2115
|
+
}, xn = [
|
|
2116
|
+
{
|
|
2117
|
+
title: "Appearance",
|
|
2118
|
+
settings: ["theme"]
|
|
2119
|
+
},
|
|
2120
|
+
{
|
|
2121
|
+
title: "Terminal",
|
|
2122
|
+
settings: ["autoAttach"]
|
|
2123
|
+
},
|
|
2124
|
+
{
|
|
2125
|
+
title: "Refresh",
|
|
2126
|
+
settings: [
|
|
2127
|
+
"refreshSeconds",
|
|
2128
|
+
"unreadPollSeconds",
|
|
2129
|
+
"gridScreenSeconds",
|
|
2130
|
+
"unreadQuietSeconds"
|
|
2131
|
+
]
|
|
2132
|
+
},
|
|
2133
|
+
{
|
|
2134
|
+
title: "Workbench",
|
|
2135
|
+
settings: ["showGetStarted"]
|
|
2136
|
+
},
|
|
2137
|
+
{
|
|
2138
|
+
title: "Cell list",
|
|
2139
|
+
settings: ["cellListStyle", "defaultGroupBy"]
|
|
2140
|
+
},
|
|
2141
|
+
{
|
|
2142
|
+
title: "Sidebar",
|
|
2143
|
+
settings: [
|
|
2144
|
+
"showCellScope",
|
|
2145
|
+
"showTerminalStatus",
|
|
2146
|
+
"showUnreadBytes",
|
|
2147
|
+
"showSidebarSearch",
|
|
2148
|
+
"showSidebarGroupBy"
|
|
2149
|
+
]
|
|
2150
|
+
},
|
|
2151
|
+
{
|
|
2152
|
+
title: "Workbench grid",
|
|
2153
|
+
settings: ["showGridSearch", "showGridGroupBy"]
|
|
2154
|
+
}
|
|
2155
|
+
];
|
|
2156
|
+
function Sn(e) {
|
|
2157
|
+
let t = bn[e];
|
|
2158
|
+
try {
|
|
2159
|
+
let e = localStorage.getItem(t.key);
|
|
2160
|
+
return e === null ? t.defaultValue : t.parse(e) ?? t.defaultValue;
|
|
2161
|
+
} catch {
|
|
2162
|
+
return t.defaultValue;
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
function Cn() {
|
|
2166
|
+
return Object.fromEntries(Object.keys(bn).map((e) => [e, Sn(e)]));
|
|
2167
|
+
}
|
|
2168
|
+
var wn = Cn(), Tn = /* @__PURE__ */ new Set();
|
|
2169
|
+
function En(e) {
|
|
2170
|
+
return Tn.add(e), () => {
|
|
2171
|
+
Tn.delete(e);
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
function Dn(e, t) {
|
|
2175
|
+
let n = bn[e];
|
|
2176
|
+
try {
|
|
2177
|
+
localStorage.setItem(n.key, n.format(t));
|
|
2178
|
+
} catch {}
|
|
2179
|
+
wn = {
|
|
2180
|
+
...wn,
|
|
2181
|
+
[e]: t
|
|
2182
|
+
};
|
|
2183
|
+
for (let e of Tn) e();
|
|
2184
|
+
}
|
|
2185
|
+
function On() {
|
|
2186
|
+
return [N(En, () => wn), D((e, t) => Dn(e, t), [])];
|
|
2187
|
+
}
|
|
2188
|
+
// src/panel-cells.mjs
|
|
2189
|
+
var kn = "kukeon-panel-cells", An = (e) => Array.isArray(e) ? [...new Set(e.filter((e) => typeof e == "string" && e))] : [];
|
|
2190
|
+
function jn(e) {
|
|
2191
|
+
if (typeof e != "string") return {
|
|
2192
|
+
added: [],
|
|
2193
|
+
removed: []
|
|
2194
|
+
};
|
|
2195
|
+
let t;
|
|
2196
|
+
try {
|
|
2197
|
+
t = JSON.parse(e);
|
|
2198
|
+
} catch {
|
|
2199
|
+
return {
|
|
2200
|
+
added: [],
|
|
2201
|
+
removed: []
|
|
2202
|
+
};
|
|
2203
|
+
}
|
|
2204
|
+
return !t || typeof t != "object" || Array.isArray(t) ? {
|
|
2205
|
+
added: [],
|
|
2206
|
+
removed: []
|
|
2207
|
+
} : {
|
|
2208
|
+
added: An(t.added),
|
|
2209
|
+
removed: An(t.removed)
|
|
2210
|
+
};
|
|
2211
|
+
}
|
|
2212
|
+
function Mn(e, t, n) {
|
|
2213
|
+
let r = new Set(n.removed), i = new Set(e), a = new Set(t);
|
|
2214
|
+
return [...e.filter((e) => !r.has(e)), ...n.added.filter((e) => a.has(e) && !i.has(e))];
|
|
2215
|
+
}
|
|
2216
|
+
function Nn(e, t, n) {
|
|
2217
|
+
let r = e.removed.filter((e) => e !== t);
|
|
2218
|
+
return n ? {
|
|
2219
|
+
added: e.added.filter((e) => e !== t),
|
|
2220
|
+
removed: r
|
|
2221
|
+
} : {
|
|
2222
|
+
added: e.added.includes(t) ? e.added : [...e.added, t],
|
|
2223
|
+
removed: r
|
|
2224
|
+
};
|
|
2225
|
+
}
|
|
2226
|
+
function Pn(e, t, n) {
|
|
2227
|
+
let r = e.added.filter((e) => e !== t);
|
|
2228
|
+
return n ? {
|
|
2229
|
+
added: r,
|
|
2230
|
+
removed: e.removed.includes(t) ? e.removed : [...e.removed, t]
|
|
2231
|
+
} : {
|
|
2232
|
+
added: r,
|
|
2233
|
+
removed: e.removed.filter((e) => e !== t)
|
|
2234
|
+
};
|
|
2235
|
+
}
|
|
2236
|
+
function Fn(e, t) {
|
|
2237
|
+
let n = new Set(t);
|
|
2238
|
+
return {
|
|
2239
|
+
added: e.added.filter((e) => n.has(e)),
|
|
2240
|
+
removed: e.removed.filter((e) => n.has(e))
|
|
2241
|
+
};
|
|
2242
|
+
}
|
|
2243
|
+
function In(e, t) {
|
|
2244
|
+
return e.added.length === t.added.length && e.removed.length === t.removed.length && e.added.every((e, n) => e === t.added[n]) && e.removed.every((e, n) => e === t.removed[n]);
|
|
2245
|
+
}
|
|
2246
|
+
// src/majordomo.tsx
|
|
2247
|
+
var Ln = "kukeon.io/team", Rn = "kukeon.io/role", zn = "kukeon.io/task", Bn = "kukeon.io/harness", Vn = "kuke", Hn = "majordomo", Un = Hn, Wn = "health-sweep", Gn = "majordomo", Kn = "kukeon-majordomo-active";
|
|
2248
|
+
function qn(e) {
|
|
2249
|
+
return e?.[Ln] === Vn && e?.[Rn] === Un;
|
|
2250
|
+
}
|
|
2251
|
+
function Jn(e) {
|
|
2252
|
+
return qn(e.metadata.labels) && !e.metadata.labels?.[zn];
|
|
2253
|
+
}
|
|
2254
|
+
function Yn(e) {
|
|
2255
|
+
return qn(e.metadata.labels) && e.metadata.labels?.[zn] === "health-sweep";
|
|
2256
|
+
}
|
|
2257
|
+
function Xn(e) {
|
|
2258
|
+
return qn(e.metadata.labels) && !e.metadata.labels?.[zn];
|
|
2259
|
+
}
|
|
2260
|
+
function Zn(e) {
|
|
2261
|
+
return [
|
|
2262
|
+
e.metadata.realm || "default",
|
|
2263
|
+
e.metadata.space || "default",
|
|
2264
|
+
e.metadata.stack || "default"
|
|
2265
|
+
];
|
|
2266
|
+
}
|
|
2267
|
+
function Qn(e) {
|
|
2268
|
+
return {
|
|
2269
|
+
name: e.metadata.name,
|
|
2270
|
+
realm: e.metadata.realm,
|
|
2271
|
+
space: e.metadata.space,
|
|
2272
|
+
stack: e.metadata.stack
|
|
2273
|
+
};
|
|
2274
|
+
}
|
|
2275
|
+
function $n(e, t) {
|
|
2276
|
+
let n = v(e.doc);
|
|
2277
|
+
return n ? _(Qn(t), n) : e.doc.metadata.labels?.["kukeon.io/config"] === t.metadata.name && e.scope[0] === Zn(t)[0];
|
|
2278
|
+
}
|
|
2279
|
+
function er(e, t) {
|
|
2280
|
+
return t.find((t) => $n(e, t));
|
|
2281
|
+
}
|
|
2282
|
+
function tr(e) {
|
|
2283
|
+
let t = Date.parse(e.doc.status?.createdAt ?? "");
|
|
2284
|
+
return Number.isFinite(t) && !(e.doc.status?.createdAt ?? "").startsWith("0001-") ? t : 2 ** 53 - 1;
|
|
2285
|
+
}
|
|
2286
|
+
var nr = (e) => e.find((e) => e.doc.status?.state === "Ready") ?? e[0];
|
|
2287
|
+
function rr(e, t) {
|
|
2288
|
+
let n = i("/catalog/configs", t), [r, a] = M(() => hr(Kn) ?? ""), o = A(() => (e) => {
|
|
2289
|
+
a(e), gr(Kn, e);
|
|
2290
|
+
}, []), [s, c] = M(() => jn(hr(kn))), l = D((e) => c((t) => {
|
|
2291
|
+
let n = e(t);
|
|
2292
|
+
return In(n, t) ? t : n;
|
|
2293
|
+
}), []);
|
|
2294
|
+
O(() => {
|
|
2295
|
+
gr(kn, JSON.stringify(s));
|
|
2296
|
+
}, [s]);
|
|
2297
|
+
let u = A(() => {
|
|
2298
|
+
let t = n.data ?? [], i = e.data?.rows[3] ?? [], a = i.filter((e) => Xn(e.doc)).sort((e, t) => tr(e) - tr(t) || e.scope.join("/").localeCompare(t.scope.join("/"))), c = new Map(i.map((e) => [$(e.scope), e])), u = a.map((e) => $(e.scope)), d = Mn(u, c.keys(), s), f = d.map((e) => c.get(e)), p = f.find((e) => $(e.scope) === r) ?? nr(f), m = p && Xn(p.doc) ? p : nr(f.filter((e) => Xn(e.doc))) ?? nr(a), h = i.filter((e) => !d.includes($(e.scope))).sort((e, t) => e.scope.join("/").localeCompare(t.scope.join("/"))), g = t.filter(Jn), _ = g.filter((e) => !a.some((t) => $n(t, e)));
|
|
2299
|
+
return {
|
|
2300
|
+
configs: n,
|
|
2301
|
+
pairs: g,
|
|
2302
|
+
sweeps: t.filter(Yn),
|
|
2303
|
+
cells: a,
|
|
2304
|
+
cell: m,
|
|
2305
|
+
panel: f,
|
|
2306
|
+
active: p,
|
|
2307
|
+
candidates: h,
|
|
2308
|
+
unused: _,
|
|
2309
|
+
select: o,
|
|
2310
|
+
add: (e) => {
|
|
2311
|
+
l((t) => Nn(t, e, u.includes(e))), o(e);
|
|
2312
|
+
},
|
|
2313
|
+
remove: (e) => l((t) => Pn(t, e, u.includes(e)))
|
|
2314
|
+
};
|
|
2315
|
+
}, [
|
|
2316
|
+
n,
|
|
2317
|
+
e.data,
|
|
2318
|
+
r,
|
|
2319
|
+
o,
|
|
2320
|
+
s,
|
|
2321
|
+
l
|
|
2322
|
+
]), d = u.active ? $(u.active.scope) : "", f = !!e.data && !e.data.failures.length;
|
|
2323
|
+
O(() => {
|
|
2324
|
+
f && d && d !== r && !u.panel.some((e) => $(e.scope) === r) && o(d);
|
|
2325
|
+
}, [
|
|
2326
|
+
f,
|
|
2327
|
+
d,
|
|
2328
|
+
r,
|
|
2329
|
+
u.panel,
|
|
2330
|
+
o
|
|
2331
|
+
]);
|
|
2332
|
+
let p = f ? (e.data?.rows[3] ?? []).map((e) => $(e.scope)).join("\n") : null;
|
|
2333
|
+
return O(() => {
|
|
2334
|
+
p !== null && l((e) => Fn(e, p ? p.split("\n") : []));
|
|
2335
|
+
}, [p, l]), u;
|
|
2336
|
+
}
|
|
2337
|
+
function ir(e) {
|
|
2338
|
+
return e.replace(/[\u0000-\u001f\u007f]+/g, " ").replace(/\s+/g, " ").trim();
|
|
2339
|
+
}
|
|
2340
|
+
function ar(e) {
|
|
2341
|
+
let t = [`state ${e?.state || "not reported"}`];
|
|
2342
|
+
return e?.reason && t.push(`reason: ${e.reason}`), e?.message && t.push(`message: ${e.message}`), e?.outOfSyncError ? t.push(`config comparison failed: ${e.outOfSyncError}`) : e?.outOfSync && t.push(`out of sync with its config: ${e.outOfSyncReason || "reason not reported"}`), t.join("; ");
|
|
2343
|
+
}
|
|
2344
|
+
function or(e, t) {
|
|
2345
|
+
return ir(`About the cell ${e[3]} in realm ${e[0]}, space ${e[1]}, stack ${e[2]} (${ar(t)}): what is going on with it, and what should I do?`);
|
|
2346
|
+
}
|
|
2347
|
+
function sr(e, t, n) {
|
|
2348
|
+
let [r, i, a] = t.length === 4 ? t : [
|
|
2349
|
+
t[0],
|
|
2350
|
+
t[1],
|
|
2351
|
+
t[2]
|
|
2352
|
+
];
|
|
2353
|
+
return ir(`About the ${e} ${t.at(-1)} in ${[
|
|
2354
|
+
`realm ${r}`,
|
|
2355
|
+
i && t.length > 2 ? `space ${i}` : "",
|
|
2356
|
+
a && t.length > 3 ? `stack ${a}` : ""
|
|
2357
|
+
].filter(Boolean).join(", ")} (${n}): explain what it is for and check whether anything is wrong with it.`);
|
|
2358
|
+
}
|
|
2359
|
+
var cr = E(null), lr = cr.Provider;
|
|
2360
|
+
function ur({ question: e, subject: t, prominent: n = !1 }) {
|
|
2361
|
+
let r = ee(cr);
|
|
2362
|
+
return r ? /* @__PURE__ */ R("button", {
|
|
2363
|
+
type: "button",
|
|
2364
|
+
className: `ask-majordomo${n ? " is-prominent" : ""}`,
|
|
2365
|
+
"aria-label": `Ask majordomo about ${t}`,
|
|
2366
|
+
title: "Opens the majordomo panel and pastes this question without sending it",
|
|
2367
|
+
onClick: () => r(e),
|
|
2368
|
+
children: [/* @__PURE__ */ L(B, { name: "majordomo" }), /* @__PURE__ */ L("span", { children: "Ask majordomo" })]
|
|
2369
|
+
}) : null;
|
|
2370
|
+
}
|
|
2371
|
+
var dr = "kukeon-majordomo-open", fr = "kukeon-majordomo-width", pr = {
|
|
2372
|
+
min: 320,
|
|
2373
|
+
max: 960,
|
|
2374
|
+
initial: 480,
|
|
2375
|
+
step: 24
|
|
2376
|
+
};
|
|
2377
|
+
function mr(e) {
|
|
2378
|
+
return Math.round(Math.min(pr.max, Math.max(pr.min, e)));
|
|
2379
|
+
}
|
|
2380
|
+
function hr(e) {
|
|
2381
|
+
try {
|
|
2382
|
+
return localStorage.getItem(e);
|
|
2383
|
+
} catch {
|
|
2384
|
+
return null;
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
function gr(e, t) {
|
|
2388
|
+
try {
|
|
2389
|
+
localStorage.setItem(e, t);
|
|
2390
|
+
} catch {}
|
|
2391
|
+
}
|
|
2392
|
+
function _r() {
|
|
2393
|
+
let [e, t] = M(() => window.innerWidth);
|
|
2394
|
+
return O(() => {
|
|
2395
|
+
let e = 0, n = () => {
|
|
2396
|
+
cancelAnimationFrame(e), e = requestAnimationFrame(() => t(window.innerWidth));
|
|
2397
|
+
};
|
|
2398
|
+
return window.addEventListener("resize", n), () => {
|
|
2399
|
+
cancelAnimationFrame(e), window.removeEventListener("resize", n);
|
|
2400
|
+
};
|
|
2401
|
+
}, []), e;
|
|
2402
|
+
}
|
|
2403
|
+
function vr(e, t) {
|
|
2404
|
+
let [n, r] = M(() => hr(dr) === "true"), [i, a] = M(() => {
|
|
2405
|
+
let e = Number(hr(fr));
|
|
2406
|
+
return Number.isFinite(e) && e > 0 ? mr(e) : pr.initial;
|
|
2407
|
+
}), [o, s] = M("");
|
|
2408
|
+
O(() => {
|
|
2409
|
+
gr(dr, String(n));
|
|
2410
|
+
}, [n]), O(() => {
|
|
2411
|
+
gr(fr, String(i));
|
|
2412
|
+
}, [i]);
|
|
2413
|
+
let c = e - t - 800, l = e <= 760 || c < pr.min, u = Math.max(pr.min, Math.min(pr.max, l ? e : c));
|
|
2414
|
+
return {
|
|
2415
|
+
open: n,
|
|
2416
|
+
setOpen: r,
|
|
2417
|
+
width: i,
|
|
2418
|
+
effectiveWidth: Math.min(i, u),
|
|
2419
|
+
maxWidth: u,
|
|
2420
|
+
overlay: l,
|
|
2421
|
+
setWidth: (e) => a(mr(e)),
|
|
2422
|
+
question: o,
|
|
2423
|
+
ask: (e) => {
|
|
2424
|
+
s(ir(e)), r(!0);
|
|
2425
|
+
},
|
|
2426
|
+
clearQuestion: () => s("")
|
|
2427
|
+
};
|
|
2428
|
+
}
|
|
2429
|
+
function yr(e) {
|
|
2430
|
+
return e.cell ? {
|
|
2431
|
+
label: `${e.cell.doc.status?.state || "State not reported"}${e.cells.length > 1 ? `, ${e.cells.length} cells` : ""}`,
|
|
2432
|
+
state: e.cell.doc.status?.state
|
|
2433
|
+
} : e.configs.loading && !e.configs.data ? { label: "Checking…" } : e.configs.error && !e.configs.data ? { label: "Unavailable" } : { label: e.pairs.length ? "Not enabled" : "Not initialized" };
|
|
2434
|
+
}
|
|
2435
|
+
function br(e) {
|
|
2436
|
+
return !e.cell && !!e.configs.data && !e.pairs.length;
|
|
2437
|
+
}
|
|
2438
|
+
function xr({ major: e, dock: t, onChanged: n }) {
|
|
2439
|
+
let { label: r, state: i } = yr(e);
|
|
2440
|
+
return /* @__PURE__ */ R("section", {
|
|
2441
|
+
className: "majordomo-entry",
|
|
2442
|
+
"aria-label": "Majordomo",
|
|
2443
|
+
children: [/* @__PURE__ */ R("button", {
|
|
2444
|
+
type: "button",
|
|
2445
|
+
className: "majordomo-entry-button",
|
|
2446
|
+
"aria-expanded": t.open,
|
|
2447
|
+
"aria-controls": "majordomo-panel",
|
|
2448
|
+
onClick: () => t.setOpen(!0),
|
|
2449
|
+
children: [
|
|
2450
|
+
/* @__PURE__ */ L(B, { name: "majordomo" }),
|
|
2451
|
+
/* @__PURE__ */ L("span", {
|
|
2452
|
+
className: "majordomo-entry-name",
|
|
2453
|
+
children: "Majordomo"
|
|
2454
|
+
}),
|
|
2455
|
+
i ? /* @__PURE__ */ L(U, { state: i }) : /* @__PURE__ */ L("span", {
|
|
2456
|
+
className: "badge",
|
|
2457
|
+
children: r
|
|
2458
|
+
}),
|
|
2459
|
+
e.cells.length > 1 && /* @__PURE__ */ L("span", {
|
|
2460
|
+
className: "badge majordomo-count",
|
|
2461
|
+
"aria-label": `${e.cells.length} majordomo cells`,
|
|
2462
|
+
title: `${e.cells.length} majordomo cells`,
|
|
2463
|
+
children: e.cells.length
|
|
2464
|
+
})
|
|
2465
|
+
]
|
|
2466
|
+
}), br(e) && /* @__PURE__ */ L(T, {
|
|
2467
|
+
compact: !0,
|
|
2468
|
+
onChanged: n,
|
|
2469
|
+
subject: "majordomo and the agent templates"
|
|
2470
|
+
})]
|
|
2471
|
+
});
|
|
2472
|
+
}
|
|
2473
|
+
function Sr({ major: e, dock: t }) {
|
|
2474
|
+
let n = `Majordomo (${yr(e).label})`;
|
|
2475
|
+
return /* @__PURE__ */ L("button", {
|
|
2476
|
+
type: "button",
|
|
2477
|
+
className: "icon-button rail-majordomo",
|
|
2478
|
+
"aria-label": n,
|
|
2479
|
+
title: n,
|
|
2480
|
+
"aria-expanded": t.open,
|
|
2481
|
+
"aria-controls": "majordomo-panel",
|
|
2482
|
+
onClick: () => t.setOpen(!0),
|
|
2483
|
+
children: /* @__PURE__ */ L(B, { name: "majordomo" })
|
|
2484
|
+
});
|
|
2485
|
+
}
|
|
2486
|
+
function Cr({ dock: e }) {
|
|
2487
|
+
let t = e.open ? "Hide majordomo panel" : "Show majordomo panel";
|
|
2488
|
+
return /* @__PURE__ */ L("button", {
|
|
2489
|
+
type: "button",
|
|
2490
|
+
className: "icon-button majordomo-toolbar-button",
|
|
2491
|
+
"aria-label": t,
|
|
2492
|
+
title: t,
|
|
2493
|
+
"aria-pressed": e.open,
|
|
2494
|
+
"aria-controls": "majordomo-panel",
|
|
2495
|
+
onClick: () => e.setOpen(!e.open),
|
|
2496
|
+
children: /* @__PURE__ */ L(B, { name: "majordomo" })
|
|
2497
|
+
});
|
|
2498
|
+
}
|
|
2499
|
+
async function wr(e, t) {
|
|
2500
|
+
let n = await P(e, {
|
|
2501
|
+
method: "POST",
|
|
2502
|
+
headers: t === void 0 ? { Accept: "application/json" } : {
|
|
2503
|
+
Accept: "application/json",
|
|
2504
|
+
"Content-Type": "application/json"
|
|
2505
|
+
},
|
|
2506
|
+
...t === void 0 ? {} : { body: JSON.stringify(t) }
|
|
2507
|
+
}), r = {};
|
|
2508
|
+
try {
|
|
2509
|
+
r = await n.json();
|
|
2510
|
+
} catch {}
|
|
2511
|
+
return {
|
|
2512
|
+
ok: n.ok,
|
|
2513
|
+
status: n.status,
|
|
2514
|
+
body: r
|
|
2515
|
+
};
|
|
2516
|
+
}
|
|
2517
|
+
function Tr({ width: e, max: t, onResize: n }) {
|
|
2518
|
+
let r = j(null);
|
|
2519
|
+
function i(t) {
|
|
2520
|
+
t.button === 0 && (t.preventDefault(), r.current = {
|
|
2521
|
+
x: t.clientX,
|
|
2522
|
+
width: e
|
|
2523
|
+
}, t.currentTarget.setPointerCapture(t.pointerId));
|
|
2524
|
+
}
|
|
2525
|
+
function a(e) {
|
|
2526
|
+
r.current && n(r.current.width - (e.clientX - r.current.x));
|
|
2527
|
+
}
|
|
2528
|
+
function o(e) {
|
|
2529
|
+
r.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId);
|
|
2530
|
+
}
|
|
2531
|
+
function s(t) {
|
|
2532
|
+
let r = t.key === "ArrowLeft" ? e + pr.step : t.key === "ArrowRight" ? e - pr.step : t.key === "Home" ? pr.max : t.key === "End" ? pr.min : null;
|
|
2533
|
+
r !== null && (t.preventDefault(), n(r));
|
|
2534
|
+
}
|
|
2535
|
+
return /* @__PURE__ */ L("div", {
|
|
2536
|
+
className: "majordomo-resizer",
|
|
2537
|
+
role: "separator",
|
|
2538
|
+
"aria-orientation": "vertical",
|
|
2539
|
+
"aria-label": "Resize majordomo panel",
|
|
2540
|
+
"aria-controls": "majordomo-panel",
|
|
2541
|
+
"aria-valuenow": e,
|
|
2542
|
+
"aria-valuemin": pr.min,
|
|
2543
|
+
"aria-valuemax": t,
|
|
2544
|
+
tabIndex: 0,
|
|
2545
|
+
onPointerDown: i,
|
|
2546
|
+
onPointerMove: a,
|
|
2547
|
+
onPointerUp: o,
|
|
2548
|
+
onPointerCancel: o,
|
|
2549
|
+
onKeyDown: s
|
|
2550
|
+
});
|
|
2551
|
+
}
|
|
2552
|
+
function Er(e) {
|
|
2553
|
+
return p(e).find((e) => d(e) && !!e.login);
|
|
2554
|
+
}
|
|
2555
|
+
function Dr({ status: e, asking: t = !1, busy: r = !1, onContinue: a, onChanged: s }) {
|
|
2556
|
+
let [c, d] = M(!1), [f, p] = M(""), [m, h] = M(!1), [g, _] = M(0), v = i(m ? "/connectors/logins" : null, g), y = j(!1), b = j(0);
|
|
2557
|
+
O(() => {
|
|
2558
|
+
if (!m) return;
|
|
2559
|
+
let e = window.setInterval(() => _((e) => e + 1), 3e3);
|
|
2560
|
+
return () => window.clearInterval(e);
|
|
2561
|
+
}, [m]), O(() => {
|
|
2562
|
+
m && !v.loading && v.data && (u(v.data, e.connector).some((t) => l(t.volume, e.volumeRef) && !!t.session) ? (y.current = !0, b.current = 0) : (b.current += 1, (y.current || b.current >= 3) && (h(!1), s())));
|
|
2563
|
+
}, [
|
|
2564
|
+
m,
|
|
2565
|
+
v.data,
|
|
2566
|
+
v.loading
|
|
2567
|
+
]);
|
|
2568
|
+
let x = n(e), S = e.login?.state;
|
|
2569
|
+
async function C() {
|
|
2570
|
+
if (!c && e.volumeRef) {
|
|
2571
|
+
d(!0), p("");
|
|
2572
|
+
try {
|
|
2573
|
+
await o(e.connector, e.volumeRef, e.method), y.current = !1, b.current = 0, h(!0);
|
|
2574
|
+
} catch (e) {
|
|
2575
|
+
p(e?.message ?? "The login could not be started.");
|
|
2576
|
+
} finally {
|
|
2577
|
+
d(!1);
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
if (S !== "logged in" && S !== "empty") return null;
|
|
2582
|
+
let w = t && S === "empty";
|
|
2583
|
+
return /* @__PURE__ */ R("div", {
|
|
2584
|
+
className: `majordomo-login${w ? " is-asking" : ""}`,
|
|
2585
|
+
role: w ? "group" : void 0,
|
|
2586
|
+
"aria-label": w ? "Log in first" : void 0,
|
|
2587
|
+
children: [
|
|
2588
|
+
/* @__PURE__ */ R("p", {
|
|
2589
|
+
role: "status",
|
|
2590
|
+
"aria-label": `${x} login`,
|
|
2591
|
+
children: [
|
|
2592
|
+
/* @__PURE__ */ L("span", {
|
|
2593
|
+
className: `state-dot tone-${S === "logged in" ? "ok" : "stopped"}`,
|
|
2594
|
+
"aria-hidden": "true"
|
|
2595
|
+
}),
|
|
2596
|
+
x,
|
|
2597
|
+
": ",
|
|
2598
|
+
S === "logged in" ? "logged in" : "not logged in"
|
|
2599
|
+
]
|
|
2600
|
+
}),
|
|
2601
|
+
w && /* @__PURE__ */ R("p", {
|
|
2602
|
+
className: "majordomo-login-ask",
|
|
2603
|
+
children: [
|
|
2604
|
+
"Majordomo starts without a login, and ",
|
|
2605
|
+
x,
|
|
2606
|
+
" then asks for one in its terminal. Log in first, or continue."
|
|
2607
|
+
]
|
|
2608
|
+
}),
|
|
2609
|
+
S === "empty" && e.volumeRef && /* @__PURE__ */ L("button", {
|
|
2610
|
+
type: "button",
|
|
2611
|
+
className: "text-button",
|
|
2612
|
+
disabled: c || r,
|
|
2613
|
+
"aria-label": `Log in to ${x} for majordomo`,
|
|
2614
|
+
onClick: () => void C(),
|
|
2615
|
+
children: c ? "Starting…" : m ? "Open login session" : "Log in"
|
|
2616
|
+
}),
|
|
2617
|
+
w && /* @__PURE__ */ L("button", {
|
|
2618
|
+
type: "button",
|
|
2619
|
+
className: "text-button",
|
|
2620
|
+
disabled: r,
|
|
2621
|
+
onClick: a,
|
|
2622
|
+
children: "Continue anyway"
|
|
2623
|
+
}),
|
|
2624
|
+
f && /* @__PURE__ */ L("p", {
|
|
2625
|
+
className: "error",
|
|
2626
|
+
role: "alert",
|
|
2627
|
+
children: f
|
|
2628
|
+
})
|
|
2629
|
+
]
|
|
2630
|
+
});
|
|
2631
|
+
}
|
|
2632
|
+
function Or({ major: e }) {
|
|
2633
|
+
let t = j(null), n = e.configs.data ?? [], r = e.active ? $(e.active.scope) : "";
|
|
2634
|
+
function i(n) {
|
|
2635
|
+
let i = e.panel.findIndex((e) => $(e.scope) === r), a = n.key === "ArrowRight" ? i + 1 : n.key === "ArrowLeft" ? i - 1 : n.key === "Home" ? 0 : n.key === "End" ? e.panel.length - 1 : null;
|
|
2636
|
+
if (a === null) return;
|
|
2637
|
+
n.preventDefault();
|
|
2638
|
+
let o = e.panel[(a + e.panel.length) % e.panel.length];
|
|
2639
|
+
e.select($(o.scope)), requestAnimationFrame(() => t.current?.querySelector("[aria-selected=\"true\"]")?.focus());
|
|
2640
|
+
}
|
|
2641
|
+
let a = (e) => er(e, n)?.metadata.name ?? v(e.doc)?.name ?? e.doc.metadata.labels?.["kukeon.io/config"] ?? e.doc.metadata.name, o = e.panel.filter((e) => Xn(e.doc)).map(a);
|
|
2642
|
+
return /* @__PURE__ */ L("div", {
|
|
2643
|
+
className: "majordomo-tabs",
|
|
2644
|
+
role: "tablist",
|
|
2645
|
+
"aria-label": "Panel cells",
|
|
2646
|
+
ref: t,
|
|
2647
|
+
onKeyDown: i,
|
|
2648
|
+
children: e.panel.map((t) => {
|
|
2649
|
+
let n = $(t.scope), i = n === r, s = Xn(t.doc) ? a(t) : "", c = s && o.indexOf(s) === o.lastIndexOf(s) ? s : t.doc.metadata.name, l = t.doc.status?.state, u = l === "Ready" ? "ok" : l && Yt.has(l) ? "stopped" : "pending";
|
|
2650
|
+
return /* @__PURE__ */ R("button", {
|
|
2651
|
+
type: "button",
|
|
2652
|
+
role: "tab",
|
|
2653
|
+
className: "majordomo-tab",
|
|
2654
|
+
"aria-selected": i,
|
|
2655
|
+
"aria-controls": "majordomo-screens",
|
|
2656
|
+
tabIndex: i ? 0 : -1,
|
|
2657
|
+
title: `${t.scope.join(" / ")} (${l || "state not reported"})`,
|
|
2658
|
+
onClick: () => e.select(n),
|
|
2659
|
+
children: [
|
|
2660
|
+
/* @__PURE__ */ L("span", {
|
|
2661
|
+
className: `state-dot tone-${u}`,
|
|
2662
|
+
"aria-hidden": "true"
|
|
2663
|
+
}),
|
|
2664
|
+
/* @__PURE__ */ L("span", {
|
|
2665
|
+
className: "majordomo-tab-label",
|
|
2666
|
+
children: c
|
|
2667
|
+
}),
|
|
2668
|
+
/* @__PURE__ */ R("span", {
|
|
2669
|
+
className: "sr-only",
|
|
2670
|
+
children: [", ", l || "state not reported"]
|
|
2671
|
+
})
|
|
2672
|
+
]
|
|
2673
|
+
}, n);
|
|
2674
|
+
})
|
|
2675
|
+
});
|
|
2676
|
+
}
|
|
2677
|
+
function kr({ major: e, dock: t, inventory: n, manager: r, theme: a, revision: o, onChanged: c }) {
|
|
2678
|
+
let l = e.active, u = l?.scope ?? null, d = u ? $(u) : "", p = !!l && Xn(l.doc), m = p ? "majordomo" : l?.doc.metadata.name ?? "", h = l?.doc.status?.state, g = !!u && !!h && !Yt.has(h), _ = i(u ? `${f(u)}/containers` : null, o), v = _.data?.filter((e) => e.attachable && !e.root) ?? [], y = v.some((e) => e.id === r.selection[d]) ? r.selection[d] : v[0]?.id ?? "", b = u && y ? Jt(u, y, "panel") : "", x = e.panel.map((e) => $(e.scope)), S = r.sessions.filter((e) => e.view === "panel" && x.includes($(e.scope))), C = S.find((e) => e.id === b), [w, E] = M({}), [D, ee] = M(""), [k, A] = M(!1), [j, N] = M(!1), [P, F] = M(""), [I, z] = M(""), [V, H] = M(""), [W, G] = M(!1), K = !l && !e.cells.length, ne = !l && !K && !j && !k, q = e.cells.length ? e.unused : e.pairs, J = q.find((e) => JSON.stringify([...Zn(e), e.metadata.name]) === D) ?? q[0], re = K || k, Y = Er(re ? J : p ? er(l, e.configs.data ?? []) : void 0), ie = re && Y?.login?.state === "empty";
|
|
2679
|
+
O(() => {
|
|
2680
|
+
ie || G(!1);
|
|
2681
|
+
}, [ie]);
|
|
2682
|
+
let ae = !_.loading && !!_.data, oe = e.candidates.some((e) => $(e.scope) === P) ? P : e.candidates[0] ? $(e.candidates[0].scope) : "", [{ autoAttach: X }] = On(), Z = X && t.open && !!u && g && !!y && !w[d] && ae;
|
|
2683
|
+
O(() => {
|
|
2684
|
+
Z && !C && r.attach(u, y, "panel");
|
|
2685
|
+
}, [
|
|
2686
|
+
Z,
|
|
2687
|
+
d,
|
|
2688
|
+
y,
|
|
2689
|
+
C,
|
|
2690
|
+
r.attach
|
|
2691
|
+
]);
|
|
2692
|
+
let se = $t(C, Z, (e) => r.attach(e.scope, e.container, "panel")), Q = e.cell ? $(e.cell.scope) : "", ce = x.includes(Q);
|
|
2693
|
+
O(() => {
|
|
2694
|
+
t.question && Q && !p && (ce ? e.select(Q) : e.add(Q));
|
|
2695
|
+
}, [
|
|
2696
|
+
t.question,
|
|
2697
|
+
Q,
|
|
2698
|
+
ce,
|
|
2699
|
+
p
|
|
2700
|
+
]), O(() => {
|
|
2701
|
+
t.question && p && C && C.state === "attached" && (r.paste(C.id, t.question), t.clearQuestion());
|
|
2702
|
+
}, [
|
|
2703
|
+
t.question,
|
|
2704
|
+
p,
|
|
2705
|
+
C?.id,
|
|
2706
|
+
C?.state
|
|
2707
|
+
]), O(() => {
|
|
2708
|
+
q.length || A(!1);
|
|
2709
|
+
}, [q.length]), O(() => {
|
|
2710
|
+
e.candidates.length || N(!1);
|
|
2711
|
+
}, [e.candidates.length]);
|
|
2712
|
+
async function le(e) {
|
|
2713
|
+
let t = await wr(`${f(e)}/start`);
|
|
2714
|
+
if (!t.ok) throw Error(t.body.error?.message ?? `HTTP ${t.status}`);
|
|
2715
|
+
}
|
|
2716
|
+
async function ue(t = !1) {
|
|
2717
|
+
if (!J || I || !K && !k) return;
|
|
2718
|
+
if (ie && !t) {
|
|
2719
|
+
G(!0);
|
|
2720
|
+
return;
|
|
2721
|
+
}
|
|
2722
|
+
G(!1), z("enable"), H("");
|
|
2723
|
+
let r = e.cells.length ? J.metadata.name : Gn;
|
|
2724
|
+
try {
|
|
2725
|
+
let t = {
|
|
2726
|
+
config: {
|
|
2727
|
+
name: J.metadata.name,
|
|
2728
|
+
realm: J.metadata.realm,
|
|
2729
|
+
space: J.metadata.space,
|
|
2730
|
+
stack: J.metadata.stack
|
|
2731
|
+
},
|
|
2732
|
+
name: r,
|
|
2733
|
+
env: [],
|
|
2734
|
+
ignoreDiskPressure: !1
|
|
2735
|
+
}, i = await wr("/cells/from-config/preview", t);
|
|
2736
|
+
if (!i.ok) throw Error(i.body.error?.message ?? `HTTP ${i.status}`);
|
|
2737
|
+
let a = i.body.document, o = await wr("/cells/from-config/create", {
|
|
2738
|
+
...t,
|
|
2739
|
+
resolvedName: a?.metadata.name,
|
|
2740
|
+
preview: i.body.preview
|
|
2741
|
+
});
|
|
2742
|
+
if (!o.ok) throw Error(o.body.error?.message ?? `HTTP ${o.status}`);
|
|
2743
|
+
let s = o.body;
|
|
2744
|
+
n.upsertCell(s);
|
|
2745
|
+
let c = [...Zn(J), s.metadata.name];
|
|
2746
|
+
e.select($(c)), A(!1), await le(c);
|
|
2747
|
+
} catch (e) {
|
|
2748
|
+
H(e instanceof Error ? e.message : "The request could not reach the web server.");
|
|
2749
|
+
} finally {
|
|
2750
|
+
z(""), c();
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
async function de() {
|
|
2754
|
+
if (u && !I) {
|
|
2755
|
+
z("start"), H("");
|
|
2756
|
+
try {
|
|
2757
|
+
await le(u);
|
|
2758
|
+
} catch (e) {
|
|
2759
|
+
H(e instanceof Error ? e.message : "The request could not reach the web server.");
|
|
2760
|
+
} finally {
|
|
2761
|
+
z(""), c();
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
function fe(t) {
|
|
2766
|
+
let n = $(t.scope);
|
|
2767
|
+
r.detachView(t.scope, "panel"), E((e) => {
|
|
2768
|
+
let t = { ...e };
|
|
2769
|
+
return delete t[n], t;
|
|
2770
|
+
}), H(""), e.remove(n);
|
|
2771
|
+
}
|
|
2772
|
+
function pe() {
|
|
2773
|
+
oe && (e.add(oe), N(!1), F(""));
|
|
2774
|
+
}
|
|
2775
|
+
let me = () => {
|
|
2776
|
+
A(!1), N((e) => !e);
|
|
2777
|
+
}, he = () => {
|
|
2778
|
+
N(!1), A((e) => !e);
|
|
2779
|
+
}, ge = C?.state === "attached" || C?.state === "connecting", _e = u ? g ? C ? {
|
|
2780
|
+
tone: C.state,
|
|
2781
|
+
label: C.state === "attached" ? "Attached" : C.state === "connecting" ? "Connecting…" : C.message || "Disconnected"
|
|
2782
|
+
} : w[d] ? {
|
|
2783
|
+
tone: "disconnected",
|
|
2784
|
+
label: "Detached"
|
|
2785
|
+
} : !_.loading && !v.length ? {
|
|
2786
|
+
tone: "disconnected",
|
|
2787
|
+
label: "No attachable container"
|
|
2788
|
+
} : X ? {
|
|
2789
|
+
tone: "connecting",
|
|
2790
|
+
label: "Connecting…"
|
|
2791
|
+
} : {
|
|
2792
|
+
tone: "disconnected",
|
|
2793
|
+
label: "Detached"
|
|
2794
|
+
} : {
|
|
2795
|
+
tone: "disconnected",
|
|
2796
|
+
label: `Cell is ${h || "in an unknown state"}`
|
|
2797
|
+
} : {
|
|
2798
|
+
tone: "disconnected",
|
|
2799
|
+
label: K ? "No majordomo cell" : "No cell in the panel"
|
|
2800
|
+
}, ve = !!u && g && !!y && !ge, ye = () => {
|
|
2801
|
+
u && y && (E((e) => ({
|
|
2802
|
+
...e,
|
|
2803
|
+
[d]: !1
|
|
2804
|
+
})), se(b), r.attach(u, y, "panel"));
|
|
2805
|
+
}, be = (t, n) => /* @__PURE__ */ R(te, { children: [
|
|
2806
|
+
/* @__PURE__ */ L("p", { children: t }),
|
|
2807
|
+
/* @__PURE__ */ R("label", { children: ["Harness", /* @__PURE__ */ L("select", {
|
|
2808
|
+
value: J ? JSON.stringify([...Zn(J), J.metadata.name]) : "",
|
|
2809
|
+
disabled: !!I,
|
|
2810
|
+
onChange: (e) => ee(e.target.value),
|
|
2811
|
+
children: q.map((e) => {
|
|
2812
|
+
let t = JSON.stringify([...Zn(e), e.metadata.name]);
|
|
2813
|
+
return /* @__PURE__ */ L("option", {
|
|
2814
|
+
value: t,
|
|
2815
|
+
children: e.metadata.name
|
|
2816
|
+
}, t);
|
|
2817
|
+
})
|
|
2818
|
+
})] }),
|
|
2819
|
+
/* @__PURE__ */ L("button", {
|
|
2820
|
+
type: "button",
|
|
2821
|
+
className: "majordomo-primary",
|
|
2822
|
+
disabled: !!I || !J,
|
|
2823
|
+
"aria-busy": I === "enable" || void 0,
|
|
2824
|
+
onClick: () => void ue(),
|
|
2825
|
+
children: I === "enable" ? e.cells.length ? "Adding majordomo…" : "Enabling majordomo…" : e.cells.length ? "Add majordomo" : "Enable majordomo"
|
|
2826
|
+
}),
|
|
2827
|
+
/* @__PURE__ */ L("small", { children: n })
|
|
2828
|
+
] }), xe = "Majordomo is kukeon's own assistant: ask it for help, and it changes things only when you ask.", Se = j ? /* @__PURE__ */ R("div", {
|
|
2829
|
+
className: "majordomo-setup majordomo-add",
|
|
2830
|
+
role: "group",
|
|
2831
|
+
"aria-label": "Add cell to the panel",
|
|
2832
|
+
children: [
|
|
2833
|
+
/* @__PURE__ */ L("p", { children: "Add a cell to the side panel. It stays open beside every page, and its cell screen keeps its own terminal." }),
|
|
2834
|
+
/* @__PURE__ */ R("label", { children: ["Cell", /* @__PURE__ */ L("select", {
|
|
2835
|
+
value: oe,
|
|
2836
|
+
onChange: (e) => F(e.target.value),
|
|
2837
|
+
children: e.candidates.map((e) => {
|
|
2838
|
+
let t = $(e.scope);
|
|
2839
|
+
return /* @__PURE__ */ L("option", {
|
|
2840
|
+
value: t,
|
|
2841
|
+
children: e.scope.join(" / ")
|
|
2842
|
+
}, t);
|
|
2843
|
+
})
|
|
2844
|
+
})] }),
|
|
2845
|
+
/* @__PURE__ */ L("button", {
|
|
2846
|
+
type: "button",
|
|
2847
|
+
className: "majordomo-primary",
|
|
2848
|
+
disabled: !oe,
|
|
2849
|
+
onClick: pe,
|
|
2850
|
+
children: "Add to panel"
|
|
2851
|
+
}),
|
|
2852
|
+
/* @__PURE__ */ L("button", {
|
|
2853
|
+
type: "button",
|
|
2854
|
+
className: "text-button",
|
|
2855
|
+
onClick: () => N(!1),
|
|
2856
|
+
children: "Cancel"
|
|
2857
|
+
})
|
|
2858
|
+
]
|
|
2859
|
+
}) : k ? /* @__PURE__ */ R("div", {
|
|
2860
|
+
className: "majordomo-setup majordomo-add",
|
|
2861
|
+
role: "group",
|
|
2862
|
+
"aria-label": "Add majordomo",
|
|
2863
|
+
children: [e.cells.length ? be("Add another majordomo with a different harness. Each runs in its own cell, in its own tab.", "Creates and starts a cell named after the selected config.") : be(xe, `Creates and starts one cell named ${Gn} from the selected config.`), /* @__PURE__ */ L("button", {
|
|
2864
|
+
type: "button",
|
|
2865
|
+
className: "text-button",
|
|
2866
|
+
disabled: !!I,
|
|
2867
|
+
onClick: () => A(!1),
|
|
2868
|
+
children: "Cancel"
|
|
2869
|
+
})]
|
|
2870
|
+
}) : K ? /* @__PURE__ */ L("div", {
|
|
2871
|
+
className: "majordomo-setup",
|
|
2872
|
+
children: e.configs.loading && !e.configs.data ? /* @__PURE__ */ L("p", {
|
|
2873
|
+
role: "status",
|
|
2874
|
+
children: "Looking for majordomo configs…"
|
|
2875
|
+
}) : e.configs.error && !e.configs.data ? /* @__PURE__ */ L(s, {
|
|
2876
|
+
error: e.configs.error,
|
|
2877
|
+
kind: "Configs"
|
|
2878
|
+
}) : e.pairs.length ? be(xe, `Creates and starts one cell named ${Gn} from the selected config.`) : /* @__PURE__ */ R("div", {
|
|
2879
|
+
className: "majordomo-missing",
|
|
2880
|
+
children: [/* @__PURE__ */ R("p", {
|
|
2881
|
+
role: "status",
|
|
2882
|
+
children: [/* @__PURE__ */ L("strong", { children: "Majordomo is not installed on this host." }), " Initialize applies its configs."]
|
|
2883
|
+
}), /* @__PURE__ */ L(T, {
|
|
2884
|
+
onChanged: c,
|
|
2885
|
+
subject: "majordomo and the agent templates"
|
|
2886
|
+
})]
|
|
2887
|
+
})
|
|
2888
|
+
}) : ne ? /* @__PURE__ */ R("div", {
|
|
2889
|
+
className: "majordomo-setup majordomo-empty",
|
|
2890
|
+
children: [/* @__PURE__ */ L("p", {
|
|
2891
|
+
role: "status",
|
|
2892
|
+
children: "The side panel holds no cells. Add any cell to it, majordomo included."
|
|
2893
|
+
}), /* @__PURE__ */ L("button", {
|
|
2894
|
+
type: "button",
|
|
2895
|
+
className: "majordomo-primary",
|
|
2896
|
+
disabled: !e.candidates.length,
|
|
2897
|
+
onClick: () => N(!0),
|
|
2898
|
+
children: "Add cell"
|
|
2899
|
+
})]
|
|
2900
|
+
}) : u && !g ? /* @__PURE__ */ R("div", {
|
|
2901
|
+
className: "majordomo-setup",
|
|
2902
|
+
children: [/* @__PURE__ */ R("p", {
|
|
2903
|
+
role: "status",
|
|
2904
|
+
children: [
|
|
2905
|
+
p ? "The majordomo cell" : "The cell",
|
|
2906
|
+
" ",
|
|
2907
|
+
/* @__PURE__ */ L("code", { children: u.join(" / ") }),
|
|
2908
|
+
" is ",
|
|
2909
|
+
/* @__PURE__ */ L(U, { state: h }),
|
|
2910
|
+
"."
|
|
2911
|
+
]
|
|
2912
|
+
}), /* @__PURE__ */ L("button", {
|
|
2913
|
+
type: "button",
|
|
2914
|
+
className: "majordomo-primary",
|
|
2915
|
+
disabled: !!I,
|
|
2916
|
+
"aria-busy": I === "start" || void 0,
|
|
2917
|
+
onClick: de,
|
|
2918
|
+
children: I === "start" ? "Starting…" : "Start"
|
|
2919
|
+
})]
|
|
2920
|
+
}) : null, Ce = e.panel.length > 1 || !!l && !p, we = k || j;
|
|
2921
|
+
return /* @__PURE__ */ R("aside", {
|
|
2922
|
+
className: "majordomo-panel",
|
|
2923
|
+
id: "majordomo-panel",
|
|
2924
|
+
"aria-label": "Majordomo panel",
|
|
2925
|
+
hidden: !t.open,
|
|
2926
|
+
style: { width: t.effectiveWidth },
|
|
2927
|
+
children: [
|
|
2928
|
+
/* @__PURE__ */ L(Tr, {
|
|
2929
|
+
width: t.effectiveWidth,
|
|
2930
|
+
max: t.maxWidth,
|
|
2931
|
+
onResize: t.setWidth
|
|
2932
|
+
}),
|
|
2933
|
+
/* @__PURE__ */ R("header", {
|
|
2934
|
+
className: "majordomo-header",
|
|
2935
|
+
children: [
|
|
2936
|
+
/* @__PURE__ */ R("h2", { children: [/* @__PURE__ */ L(B, { name: "majordomo" }), "Majordomo"] }),
|
|
2937
|
+
/* @__PURE__ */ R("span", {
|
|
2938
|
+
className: `terminal-connection-state ${_e.tone}`,
|
|
2939
|
+
role: "status",
|
|
2940
|
+
title: _e.label,
|
|
2941
|
+
children: [/* @__PURE__ */ L("span", {
|
|
2942
|
+
className: "state-dot",
|
|
2943
|
+
"aria-hidden": "true"
|
|
2944
|
+
}), /* @__PURE__ */ L("span", {
|
|
2945
|
+
className: "majordomo-connection-label",
|
|
2946
|
+
children: _e.label
|
|
2947
|
+
})]
|
|
2948
|
+
}),
|
|
2949
|
+
/* @__PURE__ */ R("div", {
|
|
2950
|
+
className: "majordomo-header-actions",
|
|
2951
|
+
children: [
|
|
2952
|
+
e.candidates.length > 0 && !ne && /* @__PURE__ */ L("button", {
|
|
2953
|
+
type: "button",
|
|
2954
|
+
className: "icon-button",
|
|
2955
|
+
"aria-label": "Add cell",
|
|
2956
|
+
title: "Add a cell to the side panel",
|
|
2957
|
+
"aria-expanded": j,
|
|
2958
|
+
onClick: me,
|
|
2959
|
+
children: /* @__PURE__ */ L(B, { name: "sidePanel" })
|
|
2960
|
+
}),
|
|
2961
|
+
q.length > 0 && !K && /* @__PURE__ */ L("button", {
|
|
2962
|
+
type: "button",
|
|
2963
|
+
className: "icon-button",
|
|
2964
|
+
"aria-label": "Add majordomo",
|
|
2965
|
+
title: e.cells.length ? "Add majordomo with another harness" : "Enable majordomo",
|
|
2966
|
+
"aria-expanded": k,
|
|
2967
|
+
onClick: he,
|
|
2968
|
+
children: /* @__PURE__ */ L(B, { name: "create" })
|
|
2969
|
+
}),
|
|
2970
|
+
ve && /* @__PURE__ */ L("button", {
|
|
2971
|
+
type: "button",
|
|
2972
|
+
className: "icon-button",
|
|
2973
|
+
"aria-label": `Reconnect ${m}`,
|
|
2974
|
+
title: "Reconnect",
|
|
2975
|
+
onClick: ye,
|
|
2976
|
+
children: /* @__PURE__ */ L(B, { name: "reconnect" })
|
|
2977
|
+
}),
|
|
2978
|
+
ge && C && /* @__PURE__ */ L("button", {
|
|
2979
|
+
type: "button",
|
|
2980
|
+
className: "icon-button",
|
|
2981
|
+
"aria-label": `Detach ${m}`,
|
|
2982
|
+
title: "Detach",
|
|
2983
|
+
onClick: () => {
|
|
2984
|
+
E((e) => ({
|
|
2985
|
+
...e,
|
|
2986
|
+
[d]: !0
|
|
2987
|
+
})), r.detach(C.id);
|
|
2988
|
+
},
|
|
2989
|
+
children: /* @__PURE__ */ L(B, { name: "detach" })
|
|
2990
|
+
}),
|
|
2991
|
+
l && /* @__PURE__ */ L("button", {
|
|
2992
|
+
type: "button",
|
|
2993
|
+
className: "icon-button",
|
|
2994
|
+
"aria-label": `Remove ${l.doc.metadata.name} from the side panel`,
|
|
2995
|
+
title: "Remove from the side panel (the cell and its cell screen's terminal stay)",
|
|
2996
|
+
onClick: () => fe(l),
|
|
2997
|
+
children: /* @__PURE__ */ L(B, { name: "remove" })
|
|
2998
|
+
}),
|
|
2999
|
+
/* @__PURE__ */ L("button", {
|
|
3000
|
+
type: "button",
|
|
3001
|
+
className: "icon-button",
|
|
3002
|
+
"aria-label": "Collapse majordomo panel",
|
|
3003
|
+
title: "Collapse (the session stays attached)",
|
|
3004
|
+
onClick: () => t.setOpen(!1),
|
|
3005
|
+
children: /* @__PURE__ */ L(B, { name: "sidebarExpand" })
|
|
3006
|
+
})
|
|
3007
|
+
]
|
|
3008
|
+
})
|
|
3009
|
+
]
|
|
3010
|
+
}),
|
|
3011
|
+
Ce && /* @__PURE__ */ L(Or, { major: e }),
|
|
3012
|
+
t.question && /* @__PURE__ */ R("p", {
|
|
3013
|
+
className: "majordomo-question",
|
|
3014
|
+
role: "status",
|
|
3015
|
+
children: [
|
|
3016
|
+
/* @__PURE__ */ L("strong", { children: "Waiting to paste:" }),
|
|
3017
|
+
" ",
|
|
3018
|
+
t.question,
|
|
3019
|
+
" ",
|
|
3020
|
+
/* @__PURE__ */ L("button", {
|
|
3021
|
+
type: "button",
|
|
3022
|
+
className: "text-button",
|
|
3023
|
+
onClick: t.clearQuestion,
|
|
3024
|
+
children: "Discard"
|
|
3025
|
+
})
|
|
3026
|
+
]
|
|
3027
|
+
}),
|
|
3028
|
+
Y && /* @__PURE__ */ L(Dr, {
|
|
3029
|
+
status: Y,
|
|
3030
|
+
asking: W,
|
|
3031
|
+
busy: !!I,
|
|
3032
|
+
onContinue: () => void ue(!0),
|
|
3033
|
+
onChanged: c
|
|
3034
|
+
}, `${Y.connector}/${JSON.stringify(Y.volumeRef ?? null)}`),
|
|
3035
|
+
V && /* @__PURE__ */ R("div", {
|
|
3036
|
+
className: "error",
|
|
3037
|
+
role: "alert",
|
|
3038
|
+
children: [/* @__PURE__ */ L("strong", { children: u && !k ? p ? "Majordomo did not start" : "The cell did not start" : e.cells.length ? "Majordomo could not be added" : "Majordomo could not be enabled" }), /* @__PURE__ */ L("p", { children: V })]
|
|
3039
|
+
}),
|
|
3040
|
+
Se,
|
|
3041
|
+
u && g && !we && _.error && !ge && /* @__PURE__ */ L(s, {
|
|
3042
|
+
error: _.error,
|
|
3043
|
+
kind: "Containers"
|
|
3044
|
+
}),
|
|
3045
|
+
/* @__PURE__ */ L("div", {
|
|
3046
|
+
className: "majordomo-screens",
|
|
3047
|
+
id: "majordomo-screens",
|
|
3048
|
+
role: Ce ? "tabpanel" : void 0,
|
|
3049
|
+
"aria-label": l ? `Terminal of ${l.doc.metadata.name}` : void 0,
|
|
3050
|
+
hidden: !u || !g || we,
|
|
3051
|
+
children: S.map((e) => /* @__PURE__ */ L(en, {
|
|
3052
|
+
session: e,
|
|
3053
|
+
active: t.open && !we && e.id === b,
|
|
3054
|
+
expanded: !1,
|
|
3055
|
+
theme: a,
|
|
3056
|
+
update: r.update,
|
|
3057
|
+
pending: r.pastes[e.id],
|
|
3058
|
+
onPasted: r.pasteDelivered
|
|
3059
|
+
}, e.id))
|
|
3060
|
+
})
|
|
3061
|
+
]
|
|
3062
|
+
});
|
|
3063
|
+
}
|
|
3064
|
+
export { nt as $, on as A, At as B, On as C, sn as D, an as E, Qt as F, Ot as G, Pt as H, Et as I, mt as J, ut as K, Dt as L, tn as M, $ as N, dn as O, Yt as P, Ze as Q, kt as R, mn as S, ln as T, Nt as U, It as V, jt as W, rt as X, Xe as Y, Qe as Z, _n as _, fe as _t, xr as a, Ee as at, bn as b, or as c, _e as ct, Hn as d, ke as dt, Ye as et, ir as f, Oe as ft, _r as g, Q as gt, vr as h, le as ht, Sr as i, we as it, un as j, rn as k, Zn as l, Ce as lt, rr as m, ce as mt, lr as n, Ve as nt, Cr as o, he as ot, Wn as p, De as pt, lt as q, kr as r, ze as rt, sr as s, ve as st, ur as t, et as tt, Bn as u, Te as ut, gn as v, ue as vt, cn as w, hn as x, xn as y, pe as yt, Lt as z };
|