@booboo-brain/panel 0.3.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +9 -2
- package/dist/index.js +1706 -2
- package/dist-app/assets/index-DeLQvnLP.js +561 -0
- package/dist-app/index.html +7 -3
- package/package.json +8 -2
- package/dist-app/assets/index-BZauzHoT.css +0 -1
- package/dist-app/assets/index-DitmpEQM.js +0 -49
package/dist/index.js
CHANGED
|
@@ -1,5 +1,1709 @@
|
|
|
1
|
+
// src/Panel.tsx
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { orgBootSlice } from "@booboo-brain/spec";
|
|
4
|
+
|
|
5
|
+
// src/panel-css.ts
|
|
6
|
+
var PANEL_CSS = String.raw`
|
|
7
|
+
/* Booboo Organigram — alive, simple, for everyone. One accent (verdigris,
|
|
8
|
+
the dachshund's collar), a slow aurora breathing behind everything, cards
|
|
9
|
+
that lift and settle, numbers that count up. Dark by default. */
|
|
10
|
+
|
|
11
|
+
:root {
|
|
12
|
+
--bg: #0b0c10;
|
|
13
|
+
--bg-1: #10131a;
|
|
14
|
+
--bg-2: #171b24;
|
|
15
|
+
--line: #242a36;
|
|
16
|
+
--ink: #e9edf3;
|
|
17
|
+
--ink-2: #9aa7b6;
|
|
18
|
+
--ink-3: #5d6776;
|
|
19
|
+
--accent: #4fb8a0;
|
|
20
|
+
--accent-2: #7fd4c0;
|
|
21
|
+
--accent-dim: rgba(79, 184, 160, 0.13);
|
|
22
|
+
--warn: #e0b45f;
|
|
23
|
+
--font: -apple-system, "Segoe UI", Inter, system-ui, sans-serif;
|
|
24
|
+
--mono: ui-monospace, "SF Mono", Menlo, monospace;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* LIGHT theme — same verdigris accent, swapped surfaces. Toggle in the top bar. */
|
|
28
|
+
:root[data-theme="light"] {
|
|
29
|
+
--bg: #f5f7f9;
|
|
30
|
+
--bg-1: #ffffff;
|
|
31
|
+
--bg-2: #eef1f4;
|
|
32
|
+
--line: #dbe1e8;
|
|
33
|
+
--ink: #182029;
|
|
34
|
+
--ink-2: #55636f;
|
|
35
|
+
--ink-3: #8b97a3;
|
|
36
|
+
--accent: #1e8f79;
|
|
37
|
+
--accent-2: #12796a;
|
|
38
|
+
--accent-dim: rgba(30, 143, 121, 0.12);
|
|
39
|
+
--warn: #b57b1e;
|
|
40
|
+
}
|
|
41
|
+
[data-theme="light"] .bar,
|
|
42
|
+
[data-theme="light"] .tabs { background: rgba(255, 255, 255, 0.82); }
|
|
43
|
+
[data-theme="light"] .btn.primary { color: #ffffff; }
|
|
44
|
+
[data-theme="light"] .pnl-aurora { opacity: 0.32; }
|
|
45
|
+
[data-theme="light"] .doss-rep.tap:hover { background: rgba(0, 0, 0, 0.03); }
|
|
46
|
+
[data-theme="light"] .bk-card:hover,
|
|
47
|
+
[data-theme="light"] .mem-row:hover { box-shadow: 0 8px 22px rgba(20, 40, 60, 0.08); }
|
|
48
|
+
/* surfaces that hardcode a dark tint — retint for the light theme */
|
|
49
|
+
[data-theme="light"] .oc-row.wrap { background: rgba(20, 40, 60, 0.04); }
|
|
50
|
+
[data-theme="light"] .doss { background: rgba(255, 255, 255, 0.9); }
|
|
51
|
+
[data-theme="light"] .ag {
|
|
52
|
+
background: linear-gradient(180deg, hsl(var(--h) 42% 93% / 0.9), var(--bg-1) 60%);
|
|
53
|
+
border-color: hsl(var(--h) 30% 78%);
|
|
54
|
+
}
|
|
55
|
+
[data-theme="light"] .tl-ava { background: hsl(var(--h) 45% 90% / 0.9); border-color: hsl(var(--h) 40% 75% / 0.5); }
|
|
56
|
+
[data-theme="light"] .oc-tray { background: linear-gradient(180deg, #e7ebef, #eef1f4); box-shadow: inset 0 3px 7px rgba(20, 40, 60, 0.08); }
|
|
57
|
+
[data-theme="light"] .oc-mac { background: rgba(20, 40, 60, 0.05); border-color: rgba(20, 40, 60, 0.1); }
|
|
58
|
+
|
|
59
|
+
* { box-sizing: border-box; }
|
|
60
|
+
body { font-family: var(--font); color: var(--ink); background: var(--bg); overflow-x: hidden; }
|
|
61
|
+
|
|
62
|
+
.pnl { display: flex; flex-direction: column; position: relative; overflow: hidden; }
|
|
63
|
+
|
|
64
|
+
/* the breath — a slow aurora drifting behind everything */
|
|
65
|
+
.pnl-aurora {
|
|
66
|
+
position: fixed; inset: -30%; pointer-events: none; z-index: 0; opacity: 0.5;
|
|
67
|
+
background:
|
|
68
|
+
radial-gradient(38% 30% at 24% 30%, rgba(79, 184, 160, 0.10), transparent 70%),
|
|
69
|
+
radial-gradient(30% 26% at 78% 64%, rgba(90, 130, 200, 0.08), transparent 70%),
|
|
70
|
+
radial-gradient(24% 22% at 55% 15%, rgba(79, 184, 160, 0.06), transparent 70%);
|
|
71
|
+
animation: aurora 48s ease-in-out infinite alternate;
|
|
72
|
+
}
|
|
73
|
+
@keyframes aurora {
|
|
74
|
+
0% { transform: translate(0, 0) scale(1); }
|
|
75
|
+
50% { transform: translate(3%, -2%) scale(1.06); }
|
|
76
|
+
100% { transform: translate(-3%, 2%) scale(1.02); }
|
|
77
|
+
}
|
|
78
|
+
@media (prefers-reduced-motion: reduce) {
|
|
79
|
+
/* everything lands at its final state — honest for users, crisp for captures */
|
|
80
|
+
.pnl-aurora, .ag.root::before, .ag.root::after, .ag, .content, .bk-card, .tl-row, .mem-row,
|
|
81
|
+
.rule-card, .doss, .doss-rep, .bar-draft, .ag-light.fail, .mac-dot.fail { animation: none !important; }
|
|
82
|
+
}
|
|
83
|
+
/* the fit is a TRANSITION not an animation — suppress it explicitly so the org
|
|
84
|
+
snaps to its fitted size instantly under reduced-motion (honest for captures) */
|
|
85
|
+
@media (prefers-reduced-motion: reduce) { .chart { transition: none !important; } }
|
|
86
|
+
|
|
87
|
+
/* top bar */
|
|
88
|
+
.bar {
|
|
89
|
+
position: relative; z-index: 2; display: flex; align-items: center; gap: 22px;
|
|
90
|
+
padding: 14px 26px; border-bottom: 1px solid var(--line);
|
|
91
|
+
background: rgba(16, 19, 26, 0.82); backdrop-filter: blur(10px);
|
|
92
|
+
flex-wrap: wrap;
|
|
93
|
+
}
|
|
94
|
+
.bar-brand { font-size: 15px; }
|
|
95
|
+
.bar-brand b { font-weight: 650; }
|
|
96
|
+
.bar-stats { display: flex; gap: 18px; color: var(--ink-2); font-size: 12.5px; }
|
|
97
|
+
.bar-stats b { color: var(--ink); font-variant-numeric: tabular-nums; font-size: 14px; }
|
|
98
|
+
.bar-stats .tap { cursor: pointer; transition: color 0.15s; }
|
|
99
|
+
.bar-stats .tap:hover { color: var(--accent); }
|
|
100
|
+
.bar-stats .tap:hover b { color: var(--accent); }
|
|
101
|
+
.bar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
|
|
102
|
+
.bar-ok { color: var(--accent); font-size: 12px; }
|
|
103
|
+
.bar-draft { color: var(--warn); font-size: 12px; animation: pulse 1.6s ease-in-out infinite; }
|
|
104
|
+
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
|
|
105
|
+
|
|
106
|
+
.btn {
|
|
107
|
+
border: 1px solid var(--line); background: var(--bg-2); color: var(--ink);
|
|
108
|
+
border-radius: 9px; padding: 8px 15px; font-size: 12.5px; cursor: pointer;
|
|
109
|
+
transition: border-color 0.15s, transform 0.1s;
|
|
110
|
+
}
|
|
111
|
+
.btn:hover { border-color: var(--accent); }
|
|
112
|
+
.btn:active { transform: scale(0.97); }
|
|
113
|
+
.btn.primary { background: var(--accent); border-color: var(--accent); color: #08110e; font-weight: 650; }
|
|
114
|
+
.btn.primary:disabled { opacity: 0.5; cursor: wait; }
|
|
115
|
+
.btn.ghost { background: transparent; color: var(--ink-2); }
|
|
116
|
+
|
|
117
|
+
/* tabs */
|
|
118
|
+
.tabs {
|
|
119
|
+
position: relative; z-index: 2; display: flex; gap: 4px; padding: 0 22px;
|
|
120
|
+
border-bottom: 1px solid var(--line); background: rgba(16, 19, 26, 0.7); backdrop-filter: blur(8px);
|
|
121
|
+
overflow-x: auto;
|
|
122
|
+
}
|
|
123
|
+
.tab {
|
|
124
|
+
background: none; border: none; border-bottom: 2px solid transparent; color: var(--ink-2);
|
|
125
|
+
font-size: 12.5px; padding: 12px 15px 11px; cursor: pointer; white-space: nowrap;
|
|
126
|
+
transition: color 0.15s, border-color 0.2s;
|
|
127
|
+
}
|
|
128
|
+
.tab:hover { color: var(--ink); }
|
|
129
|
+
.tab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
|
|
130
|
+
.tab-glyph { margin-right: 5px; opacity: 0.85; }
|
|
131
|
+
|
|
132
|
+
/* every tab's content rises in — the key on .content retriggers it */
|
|
133
|
+
.content { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; min-height: 0; animation: rise 0.28s ease both; }
|
|
134
|
+
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
|
|
135
|
+
|
|
136
|
+
.screen { flex: 1; overflow-y: auto; padding: 30px 34px 60px; max-width: 900px; }
|
|
137
|
+
.scr-title { display: flex; align-items: center; gap: 10px; font-size: 20px; margin: 0 0 6px; }
|
|
138
|
+
.scr-count { font-size: 12px; background: var(--accent-dim); color: var(--accent); border-radius: 99px; padding: 3px 10px; font-variant-numeric: tabular-nums; }
|
|
139
|
+
.scr-sub { color: var(--ink-2); font-size: 12.5px; margin: 0 0 24px; }
|
|
140
|
+
.scr-empty { color: var(--ink-3); font-size: 13px; line-height: 1.6; }
|
|
141
|
+
.scr-empty code, .scr-sub code { font-family: var(--mono); background: var(--bg-2); padding: 1px 6px; border-radius: 5px; font-size: 11.5px; }
|
|
142
|
+
.pnl-back { background: none; border: 1px solid var(--line); color: var(--ink-2); border-radius: 8px; padding: 6px 12px; font-size: 12px; cursor: pointer; margin-bottom: 16px; }
|
|
143
|
+
.pnl-back:hover { border-color: var(--accent); color: var(--accent); }
|
|
144
|
+
|
|
145
|
+
/* buckets */
|
|
146
|
+
.bk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 13px; }
|
|
147
|
+
.bk-card {
|
|
148
|
+
text-align: left; background: var(--bg-1); border: 1px solid var(--line); border-radius: 15px;
|
|
149
|
+
padding: 17px 18px; cursor: pointer; transition: border-color 0.15s, transform 0.12s, box-shadow 0.2s;
|
|
150
|
+
animation: settle 0.4s ease both;
|
|
151
|
+
}
|
|
152
|
+
.bk-card:hover { border-color: hsl(var(--h) 45% 55% / 0.6); transform: translateY(-2px); box-shadow: 0 8px 26px hsl(var(--h) 50% 50% / 0.10); }
|
|
153
|
+
.bk-top { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
|
|
154
|
+
.bk-dot { width: 9px; height: 9px; border-radius: 50%; background: hsl(var(--h) 55% 60%); box-shadow: 0 0 9px hsl(var(--h) 55% 60% / 0.7); display: inline-block; }
|
|
155
|
+
.bk-name { font-size: 14px; font-weight: 650; }
|
|
156
|
+
.bk-n { font-size: 27px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1; }
|
|
157
|
+
.bk-n.dim { color: var(--ink-3); }
|
|
158
|
+
.bk-l { font-size: 9.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }
|
|
159
|
+
.bk-crew { display: flex; gap: 4px; margin-top: 13px; flex-wrap: wrap; }
|
|
160
|
+
.bk-face {
|
|
161
|
+
width: 24px; height: 24px; display: grid; place-items: center; font-size: 12px;
|
|
162
|
+
border-radius: 7px; background: var(--bg-2); border: 1px solid var(--line);
|
|
163
|
+
}
|
|
164
|
+
.bk-more { font-size: 10px; color: var(--ink-3); align-self: center; }
|
|
165
|
+
.bk-agents { margin-top: 8px; font-size: 10.5px; color: var(--ink-3); line-height: 1.5; }
|
|
166
|
+
|
|
167
|
+
.mem-list { display: flex; flex-direction: column; gap: 6px; }
|
|
168
|
+
.mem-row {
|
|
169
|
+
display: flex; align-items: baseline; gap: 13px; background: var(--bg-1);
|
|
170
|
+
border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; animation: settle 0.35s ease both;
|
|
171
|
+
}
|
|
172
|
+
.mem-when { font-size: 10.5px; color: var(--accent-2); white-space: nowrap; min-width: 68px; font-variant-numeric: tabular-nums; }
|
|
173
|
+
.mem-label { font-size: 13px; }
|
|
174
|
+
|
|
175
|
+
/* reports timeline */
|
|
176
|
+
.rep-filter { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 20px; }
|
|
177
|
+
.chip.tap { cursor: pointer; transition: transform 0.1s, background 0.15s; }
|
|
178
|
+
.chip.tap:hover { transform: translateY(-1px); }
|
|
179
|
+
.timeline { position: relative; padding-left: 22px; }
|
|
180
|
+
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
|
|
181
|
+
.tl-row { position: relative; margin-bottom: 15px; animation: settle 0.35s ease both; }
|
|
182
|
+
.tl-dot {
|
|
183
|
+
position: absolute; left: -21px; top: 12px; width: 9px; height: 9px; border-radius: 50%;
|
|
184
|
+
background: hsl(var(--h) 55% 60%); box-shadow: 0 0 9px hsl(var(--h) 55% 60% / 0.7);
|
|
185
|
+
}
|
|
186
|
+
.tl-body { background: var(--bg-1); border: 1px solid var(--line); border-radius: 12px; padding: 11px 15px; transition: border-color 0.15s, transform 0.12s; }
|
|
187
|
+
.tl-row:hover .tl-body { border-color: hsl(var(--h) 45% 50% / 0.5); transform: translateX(2px); }
|
|
188
|
+
.tl-top { display: flex; align-items: center; gap: 8px; }
|
|
189
|
+
.tl-ava {
|
|
190
|
+
width: 24px; height: 24px; flex: 0 0 24px; display: grid; place-items: center; font-size: 12px;
|
|
191
|
+
border-radius: 7px; background: hsl(var(--h) 42% 22% / 0.8); border: 1px solid hsl(var(--h) 45% 45% / 0.3);
|
|
192
|
+
}
|
|
193
|
+
.tl-agent { font-size: 12.5px; font-weight: 650; }
|
|
194
|
+
.tl-when { font-size: 10.5px; color: var(--ink-3); margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
|
|
195
|
+
.tl-label { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
196
|
+
.tl-sum { margin: 7px 0 0 32px; font-size: 12.5px; line-height: 1.6; color: var(--ink-2); }
|
|
197
|
+
|
|
198
|
+
/* rules */
|
|
199
|
+
.rule-list { display: flex; flex-direction: column; gap: 9px; }
|
|
200
|
+
.rule-card { background: var(--bg-1); border: 1px solid var(--line); border-left: 2px solid var(--accent); border-radius: 11px; padding: 12px 15px 10px; animation: settle 0.35s ease both; transition: border-color 0.15s; }
|
|
201
|
+
.rule-card:hover { border-color: var(--accent); }
|
|
202
|
+
.rule-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 5px; }
|
|
203
|
+
.rule-ref { font-family: var(--mono); font-size: 12.5px; }
|
|
204
|
+
.rule-scope { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--accent); background: var(--accent-dim); border-radius: 5px; padding: 2px 7px; }
|
|
205
|
+
.rule-meta { font-size: 11.5px; color: var(--ink-3); line-height: 1.6; }
|
|
206
|
+
.rule-meta b { color: var(--ink-2); font-weight: 600; }
|
|
207
|
+
.rule-bar { margin-top: 9px; height: 3px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
|
|
208
|
+
.rule-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.6s ease; }
|
|
209
|
+
|
|
210
|
+
/* graph */
|
|
211
|
+
.graph-wrap { flex: 1; min-height: 0; display: flex; }
|
|
212
|
+
.graph-frame { flex: 1; border: none; background: #06080e; }
|
|
213
|
+
|
|
214
|
+
/* dossier extras */
|
|
215
|
+
.doss-head-actions { margin-left: auto; display: flex; gap: 6px; }
|
|
216
|
+
.doss-3d { background: var(--accent-dim); border: 1px solid rgba(79, 184, 160, 0.35); color: var(--accent); border-radius: 8px; padding: 6px 10px; font-size: 11px; cursor: pointer; white-space: nowrap; }
|
|
217
|
+
.doss-3d:hover { border-color: var(--accent); }
|
|
218
|
+
|
|
219
|
+
/* dossier edit mode — every field of the agent, saved into the draft */
|
|
220
|
+
.doss-edit { display: flex; flex-direction: column; gap: 10px; background: var(--bg-1); border: 1px solid rgba(79, 184, 160, 0.3); border-radius: 12px; padding: 13px 14px; margin-bottom: 20px; animation: settle 0.25s ease both; }
|
|
221
|
+
.doss-edit label { display: flex; flex-direction: column; gap: 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); }
|
|
222
|
+
.doss-edit label em { font-style: normal; text-transform: none; letter-spacing: 0; color: var(--ink-3); font-size: 9.5px; }
|
|
223
|
+
.doss-edit input, .doss-edit textarea { background: var(--bg-2); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; font-family: var(--font); resize: vertical; }
|
|
224
|
+
.doss-edit input:focus, .doss-edit textarea:focus { outline: none; border-color: var(--accent); }
|
|
225
|
+
.doss-edit-row2 { display: grid; grid-template-columns: 1fr 72px; gap: 8px; }
|
|
226
|
+
.doss-edit-actions { display: flex; gap: 8px; margin-top: 2px; }
|
|
227
|
+
|
|
228
|
+
/* machine trays — the automations an agent operates, chips with health lights */
|
|
229
|
+
/* the machine rack — a recessed slot flush under the owner's card */
|
|
230
|
+
.oc-tray {
|
|
231
|
+
display: flex; flex-wrap: wrap; gap: 4px; justify-content: center;
|
|
232
|
+
max-width: 210px; margin-top: -6px; padding: 10px 8px 7px;
|
|
233
|
+
background: linear-gradient(180deg, #0a0c11, #0d1017);
|
|
234
|
+
border: 1px solid var(--line); border-top: 0; border-radius: 0 0 14px 14px;
|
|
235
|
+
box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.55);
|
|
236
|
+
}
|
|
237
|
+
.oc-tray.fail { border-color: rgba(224, 123, 106, 0.55); box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.55), 0 6px 18px -8px rgba(224, 123, 106, 0.3); }
|
|
238
|
+
.oc-tray.warn { border-color: rgba(224, 180, 95, 0.45); }
|
|
239
|
+
.oc-mac {
|
|
240
|
+
display: inline-flex; align-items: center; gap: 5px;
|
|
241
|
+
background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.05);
|
|
242
|
+
border-radius: 6px; padding: 4px 8px; cursor: pointer;
|
|
243
|
+
font-family: var(--mono); font-size: 10px; color: var(--ink-2);
|
|
244
|
+
transition: border-color 0.15s, transform 0.1s;
|
|
245
|
+
}
|
|
246
|
+
.oc-mac:hover { border-color: var(--accent); color: var(--ink); transform: translateY(-1px); }
|
|
247
|
+
.oc-mac.sel { border-color: var(--accent); background: var(--accent-dim); color: var(--ink); }
|
|
248
|
+
.oc-mac.more { color: var(--ink-3); font-style: italic; }
|
|
249
|
+
.oc-mac.more:hover { color: var(--accent); }
|
|
250
|
+
.mac-emoji { font-size: 11px; }
|
|
251
|
+
.mac-name { white-space: nowrap; max-width: 76px; overflow: hidden; text-overflow: ellipsis; }
|
|
252
|
+
.mac-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; display: inline-block; }
|
|
253
|
+
.mac-dot.ok { background: var(--accent); box-shadow: 0 0 6px rgba(79, 184, 160, 0.7); }
|
|
254
|
+
.mac-dot.warn { background: var(--warn); box-shadow: 0 0 6px rgba(224, 180, 95, 0.7); }
|
|
255
|
+
.mac-dot.fail { background: #e07b6a; box-shadow: 0 0 7px rgba(224, 123, 106, 0.8); animation: pulse 1.4s ease-in-out infinite; }
|
|
256
|
+
.mac-dot.none { background: var(--ink-3); }
|
|
257
|
+
/* green, but it failed earlier in the window — a faint amber ring, never a tint */
|
|
258
|
+
.mac-dot.ok.unstable { box-shadow: 0 0 6px rgba(79, 184, 160, 0.7), 0 0 0 2px rgba(224, 180, 95, 0.3); }
|
|
259
|
+
|
|
260
|
+
/* automation dossier health header */
|
|
261
|
+
.doss-health {
|
|
262
|
+
display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
|
|
263
|
+
background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px;
|
|
264
|
+
padding: 10px 13px; margin-bottom: 16px; font-size: 11.5px; color: var(--ink-2);
|
|
265
|
+
}
|
|
266
|
+
.doss-health b { color: var(--ink); font-size: 12px; }
|
|
267
|
+
.doss-health.fail { border-color: rgba(224, 123, 106, 0.5); }
|
|
268
|
+
.doss-health.warn { border-color: rgba(224, 180, 95, 0.4); }
|
|
269
|
+
.doss-health.ok { border-color: rgba(79, 184, 160, 0.35); }
|
|
270
|
+
.doss-auto-when { margin-left: auto; font-size: 10px; color: var(--ink-3); white-space: nowrap; }
|
|
271
|
+
|
|
272
|
+
/* automations — machines an agent operates, listed in its dossier */
|
|
273
|
+
.auto-badge { font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--warn); background: rgba(224, 180, 95, 0.1); border: 1px solid rgba(224, 180, 95, 0.3); border-radius: 5px; padding: 2px 7px; vertical-align: middle; margin-left: 6px; }
|
|
274
|
+
.doss-autos { display: flex; flex-direction: column; gap: 5px; }
|
|
275
|
+
.doss-auto { display: flex; align-items: baseline; gap: 9px; text-align: left; background: var(--bg-1); border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; cursor: pointer; transition: border-color 0.15s; }
|
|
276
|
+
.doss-auto:hover { border-color: var(--warn); }
|
|
277
|
+
.doss-auto-emoji { font-size: 13px; }
|
|
278
|
+
.doss-auto-name { font-size: 12px; font-weight: 600; white-space: nowrap; }
|
|
279
|
+
.doss-auto-role { font-size: 10.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
280
|
+
|
|
281
|
+
.doss-foot { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
|
|
282
|
+
.btn.danger { border-color: rgba(224, 123, 106, 0.45); color: #e07b6a; background: transparent; }
|
|
283
|
+
.btn.danger:hover { background: rgba(224, 123, 106, 0.1); }
|
|
284
|
+
.bk-agents.unassigned { color: var(--ink-3); font-style: italic; }
|
|
285
|
+
|
|
286
|
+
.pending {
|
|
287
|
+
position: relative; z-index: 2; display: flex; gap: 8px; flex-wrap: wrap;
|
|
288
|
+
padding: 10px 26px; border-bottom: 1px solid var(--line); background: rgba(224, 180, 95, 0.06);
|
|
289
|
+
}
|
|
290
|
+
.pending-item { font-size: 11.5px; color: var(--warn); font-family: var(--mono); }
|
|
291
|
+
.pnl-err { position: relative; z-index: 2; padding: 10px 26px; color: #e07b6a; font-size: 12.5px; }
|
|
292
|
+
|
|
293
|
+
/* layout — 100% so a HOST container decides the height (embedded panel);
|
|
294
|
+
the standalone app gives html/body/#root 100%, so served behaviour is unchanged. */
|
|
295
|
+
.pnl { height: 100%; min-height: 480px; }
|
|
296
|
+
.body { position: relative; z-index: 1; flex: 1; display: flex; min-height: 0; }
|
|
297
|
+
.tree { position: relative; flex: 1; min-width: 0; padding: 24px 26px 24px; overflow: hidden;
|
|
298
|
+
display: flex; flex-direction: column;
|
|
299
|
+
/* the ground plane: a faint dot grid (engineered surface, drag affordance)
|
|
300
|
+
+ a verdigris pool anchoring the eye at the root. Static — capture-safe. */
|
|
301
|
+
background:
|
|
302
|
+
radial-gradient(900px 420px at 50% 120px, rgba(79, 184, 160, 0.05), transparent 70%),
|
|
303
|
+
radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.035) 1px, transparent 1.5px);
|
|
304
|
+
background-size: auto, 28px 28px;
|
|
305
|
+
}
|
|
306
|
+
.tree-hint { color: var(--ink-3); font-size: 11.5px; margin: 0 0 20px; text-align: center; }
|
|
307
|
+
|
|
308
|
+
/* THE COMPANY CHART — root on top, branches fanning beneath. Connectors are
|
|
309
|
+
crafted: curved elbows at the row's ends, branch-hued drops, a glowing
|
|
310
|
+
junction node where the parent's line meets the bar. Pure CSS. */
|
|
311
|
+
/* the measuring viewport — flex:1 + min-height:0 lets it consume the height
|
|
312
|
+
.tree gives it; align/justify center the scaled block for narrow orgs. */
|
|
313
|
+
.chart-fit { position: relative; flex: 1; min-height: 0; display: flex; align-items: flex-start; justify-content: center; overflow: hidden; }
|
|
314
|
+
/* user-zoomed: native scroll is the pan; top-left origin keeps the scaled
|
|
315
|
+
overflow fully reachable (top/center origin would clip the left half). */
|
|
316
|
+
.chart-fit.zoomed { overflow: auto; justify-content: flex-start; }
|
|
317
|
+
.chart-fit.zoomed .chart { transform-origin: top left; }
|
|
318
|
+
.zoomer {
|
|
319
|
+
position: absolute; right: 34px; bottom: 32px; z-index: 3; display: flex; align-items: center; gap: 2px;
|
|
320
|
+
font-family: var(--mono); font-size: 11px; color: var(--ink-2);
|
|
321
|
+
background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px;
|
|
322
|
+
box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
|
|
323
|
+
}
|
|
324
|
+
.zoomer button {
|
|
325
|
+
all: unset; cursor: pointer; padding: 2px 8px; border-radius: 5px; color: var(--ink-2);
|
|
326
|
+
font-family: var(--mono); font-size: 12px; line-height: 1.4;
|
|
327
|
+
}
|
|
328
|
+
.zoomer button:hover { background: var(--accent-dim); color: var(--ink); }
|
|
329
|
+
.zoomer button.on { color: var(--accent); }
|
|
330
|
+
.zoomer-pct { min-width: 40px; text-align: center; color: var(--ink-3); }
|
|
331
|
+
/* min-width:max-content keeps connectors geometrically correct at natural size
|
|
332
|
+
BEFORE scaling; the measured --fit shrinks the whole block toward its head. */
|
|
333
|
+
.chart {
|
|
334
|
+
min-width: max-content; padding: 8px 14px 20px;
|
|
335
|
+
transform: scale(var(--fit, 1)); transform-origin: top center;
|
|
336
|
+
transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1); will-change: transform;
|
|
337
|
+
}
|
|
338
|
+
.ocn { display: flex; flex-direction: column; align-items: center; }
|
|
339
|
+
.oc-down { width: 1.5px; height: 18px; position: relative;
|
|
340
|
+
background: linear-gradient(180deg, hsl(165 40% 45% / 0.5), var(--line)); }
|
|
341
|
+
.oc-down::after { content: ""; position: absolute; bottom: -2px; left: 50%;
|
|
342
|
+
width: 5px; height: 5px; transform: translateX(-50%); border-radius: 50%;
|
|
343
|
+
background: var(--accent); box-shadow: 0 0 8px rgba(79, 184, 160, 0.5); }
|
|
344
|
+
.oc-row { display: flex; align-items: flex-start; }
|
|
345
|
+
.oc-child { position: relative; padding: 18px 5px 0; display: flex; flex-direction: column; align-items: center; }
|
|
346
|
+
.oc-child::before { content: ""; position: absolute; top: 0; left: 50%; width: 1.5px; height: 18px;
|
|
347
|
+
background: linear-gradient(180deg, var(--line), hsl(var(--h, 165) 32% 34%)); }
|
|
348
|
+
.oc-child::after { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 16px;
|
|
349
|
+
border-top: 1.5px solid var(--line); }
|
|
350
|
+
.oc-child:first-child::after { left: 50%; border-left: 1.5px solid var(--line); border-top-left-radius: 14px; }
|
|
351
|
+
.oc-child:last-child::after { right: 50%; border-right: 1.5px solid var(--line); border-top-right-radius: 14px; }
|
|
352
|
+
.oc-child:first-child::before, .oc-child:last-child::before { display: none; }
|
|
353
|
+
.oc-child:only-child::after { display: none; }
|
|
354
|
+
.oc-child:only-child::before { display: block; }
|
|
355
|
+
|
|
356
|
+
/* the branch wakes when you hover its parent */
|
|
357
|
+
.ocn:has(> .ag:hover) > .oc-down,
|
|
358
|
+
.ocn:has(> .ag:hover) > .oc-row > .oc-child::before { background: hsl(165 45% 45% / 0.6); }
|
|
359
|
+
.ocn:has(> .ag:hover) > .oc-row > .oc-child::after { border-color: hsl(165 45% 45% / 0.6); }
|
|
360
|
+
|
|
361
|
+
/* wide sibling sets — grouped subtrees that wrap to natural width (never crush a
|
|
362
|
+
branch into a fixed cell — that overflowed and collided with the next branch) */
|
|
363
|
+
.oc-row.wrap {
|
|
364
|
+
display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start;
|
|
365
|
+
gap: 10px 18px; margin: 0 auto; padding: 12px 14px 14px;
|
|
366
|
+
max-width: min(100%, 840px);
|
|
367
|
+
border: 1px solid var(--line); border-radius: 18px; background: rgba(16, 19, 26, 0.35);
|
|
368
|
+
}
|
|
369
|
+
.oc-row.wrap > .oc-child { padding: 8px 4px 0; flex: 0 0 auto; }
|
|
370
|
+
.oc-row.wrap > .oc-child::before, .oc-row.wrap > .oc-child::after { display: none; }
|
|
371
|
+
|
|
372
|
+
/* agent cards — company badges with a rank system (size + saturation recede
|
|
373
|
+
with depth) and a light-from-above material model. */
|
|
374
|
+
.ag {
|
|
375
|
+
position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
|
|
376
|
+
width: calc(160px - min(var(--d, 0), 2) * 12px); /* 160 / 148 / 136 by rank */
|
|
377
|
+
padding: 13px 11px 10px; text-align: center;
|
|
378
|
+
background: linear-gradient(180deg, hsl(var(--h) 30% 14% / 0.55), var(--bg-1) 55%);
|
|
379
|
+
border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 15px; cursor: grab; overflow: hidden;
|
|
380
|
+
filter: saturate(calc(1 - min(var(--d, 0), 2) * 0.15));
|
|
381
|
+
box-shadow:
|
|
382
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.05),
|
|
383
|
+
inset 0 0 0 1px hsl(var(--h) 40% 40% / 0.07),
|
|
384
|
+
0 1px 2px rgba(0, 0, 0, 0.5),
|
|
385
|
+
0 16px 32px -18px hsl(var(--h) 55% 40% / 0.28);
|
|
386
|
+
transition: border-color 0.15s, transform 0.15s, box-shadow 0.2s, opacity 0.15s, filter 0.2s;
|
|
387
|
+
animation: settle 0.4s ease both;
|
|
388
|
+
}
|
|
389
|
+
.ag::before { content: ""; position: absolute; top: 0; left: 0; right: 0;
|
|
390
|
+
height: calc(4px - min(var(--d, 0), 2) * 1px); /* lanyard thins with rank */
|
|
391
|
+
background: linear-gradient(90deg, hsl(var(--h) 55% 55% / 0.9), hsl(var(--h) 55% 45% / 0.25)); }
|
|
392
|
+
@keyframes settle { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
|
|
393
|
+
.ag:hover { border-color: hsl(var(--h) 45% 50% / 0.6); transform: translateY(-2px); filter: saturate(1);
|
|
394
|
+
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 4px rgba(0, 0, 0, 0.5), 0 24px 44px -18px hsl(var(--h) 55% 45% / 0.4); }
|
|
395
|
+
.ag.sel { border-color: hsl(var(--h) 55% 55%); filter: saturate(1);
|
|
396
|
+
box-shadow: 0 0 0 2px hsl(var(--h) 55% 55% / 0.18), 0 10px 28px hsl(var(--h) 50% 45% / 0.2); }
|
|
397
|
+
.ag:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
398
|
+
.ag.over { border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-dim), 0 12px 30px rgba(79, 184, 160, 0.2); transform: scale(1.03); }
|
|
399
|
+
.ag.dragging { opacity: 0.45; cursor: grabbing; }
|
|
400
|
+
|
|
401
|
+
.ag-light { position: absolute; top: 10px; right: 10px; width: 7px; height: 7px; border-radius: 50%; }
|
|
402
|
+
.ag-light.ok { background: var(--accent); box-shadow: 0 0 6px rgba(79, 184, 160, 0.7); }
|
|
403
|
+
.ag-light.warn { background: var(--warn); box-shadow: 0 0 6px rgba(224, 180, 95, 0.7); }
|
|
404
|
+
.ag-light.fail { background: #e07b6a; box-shadow: 0 0 8px rgba(224, 123, 106, 0.9); animation: pulse 1.4s ease-in-out infinite; }
|
|
405
|
+
|
|
406
|
+
.ag.root { cursor: default; width: 200px; padding: 16px 13px 11px;
|
|
407
|
+
border-color: rgba(79, 184, 160, 0.35); filter: none;
|
|
408
|
+
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 0 0 1px rgba(79, 184, 160, 0.25), 0 24px 60px -20px rgba(79, 184, 160, 0.35); }
|
|
409
|
+
.ag.root .ag-ava { width: 46px; height: 46px; font-size: 23px; }
|
|
410
|
+
.ag.root .ag-name { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
|
|
411
|
+
.ag.root::after {
|
|
412
|
+
content: ""; position: absolute; inset: 0; border-radius: 15px; pointer-events: none;
|
|
413
|
+
box-shadow: inset 0 0 26px rgba(79, 184, 160, 0.08); animation: ring 3.2s ease-in-out infinite;
|
|
414
|
+
}
|
|
415
|
+
@keyframes ring { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
|
|
416
|
+
|
|
417
|
+
.ag-ava {
|
|
418
|
+
width: 38px; height: 38px; display: grid; place-items: center; font-size: 19px; margin-top: 2px;
|
|
419
|
+
border-radius: 13px; background: linear-gradient(140deg, hsl(var(--h) 42% 26% / 0.85), hsl(var(--h) 45% 14% / 0.9));
|
|
420
|
+
border: 1px solid hsl(var(--h) 45% 45% / 0.35);
|
|
421
|
+
box-shadow: inset 0 1px 0 hsl(var(--h) 50% 60% / 0.25), 0 4px 10px -4px hsl(var(--h) 50% 30% / 0.6);
|
|
422
|
+
}
|
|
423
|
+
.ag-name { font-size: 13px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
|
|
424
|
+
.ag-role { font-size: 11px; color: var(--ink-2); line-height: 1.35;
|
|
425
|
+
display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
|
426
|
+
.ag-meta { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 2px; }
|
|
427
|
+
.ag-meta em { font-style: normal; font-size: 10.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
428
|
+
.ag-kids {
|
|
429
|
+
font-size: 10px; background: var(--accent-dim); color: var(--accent); border-radius: 99px;
|
|
430
|
+
padding: 2px 8px; font-variant-numeric: tabular-nums; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/* the dossier */
|
|
434
|
+
.doss {
|
|
435
|
+
width: 340px; flex: 0 0 340px; border-left: 1px solid var(--line);
|
|
436
|
+
background: rgba(16, 19, 26, 0.75); backdrop-filter: blur(10px);
|
|
437
|
+
padding: 26px 24px 40px; overflow-y: auto; animation: slidein 0.25s ease both;
|
|
438
|
+
}
|
|
439
|
+
@keyframes slidein { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
|
|
440
|
+
.doss-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
|
|
441
|
+
.doss-emoji { font-size: 30px; }
|
|
442
|
+
.doss h2 { margin: 0; font-size: 18px; }
|
|
443
|
+
.doss-role { margin: 3px 0 0; color: var(--ink-2); font-size: 12.5px; }
|
|
444
|
+
|
|
445
|
+
.doss-chain { font-size: 11px; color: var(--ink-3); margin-bottom: 18px; line-height: 1.7; }
|
|
446
|
+
.doss-chain i { font-style: normal; margin: 0 5px; }
|
|
447
|
+
.doss-chain b { font-weight: 500; }
|
|
448
|
+
.doss-chain b.me { color: var(--accent); font-weight: 650; }
|
|
449
|
+
|
|
450
|
+
.doss-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 22px; }
|
|
451
|
+
.doss-stat { background: var(--bg-1); border: 1px solid var(--line); border-radius: 11px; padding: 11px 8px; text-align: center; }
|
|
452
|
+
.doss-n { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
|
|
453
|
+
.doss-l { font-size: 9.5px; color: var(--ink-3); margin-top: 3px; text-transform: uppercase; letter-spacing: 0.05em; }
|
|
454
|
+
|
|
455
|
+
.doss section { margin-bottom: 20px; }
|
|
456
|
+
.doss h3 { font-size: 10px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--ink-3); margin: 0 0 9px; }
|
|
457
|
+
.doss-empty { color: var(--ink-3); font-size: 12px; margin: 0; }
|
|
458
|
+
.doss-rules { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
|
|
459
|
+
.doss-rules li { font-family: var(--mono); font-size: 11px; color: var(--ink-2); background: var(--bg-1); border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; word-break: break-all; }
|
|
460
|
+
.doss-rules li.own { color: var(--ink); border-color: rgba(79, 184, 160, 0.35); }
|
|
461
|
+
.doss-rules em { color: var(--ink-3); font-style: normal; font-size: 9.5px; margin-left: 5px; }
|
|
462
|
+
.doss-chips { display: flex; gap: 6px; flex-wrap: wrap; }
|
|
463
|
+
.doss-reps { display: flex; flex-direction: column; gap: 7px; }
|
|
464
|
+
.doss-rep {
|
|
465
|
+
background: var(--bg-1); border: 1px solid var(--line); border-left: 2px solid var(--accent);
|
|
466
|
+
border-radius: 9px; padding: 9px 11px; animation: settle 0.35s ease both;
|
|
467
|
+
}
|
|
468
|
+
.doss-rep-top { display: flex; align-items: baseline; gap: 9px; }
|
|
469
|
+
.doss-rep-when { font-size: 10px; color: var(--accent-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
470
|
+
.doss-rep-label { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
471
|
+
.doss-rep-sum { margin: 5px 0 0; font-size: 11.5px; color: var(--ink-2); line-height: 1.55; }
|
|
472
|
+
.doss-rep.tap { cursor: pointer; transition: border-color .12s ease, background .12s ease; }
|
|
473
|
+
.doss-rep.tap:hover { border-left-color: var(--warn); background: rgba(255, 255, 255, 0.03); }
|
|
474
|
+
.doss-rep.tap:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
|
|
475
|
+
.doss-rep-caret { margin-left: auto; font-size: 10px; color: var(--ink-2); align-self: center; }
|
|
476
|
+
.rep-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; align-self: center; }
|
|
477
|
+
.rep-dot.ok { background: var(--accent); } .rep-dot.warn { background: var(--warn); } .rep-dot.fail { background: #e07b6a; }
|
|
478
|
+
.rep-ok { color: var(--accent); } .rep-warn { color: var(--warn); } .rep-fail { color: #e07b6a; }
|
|
479
|
+
.doss-rep-detail { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 11px; line-height: 1.7; color: var(--ink-2); font-family: var(--mono); word-break: break-word; }
|
|
480
|
+
.doss-rep-detail .doss-l { display: inline-block; min-width: 74px; opacity: .6; text-transform: uppercase; letter-spacing: .04em; font-size: 9.5px; }
|
|
481
|
+
.chip { font-size: 11px; background: var(--accent-dim); color: var(--accent-2); border-radius: 7px; padding: 4px 10px; }
|
|
482
|
+
.chip.alt { background: var(--bg-2); color: var(--ink-2); }
|
|
483
|
+
.doss-boot { font-size: 12px; color: var(--ink-2); line-height: 1.6; margin: 0; white-space: pre-wrap; }
|
|
484
|
+
/* contract — one click to open, edit in place, save flows to the org file */
|
|
485
|
+
.doss-contract h3 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
|
|
486
|
+
.contract-card {
|
|
487
|
+
position: relative; display: block; width: 100%; text-align: left; cursor: pointer;
|
|
488
|
+
background: var(--bg-1); border: 1px solid var(--line); border-radius: 12px;
|
|
489
|
+
padding: 13px 14px; transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
|
|
490
|
+
}
|
|
491
|
+
.contract-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
|
|
492
|
+
.contract-card:hover .contract-hint { opacity: 1; }
|
|
493
|
+
.contract-card.empty { border-style: dashed; }
|
|
494
|
+
.contract-hint {
|
|
495
|
+
position: absolute; top: 9px; right: 11px; font-size: 10.5px; font-weight: 650;
|
|
496
|
+
color: var(--accent-2); opacity: 0.55; transition: opacity 0.15s; letter-spacing: 0.02em;
|
|
497
|
+
}
|
|
498
|
+
.contract-edit { display: flex; flex-direction: column; gap: 8px; }
|
|
499
|
+
.contract-ta {
|
|
500
|
+
width: 100%; min-height: 220px; resize: vertical; box-sizing: border-box;
|
|
501
|
+
background: var(--bg-1); border: 1px solid var(--accent); border-radius: 12px;
|
|
502
|
+
padding: 12px 13px; color: var(--ink); font-family: var(--mono); font-size: 12px; line-height: 1.6;
|
|
503
|
+
outline: none; box-shadow: 0 0 0 3px var(--accent-dim);
|
|
504
|
+
}
|
|
505
|
+
.doss-edit-hint { font-size: 11px; color: var(--ink-3); margin: 2px 0 0; font-style: italic; }
|
|
506
|
+
.doss-note { color: var(--ink-3); font-size: 11px; line-height: 1.6; }
|
|
507
|
+
.doss-note code { font-family: var(--mono); background: var(--bg-2); padding: 1px 5px; border-radius: 4px; }
|
|
508
|
+
|
|
509
|
+
.pnl-fatal { min-height: 100vh; display: grid; place-items: center; color: #e07b6a; font-size: 14px; padding: 30px; text-align: center; }
|
|
510
|
+
.pnl-fatal.calm { color: var(--ink-2); }
|
|
511
|
+
|
|
512
|
+
@media (max-width: 760px) {
|
|
513
|
+
.doss { position: fixed; right: 0; top: 0; bottom: 0; z-index: 5; width: min(340px, 88vw); box-shadow: -18px 0 50px rgba(0, 0, 0, 0.5); }
|
|
514
|
+
.tree { padding: 20px 14px 60px; }
|
|
515
|
+
.ag { max-width: 100%; }
|
|
516
|
+
.ag-role { display: none; }
|
|
517
|
+
}
|
|
518
|
+
`;
|
|
519
|
+
|
|
520
|
+
// src/Panel.tsx
|
|
521
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
522
|
+
var defaultApi = (path, init) => fetch(`/api${path}`, init).then((r) => r.ok ? r.json() : r.json().then((b) => Promise.reject(b)));
|
|
523
|
+
var ApiCtx = createContext(defaultApi);
|
|
524
|
+
var useApi = () => useContext(ApiCtx);
|
|
525
|
+
var TABS = [
|
|
526
|
+
{ id: "org", glyph: "\u2302", label: "organigram" },
|
|
527
|
+
{ id: "buckets", glyph: "\u25A4", label: "buckets" },
|
|
528
|
+
{ id: "reports", glyph: "\u23F1", label: "reports" },
|
|
529
|
+
{ id: "rules", glyph: "\xA7", label: "rules" },
|
|
530
|
+
{ id: "graph", glyph: "\u25C9", label: "graph" }
|
|
531
|
+
];
|
|
532
|
+
function relTime(iso) {
|
|
533
|
+
if (typeof iso !== "string") return "";
|
|
534
|
+
const t = new Date(iso).getTime();
|
|
535
|
+
if (!t) return "";
|
|
536
|
+
const s = (Date.now() - t) / 1e3;
|
|
537
|
+
if (s < 60) return "just now";
|
|
538
|
+
if (s < 3600) return `${Math.floor(s / 60)}m ago`;
|
|
539
|
+
if (s < 86400) return `${Math.floor(s / 3600)}h ago`;
|
|
540
|
+
if (s < 172800) return "yesterday";
|
|
541
|
+
return `${Math.floor(s / 86400)}d ago`;
|
|
542
|
+
}
|
|
543
|
+
function nodeAt(n) {
|
|
544
|
+
const d = n.data ?? {};
|
|
545
|
+
for (const k of ["at", "ts", "time", "created_at", "date", "bst", "ts_bst", "finished_at"]) {
|
|
546
|
+
const v = d[k];
|
|
547
|
+
if (typeof v === "string" && v) return v;
|
|
548
|
+
}
|
|
549
|
+
return "";
|
|
550
|
+
}
|
|
551
|
+
function timeMs(at) {
|
|
552
|
+
if (!at) return NaN;
|
|
553
|
+
const t = Date.parse(at);
|
|
554
|
+
return Number.isFinite(t) ? t : Number(at);
|
|
555
|
+
}
|
|
556
|
+
function buildHealthMap(nodes) {
|
|
557
|
+
const m = /* @__PURE__ */ new Map();
|
|
558
|
+
for (const r of nodes) {
|
|
559
|
+
if (!r.cluster) continue;
|
|
560
|
+
const d = r.data ?? {};
|
|
561
|
+
if (typeof d.status !== "string") continue;
|
|
562
|
+
const status = d.status;
|
|
563
|
+
const at = nodeAt(r);
|
|
564
|
+
const atMs = timeMs(at);
|
|
565
|
+
const cur = m.get(r.cluster) ?? { lastAt: "", lastMs: -Infinity, lastStatus: "", n: 0, fails: 0 };
|
|
566
|
+
cur.n++;
|
|
567
|
+
if (status === "fail") cur.fails++;
|
|
568
|
+
if (Number.isFinite(atMs) && atMs >= cur.lastMs) {
|
|
569
|
+
cur.lastMs = atMs;
|
|
570
|
+
cur.lastAt = at;
|
|
571
|
+
cur.lastStatus = status;
|
|
572
|
+
}
|
|
573
|
+
m.set(r.cluster, cur);
|
|
574
|
+
}
|
|
575
|
+
return m;
|
|
576
|
+
}
|
|
577
|
+
function pulseFor(a, health) {
|
|
578
|
+
if (!health) return null;
|
|
579
|
+
const keys = [a.id, ...a.buckets ?? []];
|
|
580
|
+
let best = null;
|
|
581
|
+
for (const k of keys) {
|
|
582
|
+
const p = health.get(k);
|
|
583
|
+
if (p && (!best || p.lastMs > best.lastMs)) best = p;
|
|
584
|
+
}
|
|
585
|
+
return best;
|
|
586
|
+
}
|
|
587
|
+
function lightFor(a, health) {
|
|
588
|
+
const p = pulseFor(a, health);
|
|
589
|
+
if (!p || !p.lastAt) return "none";
|
|
590
|
+
if (p.lastStatus === "fail") return "fail";
|
|
591
|
+
const ageH = (Date.now() - p.lastMs) / 36e5;
|
|
592
|
+
const cadence = typeof a.cadence === "number" && a.cadence > 0 ? a.cadence : 26;
|
|
593
|
+
if (ageH > cadence * 2) return "warn";
|
|
594
|
+
if (p.lastStatus === "warn") return "warn";
|
|
595
|
+
return "ok";
|
|
596
|
+
}
|
|
597
|
+
function unstableFor(a, health) {
|
|
598
|
+
return lightFor(a, health) === "ok" && (pulseFor(a, health)?.fails ?? 0) > 0;
|
|
599
|
+
}
|
|
600
|
+
var worst = (ls) => ls.includes("fail") ? "fail" : ls.includes("warn") ? "warn" : ls.includes("ok") ? "ok" : "none";
|
|
601
|
+
function nodeSummary(n) {
|
|
602
|
+
const d = n.data ?? {};
|
|
603
|
+
for (const k of ["summary", "title", "detail"]) {
|
|
604
|
+
const v = d[k];
|
|
605
|
+
if (typeof v === "string" && v && v !== n.label) return v;
|
|
606
|
+
}
|
|
607
|
+
return "";
|
|
608
|
+
}
|
|
609
|
+
async function fetchReports(api, cluster, limit = 500) {
|
|
610
|
+
const q = async (t) => {
|
|
611
|
+
try {
|
|
612
|
+
const base = `/nodes?type=${t}${cluster ? `&cluster=${encodeURIComponent(cluster)}` : ""}`;
|
|
613
|
+
const first = await api(`${base}&limit=${limit}`);
|
|
614
|
+
const nodes2 = first.nodes ?? [];
|
|
615
|
+
const want = Math.min(first.total ?? 0, limit);
|
|
616
|
+
while (nodes2.length < want) {
|
|
617
|
+
const page = await api(`${base}&limit=${limit}&offset=${nodes2.length}`);
|
|
618
|
+
if (!page.nodes?.length) break;
|
|
619
|
+
nodes2.push(...page.nodes);
|
|
620
|
+
}
|
|
621
|
+
return { total: first.total ?? 0, nodes: nodes2 };
|
|
622
|
+
} catch {
|
|
623
|
+
return { total: 0, nodes: [] };
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
const [r, d] = await Promise.all([q("report"), q("decision")]);
|
|
627
|
+
const nodes = [...r.nodes ?? [], ...d.nodes ?? []].sort((a, b) => nodeAt(b).localeCompare(nodeAt(a)));
|
|
628
|
+
return { total: (r.total ?? 0) + (d.total ?? 0), nodes };
|
|
629
|
+
}
|
|
630
|
+
function slugify(s) {
|
|
631
|
+
return s.toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
632
|
+
}
|
|
633
|
+
var REDUCED = typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
634
|
+
function readTheme() {
|
|
635
|
+
try {
|
|
636
|
+
return localStorage.getItem("booboo-theme") === "light" ? "light" : "dark";
|
|
637
|
+
} catch {
|
|
638
|
+
return "dark";
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
function useTheme() {
|
|
642
|
+
const [theme, setTheme] = useState(readTheme);
|
|
643
|
+
useEffect(() => {
|
|
644
|
+
document.documentElement.setAttribute("data-theme", theme);
|
|
645
|
+
try {
|
|
646
|
+
localStorage.setItem("booboo-theme", theme);
|
|
647
|
+
} catch {
|
|
648
|
+
}
|
|
649
|
+
}, [theme]);
|
|
650
|
+
return [theme, () => setTheme((t) => t === "dark" ? "light" : "dark")];
|
|
651
|
+
}
|
|
652
|
+
function useCountUp(target, ms = 900) {
|
|
653
|
+
const [v, setV] = useState(REDUCED ? target : 0);
|
|
654
|
+
const fromRef = useRef(0);
|
|
655
|
+
useEffect(() => {
|
|
656
|
+
if (REDUCED) {
|
|
657
|
+
setV(target);
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
const from = fromRef.current;
|
|
661
|
+
const t0 = performance.now();
|
|
662
|
+
let raf = 0;
|
|
663
|
+
const tick = (t) => {
|
|
664
|
+
const k = Math.min(1, (t - t0) / ms);
|
|
665
|
+
const eased = 1 - Math.pow(1 - k, 3);
|
|
666
|
+
setV(Math.round(from + (target - from) * eased));
|
|
667
|
+
if (k < 1) raf = requestAnimationFrame(tick);
|
|
668
|
+
else fromRef.current = target;
|
|
669
|
+
};
|
|
670
|
+
raf = requestAnimationFrame(tick);
|
|
671
|
+
return () => cancelAnimationFrame(raf);
|
|
672
|
+
}, [target, ms]);
|
|
673
|
+
return v;
|
|
674
|
+
}
|
|
675
|
+
function useRoute() {
|
|
676
|
+
const parse = () => {
|
|
677
|
+
const h = window.location.hash.replace(/^#\/?/, "");
|
|
678
|
+
const [tab, ...rest] = h.split("/");
|
|
679
|
+
const known = TABS.some((t) => t.id === tab) ? tab : "org";
|
|
680
|
+
return [known, rest.length ? decodeURIComponent(rest.join("/")) : null];
|
|
681
|
+
};
|
|
682
|
+
const [route, setRoute] = useState(parse);
|
|
683
|
+
useEffect(() => {
|
|
684
|
+
const onHash = () => setRoute(parse());
|
|
685
|
+
window.addEventListener("hashchange", onHash);
|
|
686
|
+
return () => window.removeEventListener("hashchange", onHash);
|
|
687
|
+
}, []);
|
|
688
|
+
return route;
|
|
689
|
+
}
|
|
690
|
+
var nav = (path) => {
|
|
691
|
+
window.location.hash = path;
|
|
692
|
+
};
|
|
693
|
+
function bucketHue(name) {
|
|
694
|
+
let h = 0;
|
|
695
|
+
for (const c of name) h = (h * 31 + c.charCodeAt(0)) % 360;
|
|
696
|
+
return h;
|
|
697
|
+
}
|
|
698
|
+
function AgentCard({
|
|
699
|
+
a,
|
|
700
|
+
isRoot,
|
|
701
|
+
depth,
|
|
702
|
+
order,
|
|
703
|
+
selected,
|
|
704
|
+
dragId,
|
|
705
|
+
onSelect,
|
|
706
|
+
onDragStart,
|
|
707
|
+
onDropOn,
|
|
708
|
+
childCount,
|
|
709
|
+
light = "none"
|
|
710
|
+
}) {
|
|
711
|
+
const [over, setOver] = useState(false);
|
|
712
|
+
const nBuckets = a.buckets?.length ?? 0;
|
|
713
|
+
const nSkills = a.skills?.length ?? 0;
|
|
714
|
+
return /* @__PURE__ */ jsxs(
|
|
715
|
+
"div",
|
|
716
|
+
{
|
|
717
|
+
className: `ag${isRoot ? " root" : ""}${selected ? " sel" : ""}${over ? " over" : ""}${dragId === a.id ? " dragging" : ""}`,
|
|
718
|
+
style: { ["--h"]: bucketHue(a.id), ["--d"]: depth, animationDelay: `${Math.min(depth * 70 + order * 45, 600)}ms` },
|
|
719
|
+
draggable: !isRoot,
|
|
720
|
+
tabIndex: 0,
|
|
721
|
+
onKeyDown: (e) => {
|
|
722
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
723
|
+
e.preventDefault();
|
|
724
|
+
onSelect(a.id);
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
onClick: (e) => {
|
|
728
|
+
e.stopPropagation();
|
|
729
|
+
onSelect(a.id);
|
|
730
|
+
},
|
|
731
|
+
onDragStart: (e) => {
|
|
732
|
+
e.dataTransfer.effectAllowed = "move";
|
|
733
|
+
onDragStart(a.id);
|
|
734
|
+
},
|
|
735
|
+
onDragOver: (e) => {
|
|
736
|
+
if (dragId && dragId !== a.id) {
|
|
737
|
+
e.preventDefault();
|
|
738
|
+
setOver(true);
|
|
739
|
+
}
|
|
740
|
+
},
|
|
741
|
+
onDragLeave: () => setOver(false),
|
|
742
|
+
onDrop: (e) => {
|
|
743
|
+
e.preventDefault();
|
|
744
|
+
setOver(false);
|
|
745
|
+
onDropOn(a.id);
|
|
746
|
+
},
|
|
747
|
+
children: [
|
|
748
|
+
light !== "none" && /* @__PURE__ */ jsx("i", { className: `ag-light ${light}`, title: `fleet health: ${light}` }),
|
|
749
|
+
/* @__PURE__ */ jsx("span", { className: "ag-ava", children: a.emoji || "\u{1F916}" }),
|
|
750
|
+
/* @__PURE__ */ jsx("span", { className: "ag-name", children: a.name }),
|
|
751
|
+
/* @__PURE__ */ jsx("span", { className: "ag-role", children: a.role || " " }),
|
|
752
|
+
/* @__PURE__ */ jsxs("span", { className: "ag-meta", children: [
|
|
753
|
+
nBuckets > 0 && /* @__PURE__ */ jsxs("em", { title: "memory buckets", children: [
|
|
754
|
+
"\u25A4 ",
|
|
755
|
+
nBuckets
|
|
756
|
+
] }),
|
|
757
|
+
nSkills > 0 && /* @__PURE__ */ jsxs("em", { title: "skills", children: [
|
|
758
|
+
"\u2726 ",
|
|
759
|
+
nSkills
|
|
760
|
+
] }),
|
|
761
|
+
childCount > 0 && /* @__PURE__ */ jsxs("span", { className: "ag-kids", title: "direct reports", children: [
|
|
762
|
+
childCount,
|
|
763
|
+
" reports"
|
|
764
|
+
] })
|
|
765
|
+
] })
|
|
766
|
+
]
|
|
767
|
+
}
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
function ChartNode({
|
|
771
|
+
org,
|
|
772
|
+
a,
|
|
773
|
+
depth,
|
|
774
|
+
order,
|
|
775
|
+
...cardProps
|
|
776
|
+
}) {
|
|
777
|
+
const kids = org.agents.filter((c) => c.parent === a.id && c.kind !== "automation");
|
|
778
|
+
const machines = (() => {
|
|
779
|
+
const out = [];
|
|
780
|
+
const walk = (pid) => {
|
|
781
|
+
for (const c of org.agents.filter((x) => x.parent === pid && x.kind === "automation")) {
|
|
782
|
+
const hasKids = org.agents.some((x) => x.parent === c.id);
|
|
783
|
+
if (hasKids) walk(c.id);
|
|
784
|
+
else out.push(c);
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
walk(a.id);
|
|
788
|
+
return out;
|
|
789
|
+
})();
|
|
790
|
+
const lights = machines.map((m) => lightFor(m, cardProps.health));
|
|
791
|
+
const trayLight = worst(lights);
|
|
792
|
+
const TRAY_MAX = 8;
|
|
793
|
+
const hidden = machines.length - TRAY_MAX;
|
|
794
|
+
const hiddenBad = machines.slice(TRAY_MAX).reduce(
|
|
795
|
+
(n, m) => n + (lightFor(m, cardProps.health) !== "ok" && lightFor(m, cardProps.health) !== "none" ? 1 : 0),
|
|
796
|
+
0
|
|
797
|
+
);
|
|
798
|
+
return /* @__PURE__ */ jsxs("div", { className: "ocn", children: [
|
|
799
|
+
/* @__PURE__ */ jsx(
|
|
800
|
+
AgentCard,
|
|
801
|
+
{
|
|
802
|
+
a,
|
|
803
|
+
isRoot: a.id === org.root,
|
|
804
|
+
depth,
|
|
805
|
+
order,
|
|
806
|
+
selected: cardProps.selected === a.id,
|
|
807
|
+
dragId: cardProps.dragId,
|
|
808
|
+
onSelect: cardProps.onSelect,
|
|
809
|
+
onDragStart: cardProps.onDragStart,
|
|
810
|
+
onDropOn: cardProps.onDropOn,
|
|
811
|
+
childCount: kids.length,
|
|
812
|
+
light: trayLight
|
|
813
|
+
}
|
|
814
|
+
),
|
|
815
|
+
machines.length > 0 && /* @__PURE__ */ jsxs("div", { className: `oc-tray ${trayLight}`, children: [
|
|
816
|
+
machines.slice(0, TRAY_MAX).map((m) => /* @__PURE__ */ jsxs(
|
|
817
|
+
"button",
|
|
818
|
+
{
|
|
819
|
+
type: "button",
|
|
820
|
+
className: `oc-mac${cardProps.selected === m.id ? " sel" : ""}`,
|
|
821
|
+
title: `${m.name}${m.role ? ` \u2014 ${m.role}` : ""}`,
|
|
822
|
+
onClick: (e) => {
|
|
823
|
+
e.stopPropagation();
|
|
824
|
+
cardProps.onSelect(m.id);
|
|
825
|
+
},
|
|
826
|
+
children: [
|
|
827
|
+
/* @__PURE__ */ jsx("i", { className: `mac-dot ${lightFor(m, cardProps.health)}${unstableFor(m, cardProps.health) ? " unstable" : ""}` }),
|
|
828
|
+
/* @__PURE__ */ jsx("span", { className: "mac-emoji", children: m.emoji || "\u2699\uFE0F" }),
|
|
829
|
+
/* @__PURE__ */ jsx("span", { className: "mac-name", children: m.name })
|
|
830
|
+
]
|
|
831
|
+
},
|
|
832
|
+
m.id
|
|
833
|
+
)),
|
|
834
|
+
hidden > 0 && /* @__PURE__ */ jsxs(
|
|
835
|
+
"button",
|
|
836
|
+
{
|
|
837
|
+
type: "button",
|
|
838
|
+
className: "oc-mac more",
|
|
839
|
+
title: "open the full machine list in the dossier",
|
|
840
|
+
onClick: (e) => {
|
|
841
|
+
e.stopPropagation();
|
|
842
|
+
cardProps.onSelect(a.id);
|
|
843
|
+
},
|
|
844
|
+
children: [
|
|
845
|
+
"+",
|
|
846
|
+
hidden,
|
|
847
|
+
" machines",
|
|
848
|
+
hiddenBad > 0 ? ` \xB7 ${hiddenBad} not green` : ""
|
|
849
|
+
]
|
|
850
|
+
}
|
|
851
|
+
)
|
|
852
|
+
] }),
|
|
853
|
+
kids.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
854
|
+
/* @__PURE__ */ jsx("div", { className: "oc-down" }),
|
|
855
|
+
/* @__PURE__ */ jsx("div", { className: `oc-row${kids.length > 3 ? " wrap" : ""}`, children: kids.map((k, i) => /* @__PURE__ */ jsx("div", { className: "oc-child", style: { ["--h"]: bucketHue(k.id) }, children: /* @__PURE__ */ jsx(ChartNode, { org, a: k, depth: depth + 1, order: i, ...cardProps }) }, k.id)) })
|
|
856
|
+
] })
|
|
857
|
+
] });
|
|
858
|
+
}
|
|
859
|
+
function Chip({ children, tone, onClick }) {
|
|
860
|
+
return /* @__PURE__ */ jsx("span", { className: `chip${tone ? ` ${tone}` : ""}${onClick ? " tap" : ""}`, onClick, children });
|
|
861
|
+
}
|
|
862
|
+
function Dossier({
|
|
863
|
+
org,
|
|
864
|
+
id,
|
|
865
|
+
hasSnapshot,
|
|
866
|
+
onUpdate,
|
|
867
|
+
onAdd,
|
|
868
|
+
onRemove,
|
|
869
|
+
onSelect,
|
|
870
|
+
health = null
|
|
871
|
+
}) {
|
|
872
|
+
const api = useApi();
|
|
873
|
+
const slice = useMemo(() => orgBootSlice(org, id), [org, id]);
|
|
874
|
+
const autos = useMemo(() => {
|
|
875
|
+
const out = [];
|
|
876
|
+
const walk = (pid) => {
|
|
877
|
+
for (const c of org.agents.filter((x) => x.parent === pid && x.kind === "automation")) {
|
|
878
|
+
const hasKids = org.agents.some((x) => x.parent === c.id);
|
|
879
|
+
if (hasKids) walk(c.id);
|
|
880
|
+
else out.push(c);
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
walk(id);
|
|
884
|
+
return out;
|
|
885
|
+
}, [org, id]);
|
|
886
|
+
const [memCount, setMemCount] = useState(null);
|
|
887
|
+
const [repCount, setRepCount] = useState(null);
|
|
888
|
+
const [reports, setReports] = useState(null);
|
|
889
|
+
const [edit, setEdit] = useState(false);
|
|
890
|
+
const [form, setForm] = useState({});
|
|
891
|
+
const [openRep, setOpenRep] = useState(null);
|
|
892
|
+
const [editContract, setEditContract] = useState(false);
|
|
893
|
+
const [contractText, setContractText] = useState("");
|
|
894
|
+
useEffect(() => {
|
|
895
|
+
setEdit(false);
|
|
896
|
+
setOpenRep(null);
|
|
897
|
+
setEditContract(false);
|
|
898
|
+
}, [id]);
|
|
899
|
+
useEffect(() => {
|
|
900
|
+
setMemCount(null);
|
|
901
|
+
setRepCount(null);
|
|
902
|
+
setReports(null);
|
|
903
|
+
if (!hasSnapshot || !slice) return;
|
|
904
|
+
Promise.all(
|
|
905
|
+
slice.buckets.map(
|
|
906
|
+
(b) => api(`/nodes?type=memory&cluster=${encodeURIComponent(b)}&limit=1`).then((j) => j.total).catch(() => 0)
|
|
907
|
+
)
|
|
908
|
+
).then((counts) => setMemCount(counts.reduce((s, n) => s + n, 0)));
|
|
909
|
+
fetchReports(api, id, 100).then(({ total, nodes }) => {
|
|
910
|
+
setRepCount(total);
|
|
911
|
+
setReports(nodes.slice(0, 4));
|
|
912
|
+
});
|
|
913
|
+
}, [id, hasSnapshot, slice, api]);
|
|
914
|
+
const mem = useCountUp(memCount ?? 0);
|
|
915
|
+
const rep = useCountUp(repCount ?? 0);
|
|
916
|
+
const startEdit = () => {
|
|
917
|
+
if (!slice) return;
|
|
918
|
+
const ag = slice.agent;
|
|
919
|
+
setForm({
|
|
920
|
+
name: ag.name ?? "",
|
|
921
|
+
emoji: ag.emoji ?? "",
|
|
922
|
+
role: ag.role ?? "",
|
|
923
|
+
boot: ag.boot ?? "",
|
|
924
|
+
rules: (ag.rules ?? []).join(", "),
|
|
925
|
+
skills: (ag.skills ?? []).join(", "),
|
|
926
|
+
buckets: (ag.buckets ?? []).join(", ")
|
|
927
|
+
});
|
|
928
|
+
setEdit(true);
|
|
929
|
+
};
|
|
930
|
+
const saveEdit = () => {
|
|
931
|
+
const list = (s) => s.split(",").map((x) => x.trim()).filter(Boolean);
|
|
932
|
+
onUpdate(id, {
|
|
933
|
+
name: form.name.trim() || slice?.agent.name || id,
|
|
934
|
+
emoji: form.emoji.trim() || void 0,
|
|
935
|
+
role: form.role.trim() || void 0,
|
|
936
|
+
boot: form.boot.trim() || void 0,
|
|
937
|
+
rules: list(form.rules),
|
|
938
|
+
skills: list(form.skills),
|
|
939
|
+
buckets: list(form.buckets)
|
|
940
|
+
});
|
|
941
|
+
setEdit(false);
|
|
942
|
+
};
|
|
943
|
+
if (!slice) return null;
|
|
944
|
+
const a = slice.agent;
|
|
945
|
+
const isRoot = a.id === org.root;
|
|
946
|
+
const own = new Set(a.rules ?? []);
|
|
947
|
+
return /* @__PURE__ */ jsxs("aside", { className: "doss", onClick: (e) => e.stopPropagation(), children: [
|
|
948
|
+
/* @__PURE__ */ jsxs("div", { className: "doss-head", children: [
|
|
949
|
+
/* @__PURE__ */ jsx("span", { className: "doss-emoji", children: a.emoji || "\u{1F916}" }),
|
|
950
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
951
|
+
/* @__PURE__ */ jsxs("h2", { children: [
|
|
952
|
+
a.name,
|
|
953
|
+
" ",
|
|
954
|
+
a.kind === "automation" && /* @__PURE__ */ jsx("span", { className: "auto-badge", children: "automation" })
|
|
955
|
+
] }),
|
|
956
|
+
a.role && /* @__PURE__ */ jsx("p", { className: "doss-role", children: a.role })
|
|
957
|
+
] }),
|
|
958
|
+
/* @__PURE__ */ jsxs("div", { className: "doss-head-actions", children: [
|
|
959
|
+
!edit && /* @__PURE__ */ jsx("button", { className: "doss-3d", title: "edit this agent", onClick: startEdit, children: "\u270E edit" }),
|
|
960
|
+
hasSnapshot && /* @__PURE__ */ jsx("button", { className: "doss-3d", title: "see the whole brain in 3D", onClick: () => nav("/graph"), children: "\u25C9 3D" })
|
|
961
|
+
] })
|
|
962
|
+
] }),
|
|
963
|
+
edit && /* @__PURE__ */ jsxs("div", { className: "doss-edit", children: [
|
|
964
|
+
/* @__PURE__ */ jsxs("div", { className: "doss-edit-row2", children: [
|
|
965
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
966
|
+
"name",
|
|
967
|
+
/* @__PURE__ */ jsx("input", { value: form.name, onChange: (e) => setForm({ ...form, name: e.target.value }) })
|
|
968
|
+
] }),
|
|
969
|
+
/* @__PURE__ */ jsxs("label", { className: "narrow", children: [
|
|
970
|
+
"emoji",
|
|
971
|
+
/* @__PURE__ */ jsx("input", { value: form.emoji, onChange: (e) => setForm({ ...form, emoji: e.target.value }) })
|
|
972
|
+
] })
|
|
973
|
+
] }),
|
|
974
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
975
|
+
"role",
|
|
976
|
+
/* @__PURE__ */ jsx("input", { value: form.role, onChange: (e) => setForm({ ...form, role: e.target.value }), placeholder: "one line \u2014 what this agent is for" })
|
|
977
|
+
] }),
|
|
978
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
979
|
+
"rules ",
|
|
980
|
+
/* @__PURE__ */ jsx("em", { children: "comma-separated refs \xB7 inherited by everyone beneath" }),
|
|
981
|
+
/* @__PURE__ */ jsx("input", { value: form.rules, onChange: (e) => setForm({ ...form, rules: e.target.value }), placeholder: "rules/GLOBAL.md, rules/CONTENT.md" })
|
|
982
|
+
] }),
|
|
983
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
984
|
+
"memory buckets ",
|
|
985
|
+
/* @__PURE__ */ jsx("em", { children: "comma-separated" }),
|
|
986
|
+
/* @__PURE__ */ jsx("input", { value: form.buckets, onChange: (e) => setForm({ ...form, buckets: e.target.value }), placeholder: "shared, content" })
|
|
987
|
+
] }),
|
|
988
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
989
|
+
"skills ",
|
|
990
|
+
/* @__PURE__ */ jsx("em", { children: "comma-separated" }),
|
|
991
|
+
/* @__PURE__ */ jsx("input", { value: form.skills, onChange: (e) => setForm({ ...form, skills: e.target.value }), placeholder: "humanizer, deep-research" })
|
|
992
|
+
] }),
|
|
993
|
+
/* @__PURE__ */ jsx("p", { className: "doss-edit-hint", children: "\u2193 edit the contract below \u2014 the agent's operating prompt lives in its own section." }),
|
|
994
|
+
/* @__PURE__ */ jsxs("div", { className: "doss-edit-actions", children: [
|
|
995
|
+
/* @__PURE__ */ jsx("button", { className: "btn primary", onClick: saveEdit, children: "save to draft" }),
|
|
996
|
+
/* @__PURE__ */ jsx("button", { className: "btn ghost", onClick: () => setEdit(false), children: "cancel" })
|
|
997
|
+
] })
|
|
998
|
+
] }),
|
|
999
|
+
a.kind === "automation" && (() => {
|
|
1000
|
+
const p = pulseFor(a, health);
|
|
1001
|
+
const l = lightFor(a, health);
|
|
1002
|
+
return /* @__PURE__ */ jsxs("div", { className: `doss-health ${l}`, children: [
|
|
1003
|
+
/* @__PURE__ */ jsx("i", { className: `mac-dot ${l}` }),
|
|
1004
|
+
/* @__PURE__ */ jsx("b", { children: l === "ok" ? "healthy" : l === "fail" ? "last run failed" : l === "warn" ? "stale or degraded" : "no runs recorded" }),
|
|
1005
|
+
p?.lastAt && /* @__PURE__ */ jsxs("span", { children: [
|
|
1006
|
+
"last run ",
|
|
1007
|
+
relTime(p.lastAt)
|
|
1008
|
+
] }),
|
|
1009
|
+
p && p.n > 0 && /* @__PURE__ */ jsxs("span", { children: [
|
|
1010
|
+
Math.round((p.n - p.fails) / p.n * 100),
|
|
1011
|
+
"% ok of ",
|
|
1012
|
+
p.n
|
|
1013
|
+
] }),
|
|
1014
|
+
typeof a.cadence === "number" && /* @__PURE__ */ jsxs("span", { children: [
|
|
1015
|
+
"expected every ",
|
|
1016
|
+
a.cadence,
|
|
1017
|
+
"h"
|
|
1018
|
+
] })
|
|
1019
|
+
] });
|
|
1020
|
+
})(),
|
|
1021
|
+
/* @__PURE__ */ jsx("div", { className: "doss-chain", children: slice.chain.map((c, i) => /* @__PURE__ */ jsxs("span", { children: [
|
|
1022
|
+
i > 0 && /* @__PURE__ */ jsx("i", { children: "\u203A" }),
|
|
1023
|
+
/* @__PURE__ */ jsx("b", { className: c.id === a.id ? "me" : "", children: c.name })
|
|
1024
|
+
] }, c.id)) }),
|
|
1025
|
+
hasSnapshot && /* @__PURE__ */ jsxs("div", { className: "doss-stats", children: [
|
|
1026
|
+
/* @__PURE__ */ jsxs("div", { className: "doss-stat", children: [
|
|
1027
|
+
/* @__PURE__ */ jsx("div", { className: "doss-n", children: memCount === null ? "\u2026" : mem.toLocaleString() }),
|
|
1028
|
+
/* @__PURE__ */ jsx("div", { className: "doss-l", children: "memories in reach" })
|
|
1029
|
+
] }),
|
|
1030
|
+
/* @__PURE__ */ jsxs("div", { className: "doss-stat", children: [
|
|
1031
|
+
/* @__PURE__ */ jsx("div", { className: "doss-n", children: repCount === null ? "\u2026" : rep.toLocaleString() }),
|
|
1032
|
+
/* @__PURE__ */ jsx("div", { className: "doss-l", children: "reports filed" })
|
|
1033
|
+
] }),
|
|
1034
|
+
/* @__PURE__ */ jsxs("div", { className: "doss-stat", children: [
|
|
1035
|
+
/* @__PURE__ */ jsx("div", { className: "doss-n", children: slice.children.filter((c) => c.kind !== "automation").length }),
|
|
1036
|
+
/* @__PURE__ */ jsx("div", { className: "doss-l", children: "direct reports" })
|
|
1037
|
+
] })
|
|
1038
|
+
] }),
|
|
1039
|
+
hasSnapshot && /* @__PURE__ */ jsxs("section", { children: [
|
|
1040
|
+
/* @__PURE__ */ jsx("h3", { children: "latest reports" }),
|
|
1041
|
+
reports === null ? /* @__PURE__ */ jsx("p", { className: "doss-empty", children: "loading\u2026" }) : reports.length === 0 ? /* @__PURE__ */ jsx("p", { className: "doss-empty", children: "no reports filed yet \u2014 they appear here as this agent closes work." }) : /* @__PURE__ */ jsx("div", { className: "doss-reps", children: reports.map((r) => {
|
|
1042
|
+
const when = relTime(nodeAt(r));
|
|
1043
|
+
const sum = nodeSummary(r);
|
|
1044
|
+
const st = typeof r.data?.status === "string" ? String(r.data.status) : void 0;
|
|
1045
|
+
const open = openRep === r.id;
|
|
1046
|
+
const skip = /* @__PURE__ */ new Set(["summary", "status", "at", "ts", "time", "created_at", "date", "bst", "ts_bst", "finished_at"]);
|
|
1047
|
+
const extra = r.data ? Object.entries(r.data).filter(([k, v]) => !skip.has(k) && v != null && v !== "") : [];
|
|
1048
|
+
return /* @__PURE__ */ jsxs(
|
|
1049
|
+
"div",
|
|
1050
|
+
{
|
|
1051
|
+
className: `doss-rep tap${open ? " open" : ""}`,
|
|
1052
|
+
role: "button",
|
|
1053
|
+
tabIndex: 0,
|
|
1054
|
+
"aria-expanded": open,
|
|
1055
|
+
title: "click for the full report",
|
|
1056
|
+
onClick: () => setOpenRep(open ? null : r.id),
|
|
1057
|
+
onKeyDown: (e) => {
|
|
1058
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1059
|
+
e.preventDefault();
|
|
1060
|
+
setOpenRep(open ? null : r.id);
|
|
1061
|
+
}
|
|
1062
|
+
},
|
|
1063
|
+
children: [
|
|
1064
|
+
/* @__PURE__ */ jsxs("div", { className: "doss-rep-top", children: [
|
|
1065
|
+
st && /* @__PURE__ */ jsx("span", { className: `rep-dot ${st}`, "aria-label": st }),
|
|
1066
|
+
when && /* @__PURE__ */ jsx("span", { className: "doss-rep-when", children: when }),
|
|
1067
|
+
/* @__PURE__ */ jsx("span", { className: "doss-rep-label", children: r.label }),
|
|
1068
|
+
/* @__PURE__ */ jsx("span", { className: "doss-rep-caret", "aria-hidden": true, children: open ? "\u25BE" : "\u25B8" })
|
|
1069
|
+
] }),
|
|
1070
|
+
sum && /* @__PURE__ */ jsx("p", { className: "doss-rep-sum", children: sum }),
|
|
1071
|
+
open && /* @__PURE__ */ jsxs("div", { className: "doss-rep-detail", children: [
|
|
1072
|
+
st && /* @__PURE__ */ jsxs("div", { children: [
|
|
1073
|
+
/* @__PURE__ */ jsx("span", { className: "doss-l", children: "status" }),
|
|
1074
|
+
" ",
|
|
1075
|
+
/* @__PURE__ */ jsx("b", { className: `rep-${st}`, children: st })
|
|
1076
|
+
] }),
|
|
1077
|
+
extra.map(([k, v]) => /* @__PURE__ */ jsxs("div", { children: [
|
|
1078
|
+
/* @__PURE__ */ jsx("span", { className: "doss-l", children: k }),
|
|
1079
|
+
" ",
|
|
1080
|
+
String(v)
|
|
1081
|
+
] }, k)),
|
|
1082
|
+
extra.length === 0 && !st && /* @__PURE__ */ jsx("div", { className: "doss-empty", children: "no extra detail on this report" })
|
|
1083
|
+
] })
|
|
1084
|
+
]
|
|
1085
|
+
},
|
|
1086
|
+
r.id
|
|
1087
|
+
);
|
|
1088
|
+
}) })
|
|
1089
|
+
] }),
|
|
1090
|
+
autos.length > 0 && /* @__PURE__ */ jsxs("section", { children: [
|
|
1091
|
+
/* @__PURE__ */ jsxs("h3", { children: [
|
|
1092
|
+
"automations \xB7 ",
|
|
1093
|
+
autos.length,
|
|
1094
|
+
" \u2014 machines this agent operates"
|
|
1095
|
+
] }),
|
|
1096
|
+
/* @__PURE__ */ jsx("div", { className: "doss-autos", children: autos.map((m) => {
|
|
1097
|
+
const p = pulseFor(m, health);
|
|
1098
|
+
return /* @__PURE__ */ jsxs("button", { className: "doss-auto", onClick: () => onSelect(m.id), children: [
|
|
1099
|
+
/* @__PURE__ */ jsx("i", { className: `mac-dot ${lightFor(m, health)}${unstableFor(m, health) ? " unstable" : ""}` }),
|
|
1100
|
+
/* @__PURE__ */ jsx("span", { className: "doss-auto-emoji", children: m.emoji || "\u2699\uFE0F" }),
|
|
1101
|
+
/* @__PURE__ */ jsx("span", { className: "doss-auto-name", children: m.name }),
|
|
1102
|
+
m.role && /* @__PURE__ */ jsx("span", { className: "doss-auto-role", children: m.role }),
|
|
1103
|
+
p?.lastAt && /* @__PURE__ */ jsx("span", { className: "doss-auto-when", children: relTime(p.lastAt) })
|
|
1104
|
+
] }, m.id);
|
|
1105
|
+
}) })
|
|
1106
|
+
] }),
|
|
1107
|
+
/* @__PURE__ */ jsxs("section", { children: [
|
|
1108
|
+
/* @__PURE__ */ jsx("h3", { children: "rules \xB7 inherited top-down" }),
|
|
1109
|
+
slice.rules.length === 0 ? /* @__PURE__ */ jsx("p", { className: "doss-empty", children: "no rules anywhere on this branch yet." }) : /* @__PURE__ */ jsx("ul", { className: "doss-rules", children: slice.rules.map((r) => /* @__PURE__ */ jsxs("li", { className: own.has(r) ? "own" : "", children: [
|
|
1110
|
+
r,
|
|
1111
|
+
" ",
|
|
1112
|
+
!own.has(r) && /* @__PURE__ */ jsx("em", { children: "inherited" })
|
|
1113
|
+
] }, r)) })
|
|
1114
|
+
] }),
|
|
1115
|
+
/* @__PURE__ */ jsxs("section", { children: [
|
|
1116
|
+
/* @__PURE__ */ jsx("h3", { children: "memory buckets" }),
|
|
1117
|
+
slice.buckets.length === 0 ? /* @__PURE__ */ jsx("p", { className: "doss-empty", children: "no bucket access \u2014 this agent remembers nothing." }) : /* @__PURE__ */ jsx("div", { className: "doss-chips", children: slice.buckets.map((b) => /* @__PURE__ */ jsxs(Chip, { onClick: () => nav(`/buckets/${encodeURIComponent(b)}`), children: [
|
|
1118
|
+
b,
|
|
1119
|
+
" \u203A"
|
|
1120
|
+
] }, b)) })
|
|
1121
|
+
] }),
|
|
1122
|
+
/* @__PURE__ */ jsxs("section", { children: [
|
|
1123
|
+
/* @__PURE__ */ jsx("h3", { children: "skills" }),
|
|
1124
|
+
slice.skills.length === 0 ? /* @__PURE__ */ jsx("p", { className: "doss-empty", children: "no skills declared." }) : /* @__PURE__ */ jsx("div", { className: "doss-chips", children: slice.skills.map((s) => /* @__PURE__ */ jsx(Chip, { tone: "alt", children: s }, s)) })
|
|
1125
|
+
] }),
|
|
1126
|
+
!edit && /* @__PURE__ */ jsxs("section", { className: "doss-contract", children: [
|
|
1127
|
+
/* @__PURE__ */ jsxs("h3", { children: [
|
|
1128
|
+
"contract ",
|
|
1129
|
+
/* @__PURE__ */ jsx("em", { children: "the operating prompt \u2014 loaded first, every session" })
|
|
1130
|
+
] }),
|
|
1131
|
+
editContract ? /* @__PURE__ */ jsxs("div", { className: "contract-edit", children: [
|
|
1132
|
+
/* @__PURE__ */ jsx(
|
|
1133
|
+
"textarea",
|
|
1134
|
+
{
|
|
1135
|
+
className: "contract-ta",
|
|
1136
|
+
autoFocus: true,
|
|
1137
|
+
value: contractText,
|
|
1138
|
+
onChange: (e) => setContractText(e.target.value),
|
|
1139
|
+
placeholder: "Who this agent is \xB7 what it decides \xB7 how it verifies \xB7 when it stops. This is the first thing it reads."
|
|
1140
|
+
}
|
|
1141
|
+
),
|
|
1142
|
+
/* @__PURE__ */ jsxs("div", { className: "doss-edit-actions", children: [
|
|
1143
|
+
/* @__PURE__ */ jsx("button", { className: "btn primary", onClick: () => {
|
|
1144
|
+
onUpdate(id, { boot: contractText.trim() || void 0 });
|
|
1145
|
+
setEditContract(false);
|
|
1146
|
+
}, children: "save to draft" }),
|
|
1147
|
+
/* @__PURE__ */ jsx("button", { className: "btn ghost", onClick: () => setEditContract(false), children: "cancel" })
|
|
1148
|
+
] })
|
|
1149
|
+
] }) : /* @__PURE__ */ jsxs(
|
|
1150
|
+
"button",
|
|
1151
|
+
{
|
|
1152
|
+
type: "button",
|
|
1153
|
+
className: `contract-card${a.boot ? "" : " empty"}`,
|
|
1154
|
+
title: "click to open \xB7 edit this agent's contract",
|
|
1155
|
+
onClick: () => {
|
|
1156
|
+
setContractText(a.boot ?? "");
|
|
1157
|
+
setEditContract(true);
|
|
1158
|
+
},
|
|
1159
|
+
children: [
|
|
1160
|
+
a.boot ? /* @__PURE__ */ jsx("p", { className: "doss-boot", children: a.boot }) : /* @__PURE__ */ jsx("p", { className: "doss-empty", children: "no contract yet \u2014 click to write one." }),
|
|
1161
|
+
/* @__PURE__ */ jsx("span", { className: "contract-hint", children: "\u270E edit" })
|
|
1162
|
+
]
|
|
1163
|
+
}
|
|
1164
|
+
)
|
|
1165
|
+
] }),
|
|
1166
|
+
/* @__PURE__ */ jsxs("div", { className: "doss-foot", children: [
|
|
1167
|
+
/* @__PURE__ */ jsxs("button", { className: "btn ghost", onClick: () => onAdd(id), children: [
|
|
1168
|
+
"\uFF0B add agent under ",
|
|
1169
|
+
a.name
|
|
1170
|
+
] }),
|
|
1171
|
+
!isRoot && /* @__PURE__ */ jsxs("button", { className: "btn danger", onClick: () => onRemove(id), children: [
|
|
1172
|
+
"\u2212 remove ",
|
|
1173
|
+
a.name
|
|
1174
|
+
] })
|
|
1175
|
+
] })
|
|
1176
|
+
] });
|
|
1177
|
+
}
|
|
1178
|
+
function OrgScreen({
|
|
1179
|
+
draft,
|
|
1180
|
+
selected,
|
|
1181
|
+
dragId,
|
|
1182
|
+
setSelected,
|
|
1183
|
+
setDragId,
|
|
1184
|
+
dropOn,
|
|
1185
|
+
hasSnapshot,
|
|
1186
|
+
onUpdate,
|
|
1187
|
+
onAdd,
|
|
1188
|
+
onRemove
|
|
1189
|
+
}) {
|
|
1190
|
+
const api = useApi();
|
|
1191
|
+
const [health, setHealth] = useState(null);
|
|
1192
|
+
useEffect(() => {
|
|
1193
|
+
if (!hasSnapshot) return;
|
|
1194
|
+
fetchReports(api, null, 1e4).then(({ nodes }) => setHealth(buildHealthMap(nodes))).catch(() => {
|
|
1195
|
+
});
|
|
1196
|
+
}, [hasSnapshot, api]);
|
|
1197
|
+
const fitRef = useRef(null);
|
|
1198
|
+
const chartRef = useRef(null);
|
|
1199
|
+
const [fit, setFit] = useState(1);
|
|
1200
|
+
const [zoom, setZoom] = useState(null);
|
|
1201
|
+
const eff = zoom ?? fit;
|
|
1202
|
+
useLayoutEffect(() => {
|
|
1203
|
+
const vp = fitRef.current, chart = chartRef.current;
|
|
1204
|
+
if (!vp || !chart) return;
|
|
1205
|
+
const PAD = 24;
|
|
1206
|
+
const measure = () => {
|
|
1207
|
+
const natW = chart.scrollWidth, natH = chart.scrollHeight;
|
|
1208
|
+
const availW = vp.clientWidth - PAD * 2, availH = vp.clientHeight - PAD * 2;
|
|
1209
|
+
if (natW <= 0 || natH <= 0) return;
|
|
1210
|
+
const k = Math.min(1, availW / natW, availH / natH);
|
|
1211
|
+
setFit(k > 0 ? k : 1);
|
|
1212
|
+
};
|
|
1213
|
+
measure();
|
|
1214
|
+
const ro = new ResizeObserver(measure);
|
|
1215
|
+
ro.observe(vp);
|
|
1216
|
+
ro.observe(chart);
|
|
1217
|
+
return () => ro.disconnect();
|
|
1218
|
+
}, [draft, health, selected]);
|
|
1219
|
+
const effRef = useRef(eff);
|
|
1220
|
+
effRef.current = eff;
|
|
1221
|
+
useEffect(() => {
|
|
1222
|
+
const vp = fitRef.current;
|
|
1223
|
+
if (!vp) return;
|
|
1224
|
+
const onWheel = (e) => {
|
|
1225
|
+
if (!e.ctrlKey && !e.metaKey) return;
|
|
1226
|
+
e.preventDefault();
|
|
1227
|
+
const k = e.deltaY < 0 ? 1.12 : 1 / 1.12;
|
|
1228
|
+
setZoom(Math.min(2.5, Math.max(0.2, effRef.current * k)));
|
|
1229
|
+
};
|
|
1230
|
+
vp.addEventListener("wheel", onWheel, { passive: false });
|
|
1231
|
+
return () => vp.removeEventListener("wheel", onWheel);
|
|
1232
|
+
}, []);
|
|
1233
|
+
const root = draft.agents.find((a) => a.id === draft.root);
|
|
1234
|
+
return /* @__PURE__ */ jsxs("div", { className: "body", onClick: () => setSelected(null), children: [
|
|
1235
|
+
/* @__PURE__ */ jsxs("main", { className: "tree", onClick: (e) => e.stopPropagation(), children: [
|
|
1236
|
+
/* @__PURE__ */ jsx("p", { className: "tree-hint", children: "drag an agent onto its new parent \xB7 click for its dossier \xB7 machine trays show live health" }),
|
|
1237
|
+
/* @__PURE__ */ jsx("div", { className: `chart-fit${zoom !== null ? " zoomed" : ""}`, ref: fitRef, children: /* @__PURE__ */ jsx("div", { className: "chart", ref: chartRef, style: { ["--fit"]: eff }, children: root && /* @__PURE__ */ jsx(
|
|
1238
|
+
ChartNode,
|
|
1239
|
+
{
|
|
1240
|
+
org: draft,
|
|
1241
|
+
a: root,
|
|
1242
|
+
depth: 0,
|
|
1243
|
+
order: 0,
|
|
1244
|
+
selected,
|
|
1245
|
+
dragId,
|
|
1246
|
+
health,
|
|
1247
|
+
onSelect: setSelected,
|
|
1248
|
+
onDragStart: setDragId,
|
|
1249
|
+
onDropOn: dropOn
|
|
1250
|
+
}
|
|
1251
|
+
) }) }),
|
|
1252
|
+
/* @__PURE__ */ jsxs("div", { className: "zoomer", children: [
|
|
1253
|
+
/* @__PURE__ */ jsx("button", { type: "button", title: "zoom out (ctrl+wheel)", onClick: () => setZoom(Math.max(0.2, eff / 1.25)), children: "\u2212" }),
|
|
1254
|
+
/* @__PURE__ */ jsxs("span", { className: "zoomer-pct", children: [
|
|
1255
|
+
Math.round(eff * 100),
|
|
1256
|
+
"%"
|
|
1257
|
+
] }),
|
|
1258
|
+
/* @__PURE__ */ jsx("button", { type: "button", title: "zoom in (ctrl+wheel)", onClick: () => setZoom(Math.min(2.5, eff * 1.25)), children: "\uFF0B" }),
|
|
1259
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: zoom === null ? "on" : "", title: "fit the whole org in view", onClick: () => setZoom(null), children: "fit" })
|
|
1260
|
+
] })
|
|
1261
|
+
] }),
|
|
1262
|
+
selected && /* @__PURE__ */ jsx(
|
|
1263
|
+
Dossier,
|
|
1264
|
+
{
|
|
1265
|
+
org: draft,
|
|
1266
|
+
id: selected,
|
|
1267
|
+
hasSnapshot,
|
|
1268
|
+
onUpdate,
|
|
1269
|
+
onAdd,
|
|
1270
|
+
onRemove,
|
|
1271
|
+
onSelect: setSelected,
|
|
1272
|
+
health
|
|
1273
|
+
}
|
|
1274
|
+
)
|
|
1275
|
+
] });
|
|
1276
|
+
}
|
|
1277
|
+
function BucketCount({ bucket }) {
|
|
1278
|
+
const api = useApi();
|
|
1279
|
+
const [n, setN] = useState(null);
|
|
1280
|
+
useEffect(() => {
|
|
1281
|
+
api(`/nodes?type=memory&cluster=${encodeURIComponent(bucket)}&limit=1`).then((j) => setN(j.total)).catch(() => setN(0));
|
|
1282
|
+
}, [bucket, api]);
|
|
1283
|
+
const v = useCountUp(n ?? 0);
|
|
1284
|
+
return /* @__PURE__ */ jsx("div", { className: "bk-n", children: n === null ? "\u2026" : v.toLocaleString() });
|
|
1285
|
+
}
|
|
1286
|
+
function BucketsScreen({ org, param, hasSnapshot }) {
|
|
1287
|
+
const api = useApi();
|
|
1288
|
+
const [discovered, setDiscovered] = useState(null);
|
|
1289
|
+
useEffect(() => {
|
|
1290
|
+
if (!hasSnapshot) {
|
|
1291
|
+
setDiscovered({});
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1294
|
+
api("/clusters?type=memory").then((j) => setDiscovered(j.clusters ?? {})).catch(() => setDiscovered({}));
|
|
1295
|
+
}, [hasSnapshot, api]);
|
|
1296
|
+
const buckets = useMemo(() => {
|
|
1297
|
+
const map = /* @__PURE__ */ new Map();
|
|
1298
|
+
for (const a of org.agents) {
|
|
1299
|
+
const slice = orgBootSlice(org, a.id);
|
|
1300
|
+
for (const b of slice?.buckets ?? []) {
|
|
1301
|
+
const arr = map.get(b) ?? [];
|
|
1302
|
+
arr.push(a);
|
|
1303
|
+
map.set(b, arr);
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
for (const b of Object.keys(discovered ?? {})) if (!map.has(b)) map.set(b, []);
|
|
1307
|
+
return [...map.entries()].sort(
|
|
1308
|
+
(x, y) => (y[1].length ? 1 : 0) - (x[1].length ? 1 : 0) || (discovered?.[y[0]] ?? 0) - (discovered?.[x[0]] ?? 0) || x[0].localeCompare(y[0])
|
|
1309
|
+
);
|
|
1310
|
+
}, [org, discovered]);
|
|
1311
|
+
const [items, setItems] = useState(null);
|
|
1312
|
+
useEffect(() => {
|
|
1313
|
+
setItems(null);
|
|
1314
|
+
if (!param || !hasSnapshot) return;
|
|
1315
|
+
api(`/nodes?type=memory&cluster=${encodeURIComponent(param)}&limit=500`).then((j) => {
|
|
1316
|
+
setItems([...j.nodes].sort((a, b) => nodeAt(b).localeCompare(nodeAt(a))));
|
|
1317
|
+
}).catch(() => setItems([]));
|
|
1318
|
+
}, [param, hasSnapshot, api]);
|
|
1319
|
+
if (param) {
|
|
1320
|
+
return /* @__PURE__ */ jsxs("div", { className: "screen", children: [
|
|
1321
|
+
/* @__PURE__ */ jsx("button", { className: "pnl-back", onClick: () => nav("/buckets"), children: "\u2190 all buckets" }),
|
|
1322
|
+
/* @__PURE__ */ jsxs("h2", { className: "scr-title", children: [
|
|
1323
|
+
/* @__PURE__ */ jsx("i", { className: "bk-dot", style: { ["--h"]: bucketHue(param) } }),
|
|
1324
|
+
" ",
|
|
1325
|
+
param
|
|
1326
|
+
] }),
|
|
1327
|
+
!hasSnapshot ? /* @__PURE__ */ jsxs("p", { className: "scr-empty", children: [
|
|
1328
|
+
"start with ",
|
|
1329
|
+
/* @__PURE__ */ jsx("code", { children: "--snapshot" }),
|
|
1330
|
+
" to browse this bucket's memories."
|
|
1331
|
+
] }) : items === null ? /* @__PURE__ */ jsx("p", { className: "scr-empty", children: "loading\u2026" }) : items.length === 0 ? /* @__PURE__ */ jsx("p", { className: "scr-empty", children: "this bucket is empty \u2014 nothing remembered here yet." }) : /* @__PURE__ */ jsx("div", { className: "mem-list", children: items.slice(0, 150).map((m) => {
|
|
1332
|
+
const when = relTime(nodeAt(m));
|
|
1333
|
+
return /* @__PURE__ */ jsxs("div", { className: "mem-row", children: [
|
|
1334
|
+
when && /* @__PURE__ */ jsx("span", { className: "mem-when", children: when }),
|
|
1335
|
+
/* @__PURE__ */ jsx("span", { className: "mem-label", children: m.label })
|
|
1336
|
+
] }, m.id);
|
|
1337
|
+
}) })
|
|
1338
|
+
] });
|
|
1339
|
+
}
|
|
1340
|
+
return /* @__PURE__ */ jsxs("div", { className: "screen", children: [
|
|
1341
|
+
/* @__PURE__ */ jsx("h2", { className: "scr-title", children: "memory buckets" }),
|
|
1342
|
+
/* @__PURE__ */ jsx("p", { className: "scr-sub", children: "every bucket in the organigram, who reaches it, and how much lives inside." }),
|
|
1343
|
+
buckets.length === 0 ? /* @__PURE__ */ jsxs("p", { className: "scr-empty", children: [
|
|
1344
|
+
"no buckets declared on any agent yet \u2014 add ",
|
|
1345
|
+
/* @__PURE__ */ jsx("code", { children: '"buckets"' }),
|
|
1346
|
+
" to agents in the org file."
|
|
1347
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "bk-grid", children: buckets.map(([b, agents], i) => /* @__PURE__ */ jsxs(
|
|
1348
|
+
"button",
|
|
1349
|
+
{
|
|
1350
|
+
className: "bk-card",
|
|
1351
|
+
style: { ["--h"]: bucketHue(b), animationDelay: `${i * 70}ms` },
|
|
1352
|
+
onClick: () => nav(`/buckets/${encodeURIComponent(b)}`),
|
|
1353
|
+
children: [
|
|
1354
|
+
/* @__PURE__ */ jsxs("div", { className: "bk-top", children: [
|
|
1355
|
+
/* @__PURE__ */ jsx("i", { className: "bk-dot" }),
|
|
1356
|
+
/* @__PURE__ */ jsx("span", { className: "bk-name", children: b })
|
|
1357
|
+
] }),
|
|
1358
|
+
hasSnapshot ? /* @__PURE__ */ jsx(BucketCount, { bucket: b }) : /* @__PURE__ */ jsx("div", { className: "bk-n dim", children: "\u2014" }),
|
|
1359
|
+
/* @__PURE__ */ jsx("div", { className: "bk-l", children: "memories" }),
|
|
1360
|
+
agents.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1361
|
+
/* @__PURE__ */ jsxs("div", { className: "bk-crew", children: [
|
|
1362
|
+
agents.slice(0, 7).map((a) => /* @__PURE__ */ jsx("span", { className: "bk-face", title: a.name, children: a.emoji || "\u{1F916}" }, a.id)),
|
|
1363
|
+
agents.length > 7 && /* @__PURE__ */ jsxs("span", { className: "bk-more", children: [
|
|
1364
|
+
"+",
|
|
1365
|
+
agents.length - 7
|
|
1366
|
+
] })
|
|
1367
|
+
] }),
|
|
1368
|
+
/* @__PURE__ */ jsxs("div", { className: "bk-agents", children: [
|
|
1369
|
+
agents.slice(0, 3).map((a) => a.name).join(" \xB7 "),
|
|
1370
|
+
agents.length > 3 ? ` +${agents.length - 3}` : ""
|
|
1371
|
+
] })
|
|
1372
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "bk-agents unassigned", children: "unassigned \u2014 no agent declares this bucket; add it to an agent's buckets to claim it" })
|
|
1373
|
+
]
|
|
1374
|
+
},
|
|
1375
|
+
b
|
|
1376
|
+
)) })
|
|
1377
|
+
] });
|
|
1378
|
+
}
|
|
1379
|
+
function ReportsScreen({ org, hasSnapshot }) {
|
|
1380
|
+
const api = useApi();
|
|
1381
|
+
const [rows, setRows] = useState(null);
|
|
1382
|
+
const [who, setWho] = useState("");
|
|
1383
|
+
const nameOf = useMemo(() => new Map(org.agents.map((a) => [a.id, a])), [org]);
|
|
1384
|
+
useEffect(() => {
|
|
1385
|
+
if (!hasSnapshot) return;
|
|
1386
|
+
fetchReports(api, null, 1e3).then(({ nodes }) => setRows(nodes)).catch(() => setRows([]));
|
|
1387
|
+
}, [hasSnapshot, api]);
|
|
1388
|
+
const agents = useMemo(() => [...new Set((rows ?? []).map((r) => r.cluster ?? ""))].filter(Boolean), [rows]);
|
|
1389
|
+
const shown = (rows ?? []).filter((r) => !who || r.cluster === who);
|
|
1390
|
+
const total = useCountUp(shown.length);
|
|
1391
|
+
if (!hasSnapshot)
|
|
1392
|
+
return /* @__PURE__ */ jsxs("div", { className: "screen", children: [
|
|
1393
|
+
/* @__PURE__ */ jsx("h2", { className: "scr-title", children: "reports" }),
|
|
1394
|
+
/* @__PURE__ */ jsxs("p", { className: "scr-empty", children: [
|
|
1395
|
+
"start with ",
|
|
1396
|
+
/* @__PURE__ */ jsx("code", { children: "--snapshot" }),
|
|
1397
|
+
" to see the portfolio timeline."
|
|
1398
|
+
] })
|
|
1399
|
+
] });
|
|
1400
|
+
return /* @__PURE__ */ jsxs("div", { className: "screen", children: [
|
|
1401
|
+
/* @__PURE__ */ jsxs("h2", { className: "scr-title", children: [
|
|
1402
|
+
"reports ",
|
|
1403
|
+
/* @__PURE__ */ jsx("span", { className: "scr-count", children: total })
|
|
1404
|
+
] }),
|
|
1405
|
+
/* @__PURE__ */ jsx("p", { className: "scr-sub", children: "what the fleet has been closing, newest first." }),
|
|
1406
|
+
agents.length > 1 && /* @__PURE__ */ jsxs("div", { className: "rep-filter", children: [
|
|
1407
|
+
/* @__PURE__ */ jsx(Chip, { tone: who === "" ? "" : "alt", onClick: () => setWho(""), children: "everyone" }),
|
|
1408
|
+
agents.map((a) => /* @__PURE__ */ jsxs(Chip, { tone: who === a ? "" : "alt", onClick: () => setWho(who === a ? "" : a), children: [
|
|
1409
|
+
nameOf.get(a)?.emoji ?? "",
|
|
1410
|
+
" ",
|
|
1411
|
+
nameOf.get(a)?.name ?? a
|
|
1412
|
+
] }, a))
|
|
1413
|
+
] }),
|
|
1414
|
+
rows === null ? /* @__PURE__ */ jsx("p", { className: "scr-empty", children: "loading\u2026" }) : shown.length === 0 ? /* @__PURE__ */ jsxs("p", { className: "scr-empty", children: [
|
|
1415
|
+
"no reports filed yet \u2014 they land here as agents close work (node type ",
|
|
1416
|
+
/* @__PURE__ */ jsx("code", { children: "report" }),
|
|
1417
|
+
")."
|
|
1418
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "timeline", children: [
|
|
1419
|
+
shown.slice(0, 100).map((r) => {
|
|
1420
|
+
const a = r.cluster ? nameOf.get(r.cluster) : void 0;
|
|
1421
|
+
const when = relTime(nodeAt(r));
|
|
1422
|
+
const sum = nodeSummary(r);
|
|
1423
|
+
return /* @__PURE__ */ jsxs("div", { className: "tl-row", style: { ["--h"]: bucketHue(r.cluster ?? "x") }, children: [
|
|
1424
|
+
/* @__PURE__ */ jsx("div", { className: "tl-dot" }),
|
|
1425
|
+
/* @__PURE__ */ jsxs("div", { className: "tl-body", children: [
|
|
1426
|
+
/* @__PURE__ */ jsxs("div", { className: "tl-top", children: [
|
|
1427
|
+
/* @__PURE__ */ jsx("span", { className: "tl-ava", children: a?.emoji ?? "\u{1F916}" }),
|
|
1428
|
+
/* @__PURE__ */ jsx("span", { className: "tl-agent", children: a?.name ?? r.cluster ?? "unknown" }),
|
|
1429
|
+
when && /* @__PURE__ */ jsx("span", { className: "tl-when", children: when })
|
|
1430
|
+
] }),
|
|
1431
|
+
/* @__PURE__ */ jsx("p", { className: "tl-sum", children: sum || r.label })
|
|
1432
|
+
] })
|
|
1433
|
+
] }, r.id);
|
|
1434
|
+
}),
|
|
1435
|
+
shown.length > 100 && /* @__PURE__ */ jsxs("p", { className: "scr-empty", children: [
|
|
1436
|
+
"showing the latest 100 of ",
|
|
1437
|
+
shown.length,
|
|
1438
|
+
"."
|
|
1439
|
+
] })
|
|
1440
|
+
] })
|
|
1441
|
+
] });
|
|
1442
|
+
}
|
|
1443
|
+
function RulesScreen({ org }) {
|
|
1444
|
+
const rules = useMemo(() => {
|
|
1445
|
+
const declared = /* @__PURE__ */ new Map();
|
|
1446
|
+
for (const a of org.agents) for (const r of a.rules ?? []) {
|
|
1447
|
+
const arr = declared.get(r) ?? [];
|
|
1448
|
+
arr.push(a.id);
|
|
1449
|
+
declared.set(r, arr);
|
|
1450
|
+
}
|
|
1451
|
+
const inherited = /* @__PURE__ */ new Map();
|
|
1452
|
+
for (const a of org.agents) {
|
|
1453
|
+
const own = new Set(a.rules ?? []);
|
|
1454
|
+
const slice = orgBootSlice(org, a.id);
|
|
1455
|
+
for (const r of slice?.rules ?? []) if (!own.has(r)) {
|
|
1456
|
+
const arr = inherited.get(r) ?? [];
|
|
1457
|
+
arr.push(a.id);
|
|
1458
|
+
inherited.set(r, arr);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
const name = (id) => org.agents.find((a) => a.id === id)?.name ?? id;
|
|
1462
|
+
return [...declared.entries()].sort((x, y) => x[0].localeCompare(y[0])).map(([r, by]) => ({
|
|
1463
|
+
rule: r,
|
|
1464
|
+
global: by.includes(org.root),
|
|
1465
|
+
declaredBy: by.map(name),
|
|
1466
|
+
inheritedBy: (inherited.get(r) ?? []).map(name)
|
|
1467
|
+
}));
|
|
1468
|
+
}, [org]);
|
|
1469
|
+
const maxBind = Math.max(1, org.agents.length - 1);
|
|
1470
|
+
return /* @__PURE__ */ jsxs("div", { className: "screen", children: [
|
|
1471
|
+
/* @__PURE__ */ jsxs("h2", { className: "scr-title", children: [
|
|
1472
|
+
"rules ",
|
|
1473
|
+
/* @__PURE__ */ jsx("span", { className: "scr-count", children: rules.length })
|
|
1474
|
+
] }),
|
|
1475
|
+
/* @__PURE__ */ jsx("p", { className: "scr-sub", children: "every rule in the organigram \u2014 who declares it, and who lives under it." }),
|
|
1476
|
+
rules.length === 0 ? /* @__PURE__ */ jsxs("p", { className: "scr-empty", children: [
|
|
1477
|
+
"no rules declared yet \u2014 add ",
|
|
1478
|
+
/* @__PURE__ */ jsx("code", { children: '"rules"' }),
|
|
1479
|
+
" refs to agents in the org file."
|
|
1480
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "rule-list", children: rules.map((r, i) => /* @__PURE__ */ jsxs("div", { className: "rule-card", style: { animationDelay: `${i * 60}ms` }, children: [
|
|
1481
|
+
/* @__PURE__ */ jsxs("div", { className: "rule-top", children: [
|
|
1482
|
+
/* @__PURE__ */ jsx("span", { className: "rule-ref", children: r.rule }),
|
|
1483
|
+
r.global && /* @__PURE__ */ jsx("span", { className: "rule-scope", children: "global \u2014 binds everyone" })
|
|
1484
|
+
] }),
|
|
1485
|
+
/* @__PURE__ */ jsxs("div", { className: "rule-meta", children: [
|
|
1486
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
1487
|
+
"declared by ",
|
|
1488
|
+
/* @__PURE__ */ jsx("b", { children: r.declaredBy.join(", ") })
|
|
1489
|
+
] }),
|
|
1490
|
+
r.inheritedBy.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
|
|
1491
|
+
" \xB7 binds ",
|
|
1492
|
+
/* @__PURE__ */ jsx("b", { children: r.inheritedBy.length }),
|
|
1493
|
+
" below: ",
|
|
1494
|
+
r.inheritedBy.join(", ")
|
|
1495
|
+
] })
|
|
1496
|
+
] }),
|
|
1497
|
+
/* @__PURE__ */ jsx("div", { className: "rule-bar", children: /* @__PURE__ */ jsx("i", { style: { width: `${Math.round(r.inheritedBy.length / maxBind * 100)}%` } }) })
|
|
1498
|
+
] }, r.rule)) })
|
|
1499
|
+
] });
|
|
1500
|
+
}
|
|
1501
|
+
function GraphScreen({ hasSnapshot }) {
|
|
1502
|
+
if (!hasSnapshot)
|
|
1503
|
+
return /* @__PURE__ */ jsxs("div", { className: "screen", children: [
|
|
1504
|
+
/* @__PURE__ */ jsx("h2", { className: "scr-title", children: "graph" }),
|
|
1505
|
+
/* @__PURE__ */ jsxs("p", { className: "scr-empty", children: [
|
|
1506
|
+
"start with ",
|
|
1507
|
+
/* @__PURE__ */ jsx("code", { children: "--snapshot graph.json" }),
|
|
1508
|
+
" and the 3D brain renders right here."
|
|
1509
|
+
] })
|
|
1510
|
+
] });
|
|
1511
|
+
return /* @__PURE__ */ jsx("div", { className: "graph-wrap", children: /* @__PURE__ */ jsx("iframe", { className: "graph-frame", src: "/view/?file=/snapshot.json", title: "Booboo 3D brain" }) });
|
|
1512
|
+
}
|
|
1513
|
+
function App() {
|
|
1514
|
+
const api = useApi();
|
|
1515
|
+
const [tab, param] = useRoute();
|
|
1516
|
+
const [saved, setSaved] = useState(null);
|
|
1517
|
+
const [draft, setDraft] = useState(null);
|
|
1518
|
+
const [selected, setSelected] = useState(null);
|
|
1519
|
+
const [dragId, setDragId] = useState(null);
|
|
1520
|
+
const [stats, setStats] = useState(null);
|
|
1521
|
+
const [err, setErr] = useState("");
|
|
1522
|
+
const [applying, setApplying] = useState(false);
|
|
1523
|
+
const [totals, setTotals] = useState(null);
|
|
1524
|
+
useEffect(() => {
|
|
1525
|
+
api("/org").then((o) => {
|
|
1526
|
+
setSaved(o);
|
|
1527
|
+
setDraft(o);
|
|
1528
|
+
setSelected(o.root);
|
|
1529
|
+
}).catch(() => setErr("Can't load the organigram \u2014 is `booboo panel --org` running?"));
|
|
1530
|
+
api("/stats").then(setStats).catch(() => setStats(null));
|
|
1531
|
+
Promise.all([
|
|
1532
|
+
api("/nodes?type=memory&limit=1").then((j) => j.total),
|
|
1533
|
+
fetchReports(api, null, 1).then((r) => r.total)
|
|
1534
|
+
]).then(([mem, rep]) => setTotals({ mem, rep })).catch(() => setTotals(null));
|
|
1535
|
+
}, [api]);
|
|
1536
|
+
const changes = useMemo(() => {
|
|
1537
|
+
if (!saved || !draft) return [];
|
|
1538
|
+
const before = new Map(saved.agents.map((a) => [a.id, a]));
|
|
1539
|
+
const after = new Map(draft.agents.map((a) => [a.id, a]));
|
|
1540
|
+
const name = (id) => after.get(id)?.name ?? before.get(id)?.name ?? id;
|
|
1541
|
+
const noParent = ({ parent: _p, ...rest }) => rest;
|
|
1542
|
+
const out = [];
|
|
1543
|
+
for (const a of draft.agents) {
|
|
1544
|
+
const b = before.get(a.id);
|
|
1545
|
+
if (!b) {
|
|
1546
|
+
out.push(`\uFF0B ${a.name} under ${a.parent ? name(a.parent) : "root"}`);
|
|
1547
|
+
continue;
|
|
1548
|
+
}
|
|
1549
|
+
if ((b.parent ?? null) !== (a.parent ?? null)) out.push(`${a.name} \u2192 now under ${a.parent ? name(a.parent) : "root"}`);
|
|
1550
|
+
if (JSON.stringify(noParent(b)) !== JSON.stringify(noParent(a))) out.push(`\u270E ${a.name} edited`);
|
|
1551
|
+
}
|
|
1552
|
+
for (const b of saved.agents) if (!after.has(b.id)) out.push(`\u2212 ${b.name} removed`);
|
|
1553
|
+
return out;
|
|
1554
|
+
}, [saved, draft]);
|
|
1555
|
+
const updateAgent = useCallback((id, patch) => {
|
|
1556
|
+
setDraft((d) => d ? { ...d, agents: d.agents.map((a) => a.id === id ? { ...a, ...patch } : a) } : d);
|
|
1557
|
+
}, []);
|
|
1558
|
+
const addAgent = useCallback(
|
|
1559
|
+
(parentId) => {
|
|
1560
|
+
if (!draft) return;
|
|
1561
|
+
const nm = window.prompt("Name for the new agent:");
|
|
1562
|
+
if (!nm || !nm.trim()) return;
|
|
1563
|
+
const base = slugify(nm) || "agent";
|
|
1564
|
+
let newId = base;
|
|
1565
|
+
let i = 2;
|
|
1566
|
+
while (draft.agents.some((a) => a.id === newId)) newId = `${base}-${i++}`;
|
|
1567
|
+
setDraft({ ...draft, agents: [...draft.agents, { id: newId, name: nm.trim(), emoji: "\u{1F916}", parent: parentId }] });
|
|
1568
|
+
setSelected(newId);
|
|
1569
|
+
},
|
|
1570
|
+
[draft]
|
|
1571
|
+
);
|
|
1572
|
+
const removeAgent = useCallback(
|
|
1573
|
+
(id) => {
|
|
1574
|
+
if (!draft || id === draft.root) return;
|
|
1575
|
+
const ag = draft.agents.find((a) => a.id === id);
|
|
1576
|
+
if (!ag) return;
|
|
1577
|
+
const parentName = draft.agents.find((a) => a.id === ag.parent)?.name ?? "the root";
|
|
1578
|
+
const kids = draft.agents.filter((a) => a.parent === id).length;
|
|
1579
|
+
if (!window.confirm(`Remove ${ag.name}?${kids ? ` Its ${kids} direct report${kids > 1 ? "s" : ""} move up to ${parentName}.` : ""}`)) return;
|
|
1580
|
+
setDraft({
|
|
1581
|
+
...draft,
|
|
1582
|
+
agents: draft.agents.filter((a) => a.id !== id).map((a) => a.parent === id ? { ...a, parent: ag.parent ?? draft.root } : a)
|
|
1583
|
+
});
|
|
1584
|
+
setSelected(ag.parent ?? draft.root);
|
|
1585
|
+
},
|
|
1586
|
+
[draft]
|
|
1587
|
+
);
|
|
1588
|
+
const isDescendant = useCallback((org, maybeChild, of) => {
|
|
1589
|
+
const byId = new Map(org.agents.map((a) => [a.id, a]));
|
|
1590
|
+
let cur = byId.get(maybeChild);
|
|
1591
|
+
const guard = /* @__PURE__ */ new Set();
|
|
1592
|
+
while (cur?.parent && !guard.has(cur.id)) {
|
|
1593
|
+
guard.add(cur.id);
|
|
1594
|
+
if (cur.parent === of) return true;
|
|
1595
|
+
cur = byId.get(cur.parent);
|
|
1596
|
+
}
|
|
1597
|
+
return false;
|
|
1598
|
+
}, []);
|
|
1599
|
+
const dropOn = useCallback(
|
|
1600
|
+
(targetId) => {
|
|
1601
|
+
if (!draft || !dragId || dragId === targetId) return;
|
|
1602
|
+
if (dragId === draft.root) return;
|
|
1603
|
+
if (isDescendant(draft, targetId, dragId)) return;
|
|
1604
|
+
setDraft({ ...draft, agents: draft.agents.map((a) => a.id === dragId ? { ...a, parent: targetId } : a) });
|
|
1605
|
+
setDragId(null);
|
|
1606
|
+
},
|
|
1607
|
+
[draft, dragId, isDescendant]
|
|
1608
|
+
);
|
|
1609
|
+
const apply = useCallback(async () => {
|
|
1610
|
+
if (!draft) return;
|
|
1611
|
+
setApplying(true);
|
|
1612
|
+
setErr("");
|
|
1613
|
+
try {
|
|
1614
|
+
await api("/org", { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify(draft) });
|
|
1615
|
+
setSaved(draft);
|
|
1616
|
+
} catch (e) {
|
|
1617
|
+
setErr(`apply failed: ${e?.errors?.join("; ") ?? "unknown error"}`);
|
|
1618
|
+
} finally {
|
|
1619
|
+
setApplying(false);
|
|
1620
|
+
}
|
|
1621
|
+
}, [draft, api]);
|
|
1622
|
+
const agentCount = useCountUp(draft?.agents.length ?? 0);
|
|
1623
|
+
const nodeCount = useCountUp(stats?.nodes ?? 0, 1200);
|
|
1624
|
+
const memTotal = useCountUp(totals?.mem ?? 0, 1100);
|
|
1625
|
+
const repTotal = useCountUp(totals?.rep ?? 0, 1300);
|
|
1626
|
+
const [theme, toggleTheme] = useTheme();
|
|
1627
|
+
if (err && !draft) return /* @__PURE__ */ jsx("div", { className: "pnl-fatal", children: err });
|
|
1628
|
+
if (!draft) return /* @__PURE__ */ jsx("div", { className: "pnl-fatal calm", children: "waking the organigram\u2026" });
|
|
1629
|
+
return /* @__PURE__ */ jsxs("div", { className: "pnl", children: [
|
|
1630
|
+
/* @__PURE__ */ jsx("div", { className: "pnl-aurora", "aria-hidden": true }),
|
|
1631
|
+
/* @__PURE__ */ jsxs("header", { className: "bar", children: [
|
|
1632
|
+
/* @__PURE__ */ jsxs("div", { className: "bar-brand", children: [
|
|
1633
|
+
"\u{1F43E} ",
|
|
1634
|
+
/* @__PURE__ */ jsx("b", { children: draft.title || "the organigram" })
|
|
1635
|
+
] }),
|
|
1636
|
+
/* @__PURE__ */ jsxs("div", { className: "bar-stats", children: [
|
|
1637
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
1638
|
+
/* @__PURE__ */ jsx("b", { children: agentCount }),
|
|
1639
|
+
" agents"
|
|
1640
|
+
] }),
|
|
1641
|
+
stats && /* @__PURE__ */ jsxs("span", { children: [
|
|
1642
|
+
/* @__PURE__ */ jsx("b", { children: nodeCount.toLocaleString() }),
|
|
1643
|
+
" nodes"
|
|
1644
|
+
] }),
|
|
1645
|
+
totals && /* @__PURE__ */ jsxs("span", { onClick: () => nav("/buckets"), className: "tap", children: [
|
|
1646
|
+
/* @__PURE__ */ jsx("b", { children: memTotal.toLocaleString() }),
|
|
1647
|
+
" memories"
|
|
1648
|
+
] }),
|
|
1649
|
+
totals && /* @__PURE__ */ jsxs("span", { onClick: () => nav("/reports"), className: "tap", children: [
|
|
1650
|
+
/* @__PURE__ */ jsx("b", { children: repTotal.toLocaleString() }),
|
|
1651
|
+
" reports"
|
|
1652
|
+
] })
|
|
1653
|
+
] }),
|
|
1654
|
+
/* @__PURE__ */ jsxs("div", { className: "bar-actions", children: [
|
|
1655
|
+
/* @__PURE__ */ jsx("button", { className: "btn ghost theme-toggle", title: "light / dark", "aria-label": "toggle light or dark theme", onClick: toggleTheme, children: theme === "dark" ? "\u2600" : "\u263E" }),
|
|
1656
|
+
changes.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1657
|
+
/* @__PURE__ */ jsxs("span", { className: "bar-draft", children: [
|
|
1658
|
+
changes.length,
|
|
1659
|
+
" unapplied change",
|
|
1660
|
+
changes.length > 1 ? "s" : ""
|
|
1661
|
+
] }),
|
|
1662
|
+
/* @__PURE__ */ jsx("button", { className: "btn ghost", onClick: () => setDraft(saved), children: "discard" }),
|
|
1663
|
+
/* @__PURE__ */ jsx("button", { className: "btn primary", disabled: applying, onClick: apply, children: applying ? "applying\u2026" : "apply \u2192 org file" })
|
|
1664
|
+
] }) : /* @__PURE__ */ jsx("span", { className: "bar-ok", children: "\u25CF in sync with the org file" })
|
|
1665
|
+
] })
|
|
1666
|
+
] }),
|
|
1667
|
+
/* @__PURE__ */ jsx("nav", { className: "tabs", children: TABS.map((t) => /* @__PURE__ */ jsxs("button", { className: `tab${tab === t.id ? " on" : ""}`, onClick: () => nav(`/${t.id === "org" ? "" : t.id}`), children: [
|
|
1668
|
+
/* @__PURE__ */ jsx("span", { className: "tab-glyph", children: t.glyph }),
|
|
1669
|
+
" ",
|
|
1670
|
+
t.label
|
|
1671
|
+
] }, t.id)) }),
|
|
1672
|
+
changes.length > 0 && tab === "org" && /* @__PURE__ */ jsx("div", { className: "pending", children: changes.map((c) => /* @__PURE__ */ jsx("span", { className: "pending-item", children: c }, c)) }),
|
|
1673
|
+
err && /* @__PURE__ */ jsx("div", { className: "pnl-err", children: err }),
|
|
1674
|
+
/* @__PURE__ */ jsxs("div", { className: "content", children: [
|
|
1675
|
+
tab === "org" && /* @__PURE__ */ jsx(
|
|
1676
|
+
OrgScreen,
|
|
1677
|
+
{
|
|
1678
|
+
draft,
|
|
1679
|
+
selected,
|
|
1680
|
+
dragId,
|
|
1681
|
+
setSelected,
|
|
1682
|
+
setDragId,
|
|
1683
|
+
dropOn,
|
|
1684
|
+
hasSnapshot: !!stats,
|
|
1685
|
+
onUpdate: updateAgent,
|
|
1686
|
+
onAdd: addAgent,
|
|
1687
|
+
onRemove: removeAgent
|
|
1688
|
+
}
|
|
1689
|
+
),
|
|
1690
|
+
tab === "buckets" && /* @__PURE__ */ jsx(BucketsScreen, { org: draft, param, hasSnapshot: !!stats }),
|
|
1691
|
+
tab === "reports" && /* @__PURE__ */ jsx(ReportsScreen, { org: draft, hasSnapshot: !!stats }),
|
|
1692
|
+
tab === "rules" && /* @__PURE__ */ jsx(RulesScreen, { org: draft }),
|
|
1693
|
+
tab === "graph" && /* @__PURE__ */ jsx(GraphScreen, { hasSnapshot: !!stats })
|
|
1694
|
+
] }, tab + (param ?? ""))
|
|
1695
|
+
] });
|
|
1696
|
+
}
|
|
1697
|
+
function Panel({ api = defaultApi } = {}) {
|
|
1698
|
+
return /* @__PURE__ */ jsxs(ApiCtx.Provider, { value: api, children: [
|
|
1699
|
+
/* @__PURE__ */ jsx("style", { children: PANEL_CSS }),
|
|
1700
|
+
/* @__PURE__ */ jsx(App, {})
|
|
1701
|
+
] });
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1
1704
|
// src/index.ts
|
|
2
|
-
var PANEL_VERSION = "0.
|
|
1705
|
+
var PANEL_VERSION = "0.4.0";
|
|
3
1706
|
export {
|
|
4
|
-
PANEL_VERSION
|
|
1707
|
+
PANEL_VERSION,
|
|
1708
|
+
Panel
|
|
5
1709
|
};
|