@korso/shepherd-ui 0.1.0 → 0.2.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/ShepherdProvider.d.ts +12 -0
- package/dist/ShepherdProvider.js +33 -0
- package/dist/ShepherdProvider.test.d.ts +1 -0
- package/dist/ShepherdProvider.test.js +47 -0
- package/dist/ShepherdRoot.d.ts +9 -0
- package/dist/ShepherdRoot.js +88 -0
- package/dist/ShepherdRoot.routing.test.d.ts +1 -0
- package/dist/ShepherdRoot.routing.test.js +61 -0
- package/dist/ShepherdRoot.test.d.ts +1 -0
- package/dist/ShepherdRoot.test.js +37 -0
- package/dist/app/assets/index-CDOCIg6s.js +11 -0
- package/dist/app/index.html +12 -0
- package/dist/client.d.ts +107 -0
- package/dist/client.js +238 -0
- package/dist/client.test.d.ts +1 -0
- package/dist/client.test.js +298 -0
- package/dist/components/ActiveList.d.ts +22 -0
- package/dist/components/ActiveList.js +59 -0
- package/dist/components/Chat.d.ts +30 -0
- package/dist/components/Chat.js +61 -0
- package/dist/components/Composer.d.ts +37 -0
- package/dist/components/Composer.js +146 -0
- package/dist/components/Crew.d.ts +23 -0
- package/dist/components/Crew.js +31 -0
- package/dist/components/Dashboard.d.ts +34 -0
- package/dist/components/Dashboard.js +209 -0
- package/dist/components/DoneList.d.ts +29 -0
- package/dist/components/DoneList.js +50 -0
- package/dist/components/RepoSelect.d.ts +38 -0
- package/dist/components/RepoSelect.js +56 -0
- package/dist/components/Territory.d.ts +21 -0
- package/dist/components/Territory.js +21 -0
- package/dist/config/ConnectAgent.d.ts +10 -0
- package/dist/config/ConnectAgent.js +119 -0
- package/dist/config/ConnectAgent.test.d.ts +1 -0
- package/dist/config/ConnectAgent.test.js +92 -0
- package/dist/config/EmptyState.d.ts +12 -0
- package/dist/config/EmptyState.js +4 -0
- package/dist/config/EmptyState.test.d.ts +1 -0
- package/dist/config/EmptyState.test.js +32 -0
- package/dist/config/Members.d.ts +10 -0
- package/dist/config/Members.js +83 -0
- package/dist/config/Members.test.d.ts +1 -0
- package/dist/config/Members.test.js +66 -0
- package/dist/config/Workspaces.d.ts +12 -0
- package/dist/config/Workspaces.js +96 -0
- package/dist/config/Workspaces.test.d.ts +1 -0
- package/dist/config/Workspaces.test.js +90 -0
- package/dist/config/index.d.ts +8 -0
- package/dist/config/index.js +6 -0
- package/dist/context.d.ts +28 -0
- package/dist/context.js +36 -0
- package/dist/index.cjs +5289 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +149 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/Dashboard-CG6KeFQ3.js +1214 -0
- package/dist/lib/index.d.ts +438 -16
- package/dist/lib/index.js +455 -6
- package/dist/lib/selfhost.js +9 -9
- package/dist/lib/styles.css +27 -0
- package/dist/logic.d.ts +208 -0
- package/dist/logic.js +372 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +11 -0
- package/dist/selfhost/assets/{index-tSyzirZa.css → index-BZmImfYZ.css} +1 -1
- package/dist/selfhost/assets/index-CS268KSw.js +40 -0
- package/dist/selfhost/index.html +2 -2
- package/dist/selfhost.d.ts +22 -0
- package/dist/selfhost.js +97 -0
- package/dist/test/mockClient.d.ts +6 -0
- package/dist/test/mockClient.js +45 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/test/setup.js +2 -0
- package/dist/useLandscapePolling.d.ts +63 -0
- package/dist/useLandscapePolling.js +129 -0
- package/dist/views/Chat.d.ts +5 -0
- package/dist/views/Chat.js +60 -0
- package/dist/views/Chat.test.d.ts +1 -0
- package/dist/views/Chat.test.js +92 -0
- package/dist/views/Config.d.ts +12 -0
- package/dist/views/Config.js +6 -0
- package/dist/views/Tasks.d.ts +5 -0
- package/dist/views/Tasks.js +75 -0
- package/dist/views/Tasks.test.d.ts +1 -0
- package/dist/views/Tasks.test.js +115 -0
- package/dist/views/useLandscape.d.ts +14 -0
- package/dist/views/useLandscape.js +74 -0
- package/dist/views/useLandscape.test.d.ts +1 -0
- package/dist/views/useLandscape.test.js +101 -0
- package/dist/views/wallboard.d.ts +46 -0
- package/dist/views/wallboard.js +209 -0
- package/dist/views/wallboard.test.d.ts +1 -0
- package/dist/views/wallboard.test.js +143 -0
- package/package.json +1 -1
- package/dist/lib/Dashboard-CB6SL-J2.js +0 -1064
- package/dist/selfhost/assets/index-BBx3vo2Y.js +0 -40
|
@@ -1,1064 +0,0 @@
|
|
|
1
|
-
var pe = Object.defineProperty;
|
|
2
|
-
var fe = (e, n, r) => n in e ? pe(e, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[n] = r;
|
|
3
|
-
var J = (e, n, r) => fe(e, typeof n != "symbol" ? n + "" : n, r);
|
|
4
|
-
import { jsx as s, jsxs as m, Fragment as ge } from "react/jsx-runtime";
|
|
5
|
-
import { createContext as be, useContext as ve, useState as y, useRef as E, useCallback as k, useEffect as V, Fragment as _e, useLayoutEffect as Ne } from "react";
|
|
6
|
-
import { z as t } from "zod";
|
|
7
|
-
const $ = t.string(), O = t.number(), ye = t.object({
|
|
8
|
-
agentName: t.string(),
|
|
9
|
-
human: t.string(),
|
|
10
|
-
branch: t.string(),
|
|
11
|
-
kind: t.enum(["committed", "uncommitted"]),
|
|
12
|
-
commitSha: t.string().nullable(),
|
|
13
|
-
message: t.string().nullable(),
|
|
14
|
-
paths: t.array(t.string()).min(1),
|
|
15
|
-
authorIsLive: t.boolean(),
|
|
16
|
-
authorLastActiveAt: $,
|
|
17
|
-
updatedAt: $
|
|
18
|
-
}), ke = t.object({
|
|
19
|
-
kind: t.enum(["committed", "uncommitted"]),
|
|
20
|
-
// A git object id (lowercase hex, 4–64 chars) for `committed` entries, or null
|
|
21
|
-
// for `uncommitted`. This value is forwarded by the hub to OTHER clients, which
|
|
22
|
-
// feed it straight into local `git` argument vectors (isAncestor/hasCommit/
|
|
23
|
-
// changedLineRanges). Validating the shape at the wire boundary stops an
|
|
24
|
-
// attacker-controlled, flag-like value (e.g. "--output=...") from being parsed
|
|
25
|
-
// by git as an option on a teammate's machine (argument injection). gitContext
|
|
26
|
-
// re-validates defensively as well.
|
|
27
|
-
sha: t.string().regex(/^[0-9a-f]{4,64}$/).nullable(),
|
|
28
|
-
message: t.string().nullable(),
|
|
29
|
-
paths: t.array(t.string()).min(1).max(500)
|
|
30
|
-
}), X = t.object({
|
|
31
|
-
branch: t.string(),
|
|
32
|
-
baseBranch: t.string(),
|
|
33
|
-
head: t.string(),
|
|
34
|
-
truncated: t.boolean().default(!1),
|
|
35
|
-
// The only producer (gitContext.unlandedCommits) emits at most MAX_COMMITS
|
|
36
|
-
// (100) committed entries + 1 uncommitted, so this ceiling is generous. If
|
|
37
|
-
// MAX_COMMITS is ever raised above ~599, raise this in lockstep or the hub
|
|
38
|
-
// will start 400-rejecting otherwise-valid reports.
|
|
39
|
-
entries: t.array(ke).max(600)
|
|
40
|
-
}), q = t.object({
|
|
41
|
-
workItemId: t.string().uuid(),
|
|
42
|
-
agentName: t.string(),
|
|
43
|
-
human: t.string().min(1),
|
|
44
|
-
intent: t.string().min(1).max(2048),
|
|
45
|
-
pathGlobs: t.array(t.string().min(1).max(512)).min(1).max(64),
|
|
46
|
-
// ISO timestamp string; see IsoTimestamp note above
|
|
47
|
-
expiresAt: $
|
|
48
|
-
}), U = t.object({
|
|
49
|
-
// bigint PK serialised as number; see DbId note above
|
|
50
|
-
id: O,
|
|
51
|
-
fromAgentName: t.string(),
|
|
52
|
-
fromHuman: t.string().min(1),
|
|
53
|
-
body: t.string().min(1).max(8192),
|
|
54
|
-
targetAgentName: t.string().nullable(),
|
|
55
|
-
// ISO timestamp string; see IsoTimestamp note above
|
|
56
|
-
createdAt: $
|
|
57
|
-
}), ce = t.object({
|
|
58
|
-
conflicts: t.array(q),
|
|
59
|
-
activeClaims: t.array(q),
|
|
60
|
-
// The caller's OWN active claims. `activeClaims` deliberately excludes the
|
|
61
|
-
// caller's session, so without this an agent has no way to confirm its own
|
|
62
|
-
// claim is live. Optional with a default so an older client talking to a
|
|
63
|
-
// newer hub (or vice-versa) never fails validation on its absence.
|
|
64
|
-
yourClaims: t.array(q).default([]),
|
|
65
|
-
announcements: t.array(U),
|
|
66
|
-
// Per-agent change records for the workspace. Defaulted for version-skew safety.
|
|
67
|
-
changeRecords: t.array(ye).default([])
|
|
68
|
-
}), Ae = t.object({
|
|
69
|
-
name: t.string(),
|
|
70
|
-
human: t.string(),
|
|
71
|
-
program: t.string(),
|
|
72
|
-
// model is nullable in the DB (may be unknown when an agent first joins).
|
|
73
|
-
model: t.string().nullable(),
|
|
74
|
-
// repo/branch/lastHeartbeatAt come from the agent's most-recent session and
|
|
75
|
-
// are null when the agent has no session yet.
|
|
76
|
-
repo: t.string().nullable(),
|
|
77
|
-
branch: t.string().nullable(),
|
|
78
|
-
lastHeartbeatAt: $.nullable(),
|
|
79
|
-
presence: t.enum(["live", "offline"])
|
|
80
|
-
}), we = t.enum(["active", "done", "dropped"]), Se = t.object({
|
|
81
|
-
agentName: t.string(),
|
|
82
|
-
program: t.string(),
|
|
83
|
-
model: t.string().nullable(),
|
|
84
|
-
repo: t.string(),
|
|
85
|
-
intent: t.string(),
|
|
86
|
-
pathGlobs: t.array(t.string()),
|
|
87
|
-
status: we,
|
|
88
|
-
createdAt: $,
|
|
89
|
-
endedAt: $.nullable()
|
|
90
|
-
}), Ce = t.object({
|
|
91
|
-
fromAgentName: t.string(),
|
|
92
|
-
fromHuman: t.string(),
|
|
93
|
-
body: t.string(),
|
|
94
|
-
targetAgentName: t.string().nullable(),
|
|
95
|
-
repo: t.string(),
|
|
96
|
-
// True when the message was sent by the human operator from the dashboard
|
|
97
|
-
// (no agent session). The dashboard renders these as "me" (right-aligned).
|
|
98
|
-
// Defaulted for version-skew safety with older hubs.
|
|
99
|
-
fromAdmin: t.boolean().default(!1),
|
|
100
|
-
// True when an agent addressed the message TO the operator (the mirror of
|
|
101
|
-
// fromAdmin). The dashboard renders these as "<agent> → admin". Not delivered
|
|
102
|
-
// to other agents. Defaulted for version-skew safety with older hubs.
|
|
103
|
-
toAdmin: t.boolean().default(!1),
|
|
104
|
-
createdAt: $
|
|
105
|
-
}), $e = t.object({
|
|
106
|
-
agents: t.array(Ae),
|
|
107
|
-
tasks: t.array(Se),
|
|
108
|
-
announcements: t.array(Ce),
|
|
109
|
-
// The server's clock, so the client computes "expires in / last seen" against
|
|
110
|
-
// the hub rather than the (possibly skewed) browser clock.
|
|
111
|
-
serverTime: $
|
|
112
|
-
});
|
|
113
|
-
t.object({
|
|
114
|
-
body: t.string().min(1).max(8192),
|
|
115
|
-
// Direct-message a single agent (by the exact name shown in the landscape).
|
|
116
|
-
// Absent/null => broadcast. The hub resolves the target's repo server-side.
|
|
117
|
-
targetAgentName: t.string().min(1).nullable().optional(),
|
|
118
|
-
// For a broadcast, the repo to scope the message to (matches the dashboard's
|
|
119
|
-
// selected repo). Absent/null => fan out to every repo in the workspace.
|
|
120
|
-
// Ignored for a DM (the target's own repo is used).
|
|
121
|
-
repo: t.string().min(1).nullable().optional()
|
|
122
|
-
});
|
|
123
|
-
const De = t.object({
|
|
124
|
-
ok: t.literal(!0),
|
|
125
|
-
// One id per inserted row: a single id for a DM or repo-scoped broadcast, or
|
|
126
|
-
// several when an all-repos broadcast fans out across repos.
|
|
127
|
-
announcementIds: t.array(O)
|
|
128
|
-
});
|
|
129
|
-
t.object({
|
|
130
|
-
workspace: t.string().min(1),
|
|
131
|
-
repo: t.string().min(1),
|
|
132
|
-
branch: t.string().min(1),
|
|
133
|
-
human: t.string().min(1),
|
|
134
|
-
program: t.string().min(1),
|
|
135
|
-
model: t.string().min(1).optional()
|
|
136
|
-
});
|
|
137
|
-
t.object({
|
|
138
|
-
agentName: t.string(),
|
|
139
|
-
sessionId: t.string().uuid()
|
|
140
|
-
});
|
|
141
|
-
const Re = t.object({
|
|
142
|
-
sessionId: t.string().uuid(),
|
|
143
|
-
intent: t.string().min(1).max(2048),
|
|
144
|
-
pathGlobs: t.array(t.string().min(1).max(512)).min(1).max(64),
|
|
145
|
-
ttlSeconds: t.number().int().positive().optional(),
|
|
146
|
-
changeReport: X.optional()
|
|
147
|
-
});
|
|
148
|
-
t.object({
|
|
149
|
-
workItemId: t.string().uuid(),
|
|
150
|
-
landscape: ce
|
|
151
|
-
});
|
|
152
|
-
const Te = t.object({
|
|
153
|
-
sessionId: t.string().uuid(),
|
|
154
|
-
workItemId: t.string().uuid()
|
|
155
|
-
});
|
|
156
|
-
t.object({
|
|
157
|
-
ok: t.literal(!0),
|
|
158
|
-
// Pending announcements for the caller, delivered as a side effect of done so
|
|
159
|
-
// a message lands the moment a teammate finishes a unit of work (not only on
|
|
160
|
-
// their next work/sync). Defaulted for version-skew safety with older hubs.
|
|
161
|
-
announcements: t.array(U).default([])
|
|
162
|
-
});
|
|
163
|
-
const xe = t.object({
|
|
164
|
-
sessionId: t.string().uuid(),
|
|
165
|
-
body: t.string().min(1).max(8192),
|
|
166
|
-
// absent or null => broadcast to all agents in the workspace
|
|
167
|
-
targetAgentName: t.string().nullable().optional(),
|
|
168
|
-
// true => address the human operator (the dashboard) instead of agents. The
|
|
169
|
-
// mirror of the operator's admin → agent DM: it shows in the workspace feed as
|
|
170
|
-
// "<agent> → admin" and is NOT delivered to other agents. Mutually exclusive
|
|
171
|
-
// with targetAgentName (the hub rejects setting both). Defaulted/optional for
|
|
172
|
-
// version skew with older clients.
|
|
173
|
-
toAdmin: t.boolean().optional()
|
|
174
|
-
});
|
|
175
|
-
t.object({
|
|
176
|
-
ok: t.literal(!0),
|
|
177
|
-
// bigint PK serialised as number; see DbId note above
|
|
178
|
-
announcementId: O,
|
|
179
|
-
// Pending announcements for the caller, delivered as a side effect of announce
|
|
180
|
-
// (a turn where the agent is already reading hub output) so inbound messages
|
|
181
|
-
// surface promptly. Excludes the just-sent one. Defaulted for version skew.
|
|
182
|
-
announcements: t.array(U).default([])
|
|
183
|
-
});
|
|
184
|
-
t.object({
|
|
185
|
-
sessionId: t.string().uuid(),
|
|
186
|
-
changeReport: X.optional()
|
|
187
|
-
});
|
|
188
|
-
t.object({
|
|
189
|
-
landscape: ce
|
|
190
|
-
});
|
|
191
|
-
Re.omit({ sessionId: !0, changeReport: !0 });
|
|
192
|
-
xe.omit({ sessionId: !0 });
|
|
193
|
-
Te.omit({ sessionId: !0 });
|
|
194
|
-
t.object({});
|
|
195
|
-
t.object({});
|
|
196
|
-
t.object({
|
|
197
|
-
sessionId: t.string().uuid(),
|
|
198
|
-
// Optional change report so the BACKGROUND heartbeat keeps an agent's durable
|
|
199
|
-
// change records fresh (commits surface within ~one heartbeat interval, not
|
|
200
|
-
// only when it next calls work/sync). Processed presence-style: it refreshes
|
|
201
|
-
// change records but, like the rest of heartbeat, does NOT renew claim TTLs.
|
|
202
|
-
changeReport: X.optional(),
|
|
203
|
-
// Opt-in: when set, the heartbeat returns any pending announcements for the
|
|
204
|
-
// caller in the response. Delivery is now TWO-PHASE and crash-safe: this fetch
|
|
205
|
-
// phase does NOT mark them delivered — the client persists them to its
|
|
206
|
-
// model-visible sink (the local inbox file drained by a hook) FIRST, then acks
|
|
207
|
-
// via `ackAnnouncementIds` so the hub records the delivery only after the local
|
|
208
|
-
// write is confirmed. The MCP client only sets this when it actually has such a
|
|
209
|
-
// sink. Absent for older clients, so default behaviour (no delivery) is
|
|
210
|
-
// unchanged.
|
|
211
|
-
deliverAnnouncements: t.boolean().optional(),
|
|
212
|
-
// Phase-two ack of a previous `deliverAnnouncements` fetch: the ids the client
|
|
213
|
-
// has now durably written to its model-visible sink. The hub marks exactly
|
|
214
|
-
// these delivered to the caller's session. Decoupling the mark from the fetch
|
|
215
|
-
// guarantees a message is never recorded delivered before the client holds it
|
|
216
|
-
// (a lost response or a failed local append simply leaves it pending for the
|
|
217
|
-
// next beat). Absent on a plain presence/fetch beat.
|
|
218
|
-
ackAnnouncementIds: t.array(O).optional()
|
|
219
|
-
});
|
|
220
|
-
t.object({
|
|
221
|
-
ok: t.literal(!0),
|
|
222
|
-
// Pending announcements for the caller, delivered only when the request set
|
|
223
|
-
// `deliverAnnouncements`. Defaulted to [] for version-skew safety with older
|
|
224
|
-
// hubs (which return just { ok: true }).
|
|
225
|
-
announcements: t.array(U).default([])
|
|
226
|
-
});
|
|
227
|
-
t.object({
|
|
228
|
-
sessionId: t.string().uuid()
|
|
229
|
-
});
|
|
230
|
-
t.object({
|
|
231
|
-
ok: t.literal(!0)
|
|
232
|
-
});
|
|
233
|
-
const Ie = 5e3;
|
|
234
|
-
class I extends Error {
|
|
235
|
-
/**
|
|
236
|
-
* @param message - Human-readable failure description.
|
|
237
|
-
* @param status - Upstream HTTP status, omitted for network/abort failures.
|
|
238
|
-
*/
|
|
239
|
-
constructor(r, o) {
|
|
240
|
-
super(r);
|
|
241
|
-
/** Upstream HTTP status for a non-2xx response; absent for transport errors. */
|
|
242
|
-
J(this, "status");
|
|
243
|
-
this.name = "ShepherdClientError", o !== void 0 && (this.status = o);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
async function Ee(e) {
|
|
247
|
-
try {
|
|
248
|
-
const n = await e.json();
|
|
249
|
-
if (n !== null && typeof n == "object" && "error" in n && typeof n.error == "string")
|
|
250
|
-
return n.error;
|
|
251
|
-
} catch {
|
|
252
|
-
}
|
|
253
|
-
return "";
|
|
254
|
-
}
|
|
255
|
-
function ut(e) {
|
|
256
|
-
const n = e.baseUrl.replace(/\/$/, ""), r = e.timeoutMs ?? Ie;
|
|
257
|
-
async function o(a, c) {
|
|
258
|
-
var d, u;
|
|
259
|
-
const l = new AbortController(), i = setTimeout(() => l.abort(), r);
|
|
260
|
-
let f;
|
|
261
|
-
try {
|
|
262
|
-
const _ = { ...{
|
|
263
|
-
"Content-Type": "application/json"
|
|
264
|
-
}, ...await ((d = e.getAuthHeaders) == null ? void 0 : d.call(e)) ?? {} };
|
|
265
|
-
f = await fetch(`${n}${a}`, {
|
|
266
|
-
...c,
|
|
267
|
-
headers: _,
|
|
268
|
-
signal: l.signal
|
|
269
|
-
});
|
|
270
|
-
} catch (h) {
|
|
271
|
-
throw new I(
|
|
272
|
-
h instanceof Error ? h.message : String(h)
|
|
273
|
-
);
|
|
274
|
-
} finally {
|
|
275
|
-
clearTimeout(i);
|
|
276
|
-
}
|
|
277
|
-
if (f.status === 401)
|
|
278
|
-
throw (u = e.onUnauthorized) == null || u.call(e), new I("Unauthorized", 401);
|
|
279
|
-
if (!f.ok) {
|
|
280
|
-
const h = await Ee(f);
|
|
281
|
-
throw new I(
|
|
282
|
-
h !== "" ? `HTTP ${f.status}: ${h}` : `HTTP ${f.status}`,
|
|
283
|
-
f.status
|
|
284
|
-
);
|
|
285
|
-
}
|
|
286
|
-
return f.json();
|
|
287
|
-
}
|
|
288
|
-
return {
|
|
289
|
-
async getLandscape() {
|
|
290
|
-
const a = await o("/workspace/landscape", { method: "GET" }), c = $e.safeParse(a);
|
|
291
|
-
if (!c.success)
|
|
292
|
-
throw new I("Invalid response schema");
|
|
293
|
-
return c.data;
|
|
294
|
-
},
|
|
295
|
-
async announce(a) {
|
|
296
|
-
const c = await o("/workspace/announce", {
|
|
297
|
-
method: "POST",
|
|
298
|
-
body: JSON.stringify(a)
|
|
299
|
-
}), l = De.safeParse(c);
|
|
300
|
-
if (!l.success)
|
|
301
|
-
throw new I("Invalid response schema");
|
|
302
|
-
return l.data;
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
const ie = be(null);
|
|
307
|
-
function mt({
|
|
308
|
-
client: e,
|
|
309
|
-
children: n
|
|
310
|
-
}) {
|
|
311
|
-
return /* @__PURE__ */ s(ie.Provider, { value: e, children: n });
|
|
312
|
-
}
|
|
313
|
-
function le() {
|
|
314
|
-
const e = ve(ie);
|
|
315
|
-
if (e === null)
|
|
316
|
-
throw new Error(
|
|
317
|
-
"useShepherdClient must be used within <ShepherdClientProvider>"
|
|
318
|
-
);
|
|
319
|
-
return e;
|
|
320
|
-
}
|
|
321
|
-
const je = 5e3, Me = 1e3;
|
|
322
|
-
function Le(e) {
|
|
323
|
-
const n = le(), r = je, [o, a] = y(
|
|
324
|
-
null
|
|
325
|
-
), [c, l] = y("live"), [i, f] = y(null), [, d] = y(0), u = E(n);
|
|
326
|
-
u.current = n;
|
|
327
|
-
const h = k(async () => {
|
|
328
|
-
try {
|
|
329
|
-
const N = await u.current.getLandscape();
|
|
330
|
-
a(N), f(Date.now()), l("live");
|
|
331
|
-
} catch (N) {
|
|
332
|
-
N instanceof I && N.status === 401 ? l("unauthorized") : l("reconnecting");
|
|
333
|
-
}
|
|
334
|
-
}, []);
|
|
335
|
-
V(() => {
|
|
336
|
-
h();
|
|
337
|
-
const N = setInterval(() => {
|
|
338
|
-
h();
|
|
339
|
-
}, r), b = setInterval(() => {
|
|
340
|
-
d((w) => w + 1);
|
|
341
|
-
}, Me);
|
|
342
|
-
return () => {
|
|
343
|
-
clearInterval(N), clearInterval(b);
|
|
344
|
-
};
|
|
345
|
-
}, [h, r]);
|
|
346
|
-
const _ = k(() => h(), [h]);
|
|
347
|
-
return { snapshot: o, status: c, lastUpdatedMs: i, refresh: _ };
|
|
348
|
-
}
|
|
349
|
-
function G(e, n) {
|
|
350
|
-
const r = Math.floor((n - Date.parse(e)) / 1e3);
|
|
351
|
-
if (r < 5) return "just now";
|
|
352
|
-
if (r < 60) return `${r}s ago`;
|
|
353
|
-
const o = Math.floor(r / 60);
|
|
354
|
-
if (o < 60) return `${o}m ago`;
|
|
355
|
-
const a = Math.floor(o / 60);
|
|
356
|
-
return a < 24 ? `${a}h ago` : `${Math.floor(a / 24)}d ago`;
|
|
357
|
-
}
|
|
358
|
-
function H(e) {
|
|
359
|
-
let n = 0;
|
|
360
|
-
for (let r = 0; r < e.length; r++) n = (n * 31 + e.charCodeAt(r)) % 360;
|
|
361
|
-
return `hsl(${n}, 38%, 42%)`;
|
|
362
|
-
}
|
|
363
|
-
function Z(e) {
|
|
364
|
-
if (!e) return "?";
|
|
365
|
-
const n = e.match(/[A-Z]/g);
|
|
366
|
-
return n && n.length >= 2 ? n[0] + n[1] : e.slice(0, 2).toUpperCase();
|
|
367
|
-
}
|
|
368
|
-
const de = "A-Za-z0-9_-";
|
|
369
|
-
function Pe(e, n) {
|
|
370
|
-
const o = e.slice(0, n).match(new RegExp(`(?:^|\\s)@([${de}]*)$`));
|
|
371
|
-
if (!o) return null;
|
|
372
|
-
const a = o[1];
|
|
373
|
-
return { start: n - a.length - 1, end: n, query: a };
|
|
374
|
-
}
|
|
375
|
-
function Ge(e, n) {
|
|
376
|
-
const r = new RegExp(`(?:^|\\s)@([${de}]+)`, "g");
|
|
377
|
-
let o;
|
|
378
|
-
for (; (o = r.exec(e)) !== null; ) {
|
|
379
|
-
const a = o[1].toLowerCase(), c = n.find((l) => l.toLowerCase() === a);
|
|
380
|
-
if (c) return c;
|
|
381
|
-
}
|
|
382
|
-
return null;
|
|
383
|
-
}
|
|
384
|
-
function ue(e) {
|
|
385
|
-
return [...new Set(e.map((n) => n.repo))].sort();
|
|
386
|
-
}
|
|
387
|
-
function C(e, n) {
|
|
388
|
-
return n === null || n === "__all__" || e.repo === n;
|
|
389
|
-
}
|
|
390
|
-
function He(e, n) {
|
|
391
|
-
return [
|
|
392
|
-
...new Set(
|
|
393
|
-
e.filter((r) => r.presence === "live" && C(r, n)).map((r) => r.name)
|
|
394
|
-
)
|
|
395
|
-
].sort();
|
|
396
|
-
}
|
|
397
|
-
function Q(e) {
|
|
398
|
-
const n = e.find((r) => r.status === "active");
|
|
399
|
-
return n ? n.repo : e.length ? e[0].repo : null;
|
|
400
|
-
}
|
|
401
|
-
function Oe(e) {
|
|
402
|
-
return e === "dropped" ? "dropped" : "done";
|
|
403
|
-
}
|
|
404
|
-
function ee(e, n) {
|
|
405
|
-
if (!n) return "";
|
|
406
|
-
const r = Math.floor((Date.parse(n) - Date.parse(e)) / 1e3), o = Math.floor(r / 60);
|
|
407
|
-
return o < 60 ? `active ${o}m` : `active ${Math.floor(o / 60)}h`;
|
|
408
|
-
}
|
|
409
|
-
function Ue(e, n) {
|
|
410
|
-
const r = new Date(Date.parse(e)), o = new Date(n), a = (l) => new Date(l.getFullYear(), l.getMonth(), l.getDate()).getTime(), c = Math.round((a(o) - a(r)) / 864e5);
|
|
411
|
-
return c <= 0 ? "Today" : c === 1 ? "Yesterday" : r.toLocaleDateString(void 0, { month: "short", day: "numeric" });
|
|
412
|
-
}
|
|
413
|
-
function te(e) {
|
|
414
|
-
let n = e.toLowerCase().replace(/\\/g, "/");
|
|
415
|
-
n.endsWith("/") && (n = n.replace(/\/+$/, "") + "/**");
|
|
416
|
-
const r = [];
|
|
417
|
-
for (const o of n.split("/"))
|
|
418
|
-
if (!(o === "" || o === ".")) {
|
|
419
|
-
if (o === "..") {
|
|
420
|
-
r.length && r.pop();
|
|
421
|
-
continue;
|
|
422
|
-
}
|
|
423
|
-
r.push(o);
|
|
424
|
-
}
|
|
425
|
-
return r;
|
|
426
|
-
}
|
|
427
|
-
const ne = /[*?{}[\]]/;
|
|
428
|
-
function Fe(e, n) {
|
|
429
|
-
return e === "*" ? !0 : (ne.test(e) || !ne.test(n)) && e === n;
|
|
430
|
-
}
|
|
431
|
-
function qe(e, n) {
|
|
432
|
-
const r = /* @__PURE__ */ new Map();
|
|
433
|
-
function o(a, c) {
|
|
434
|
-
if (n.length - c === 0) {
|
|
435
|
-
for (let h = a; h < e.length; h++) if (e[h] !== "**") return !1;
|
|
436
|
-
return !0;
|
|
437
|
-
}
|
|
438
|
-
if (e.length - a === 0) return !1;
|
|
439
|
-
const l = a * (n.length + 1) + c, i = r.get(l);
|
|
440
|
-
if (i !== void 0) return i;
|
|
441
|
-
const f = e[a], d = n[c];
|
|
442
|
-
let u;
|
|
443
|
-
return f === "**" ? u = o(a + 1, c) || o(a, c + 1) : d === "**" ? u = !1 : u = Fe(f, d) && o(a + 1, c + 1), r.set(l, u), u;
|
|
444
|
-
}
|
|
445
|
-
return o(0, 0);
|
|
446
|
-
}
|
|
447
|
-
function ae(e, n) {
|
|
448
|
-
if (n.length === 0) return !0;
|
|
449
|
-
const r = e.map(te);
|
|
450
|
-
return n.every((o) => {
|
|
451
|
-
const a = te(o);
|
|
452
|
-
return r.some((c) => qe(c, a));
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
function We(e) {
|
|
456
|
-
const n = /* @__PURE__ */ new Map();
|
|
457
|
-
for (const a of e)
|
|
458
|
-
n.has(a.agentName) || n.set(a.agentName, []), n.get(a.agentName).push(a);
|
|
459
|
-
const r = (a, c) => c.createdAt.localeCompare(a.createdAt), o = [];
|
|
460
|
-
for (const [a, c] of n) {
|
|
461
|
-
const l = [...c].sort(r), i = l.map(
|
|
462
|
-
(d) => l.some(
|
|
463
|
-
(u) => u !== d && ae(u.pathGlobs, d.pathGlobs) && !ae(d.pathGlobs, u.pathGlobs)
|
|
464
|
-
)
|
|
465
|
-
), f = l[0];
|
|
466
|
-
o.push({
|
|
467
|
-
agentName: a,
|
|
468
|
-
model: f.model,
|
|
469
|
-
program: f.program,
|
|
470
|
-
repo: f.repo,
|
|
471
|
-
primaries: l.filter((d, u) => !i[u]),
|
|
472
|
-
narrower: l.filter((d, u) => i[u])
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
return o.sort((a, c) => {
|
|
476
|
-
const l = a.primaries.concat(a.narrower)[0].createdAt;
|
|
477
|
-
return c.primaries.concat(c.narrower)[0].createdAt.localeCompare(l);
|
|
478
|
-
}), o;
|
|
479
|
-
}
|
|
480
|
-
const se = { active: 0, done: 0 };
|
|
481
|
-
function ze({
|
|
482
|
-
repos: e,
|
|
483
|
-
counts: n,
|
|
484
|
-
selected: r,
|
|
485
|
-
onSelect: o
|
|
486
|
-
}) {
|
|
487
|
-
const [a, c] = y(!1), l = E(null);
|
|
488
|
-
if (V(() => {
|
|
489
|
-
var _;
|
|
490
|
-
if (!a) return;
|
|
491
|
-
const u = (_ = l.current) == null ? void 0 : _.querySelector(".repo-menu");
|
|
492
|
-
if (!u) return;
|
|
493
|
-
const h = u.querySelector('[aria-selected="true"]') ?? u.querySelector("button");
|
|
494
|
-
h == null || h.focus();
|
|
495
|
-
}, [a]), e.length < 2) return null;
|
|
496
|
-
const i = r === null || r === "__all__", f = i ? "All repos" : r, d = (u, h) => {
|
|
497
|
-
const _ = u === null ? n.__all__ ?? se : n[u] ?? se, N = u === null ? i : r === u, b = "repo-mi" + (N ? " on" : "") + (u === null ? " all" : "");
|
|
498
|
-
return /* @__PURE__ */ m(
|
|
499
|
-
"button",
|
|
500
|
-
{
|
|
501
|
-
type: "button",
|
|
502
|
-
className: b,
|
|
503
|
-
role: "option",
|
|
504
|
-
"aria-selected": N,
|
|
505
|
-
onClick: (w) => {
|
|
506
|
-
w.stopPropagation(), c(!1), o(u);
|
|
507
|
-
},
|
|
508
|
-
children: [
|
|
509
|
-
/* @__PURE__ */ s("span", { children: h }),
|
|
510
|
-
/* @__PURE__ */ s("span", { className: "ct", children: `${_.active} active · ${_.done} done` })
|
|
511
|
-
]
|
|
512
|
-
},
|
|
513
|
-
u ?? "__all__"
|
|
514
|
-
);
|
|
515
|
-
};
|
|
516
|
-
return /* @__PURE__ */ m(
|
|
517
|
-
"span",
|
|
518
|
-
{
|
|
519
|
-
ref: l,
|
|
520
|
-
className: "repo",
|
|
521
|
-
onKeyDown: (u) => {
|
|
522
|
-
u.key === "Escape" && c(!1);
|
|
523
|
-
},
|
|
524
|
-
children: [
|
|
525
|
-
/* @__PURE__ */ m(
|
|
526
|
-
"button",
|
|
527
|
-
{
|
|
528
|
-
type: "button",
|
|
529
|
-
className: "repo-trig",
|
|
530
|
-
"aria-haspopup": "listbox",
|
|
531
|
-
"aria-expanded": a,
|
|
532
|
-
"aria-label": `Filter by repo (current: ${f})`,
|
|
533
|
-
onClick: (u) => {
|
|
534
|
-
u.stopPropagation(), c((h) => !h);
|
|
535
|
-
},
|
|
536
|
-
children: [
|
|
537
|
-
/* @__PURE__ */ s("span", { className: "slash", children: "/" }),
|
|
538
|
-
" " + f + " ",
|
|
539
|
-
/* @__PURE__ */ s("span", { children: "▼" })
|
|
540
|
-
]
|
|
541
|
-
}
|
|
542
|
-
),
|
|
543
|
-
a && /* @__PURE__ */ m("div", { className: "repo-menu", role: "listbox", children: [
|
|
544
|
-
e.map((u) => d(u, u)),
|
|
545
|
-
d(null, "All repos")
|
|
546
|
-
] })
|
|
547
|
-
]
|
|
548
|
-
}
|
|
549
|
-
);
|
|
550
|
-
}
|
|
551
|
-
function Ke({ agents: e, tasks: n, selectedRepo: r }) {
|
|
552
|
-
const o = e.filter(
|
|
553
|
-
(i) => i.presence === "live" && C({ repo: i.repo ?? "" }, r)
|
|
554
|
-
), a = /* @__PURE__ */ new Set();
|
|
555
|
-
for (const i of n) i.status === "active" && a.add(i.agentName);
|
|
556
|
-
const c = (i) => a.has(i.name), l = [...o].sort((i, f) => {
|
|
557
|
-
const d = c(i), u = c(f);
|
|
558
|
-
return d !== u ? d ? -1 : 1 : i.name.localeCompare(f.name);
|
|
559
|
-
});
|
|
560
|
-
return /* @__PURE__ */ s("div", { className: "crew", id: "crew", children: l.map((i) => /* @__PURE__ */ m(
|
|
561
|
-
"div",
|
|
562
|
-
{
|
|
563
|
-
className: "person" + (c(i) ? "" : " person--idle"),
|
|
564
|
-
children: [
|
|
565
|
-
/* @__PURE__ */ s("div", { className: "avatar", style: { background: H(i.name) }, children: Z(i.name) }),
|
|
566
|
-
/* @__PURE__ */ s("span", { className: "person__name", children: i.name })
|
|
567
|
-
]
|
|
568
|
-
},
|
|
569
|
-
i.name
|
|
570
|
-
)) });
|
|
571
|
-
}
|
|
572
|
-
function me({ globs: e }) {
|
|
573
|
-
return e.length <= 1 ? /* @__PURE__ */ m("div", { className: "terr", children: [
|
|
574
|
-
/* @__PURE__ */ s("span", { className: "terr__lbl", children: "territory" }),
|
|
575
|
-
e.map((n) => /* @__PURE__ */ s("span", { className: "glob", children: n }, n))
|
|
576
|
-
] }) : /* @__PURE__ */ m("details", { className: "terrx", children: [
|
|
577
|
-
/* @__PURE__ */ m("summary", { children: [
|
|
578
|
-
/* @__PURE__ */ s("span", { className: "terr__lbl", children: "territory" }),
|
|
579
|
-
/* @__PURE__ */ m("span", { className: "glob glob--more", children: [
|
|
580
|
-
/* @__PURE__ */ s("span", { className: "tw", children: "▶" }),
|
|
581
|
-
` ${e.length} paths`
|
|
582
|
-
] })
|
|
583
|
-
] }),
|
|
584
|
-
/* @__PURE__ */ s("div", { className: "terr terr--full", children: e.map((n) => /* @__PURE__ */ s("span", { className: "glob", children: n }, n)) })
|
|
585
|
-
] });
|
|
586
|
-
}
|
|
587
|
-
const B = (e) => `${e.agentName}|${e.repo}|${e.createdAt}`, Be = (e) => e === null || e === "__all__";
|
|
588
|
-
function Y({
|
|
589
|
-
task: e,
|
|
590
|
-
nowMs: n
|
|
591
|
-
}) {
|
|
592
|
-
return /* @__PURE__ */ m(ge, { children: [
|
|
593
|
-
/* @__PURE__ */ s("div", { className: "task__intent", children: e.intent }),
|
|
594
|
-
/* @__PURE__ */ s(me, { globs: e.pathGlobs }),
|
|
595
|
-
/* @__PURE__ */ s("div", { className: "task__meta", children: `started ${G(e.createdAt, n)}` })
|
|
596
|
-
] });
|
|
597
|
-
}
|
|
598
|
-
function Ye({
|
|
599
|
-
task: e,
|
|
600
|
-
nowMs: n,
|
|
601
|
-
allRepos: r
|
|
602
|
-
}) {
|
|
603
|
-
const o = e.model || e.program;
|
|
604
|
-
return /* @__PURE__ */ m("div", { className: "task", children: [
|
|
605
|
-
/* @__PURE__ */ m("div", { className: "task__r1", children: [
|
|
606
|
-
/* @__PURE__ */ s("span", { className: "task__who", children: e.agentName }),
|
|
607
|
-
r && /* @__PURE__ */ s("span", { className: "task__repo", children: e.repo }),
|
|
608
|
-
o && /* @__PURE__ */ s("span", { className: "task__tag", children: o }),
|
|
609
|
-
/* @__PURE__ */ s("span", { className: "livedot", title: "active" })
|
|
610
|
-
] }),
|
|
611
|
-
/* @__PURE__ */ s(Y, { task: e, nowMs: n })
|
|
612
|
-
] });
|
|
613
|
-
}
|
|
614
|
-
function Ve({
|
|
615
|
-
group: e,
|
|
616
|
-
nowMs: n,
|
|
617
|
-
allRepos: r
|
|
618
|
-
}) {
|
|
619
|
-
const o = e.model || e.program, a = e.primaries.length + e.narrower.length, c = e.narrower.length;
|
|
620
|
-
return /* @__PURE__ */ m("div", { className: "grp", children: [
|
|
621
|
-
/* @__PURE__ */ m("div", { className: "grp__head", children: [
|
|
622
|
-
/* @__PURE__ */ s("span", { className: "grp__who", children: e.agentName }),
|
|
623
|
-
r && /* @__PURE__ */ s("span", { className: "task__repo", children: e.repo }),
|
|
624
|
-
o && /* @__PURE__ */ s("span", { className: "grp__tag", children: o }),
|
|
625
|
-
/* @__PURE__ */ s("span", { className: "grp__count", children: `· ${a} active` }),
|
|
626
|
-
/* @__PURE__ */ s("span", { className: "grp__dot", title: "live" })
|
|
627
|
-
] }),
|
|
628
|
-
/* @__PURE__ */ s("div", { className: "claims", children: e.primaries.map((l) => /* @__PURE__ */ s("div", { className: "claim", children: /* @__PURE__ */ s(Y, { task: l, nowMs: n }) }, B(l))) }),
|
|
629
|
-
c > 0 && /* @__PURE__ */ m("details", { className: "fold", children: [
|
|
630
|
-
/* @__PURE__ */ m("summary", { children: [
|
|
631
|
-
/* @__PURE__ */ s("span", { className: "tw", children: "▶" }),
|
|
632
|
-
` +${c} narrower claim${c > 1 ? "s" : ""}`
|
|
633
|
-
] }),
|
|
634
|
-
/* @__PURE__ */ s("div", { className: "fold__body", children: e.narrower.map((l) => /* @__PURE__ */ m("div", { className: "claim", children: [
|
|
635
|
-
/* @__PURE__ */ s(Y, { task: l, nowMs: n }),
|
|
636
|
-
/* @__PURE__ */ s("div", { className: "covered", children: "⊂ covered by a claim above" })
|
|
637
|
-
] }, B(l))) })
|
|
638
|
-
] })
|
|
639
|
-
] });
|
|
640
|
-
}
|
|
641
|
-
function Xe({
|
|
642
|
-
tasks: e,
|
|
643
|
-
nowMs: n,
|
|
644
|
-
selectedRepo: r
|
|
645
|
-
}) {
|
|
646
|
-
const o = Be(r), a = e.filter(
|
|
647
|
-
(c) => c.status === "active" && C(c, r)
|
|
648
|
-
);
|
|
649
|
-
if (a.length === 0) {
|
|
650
|
-
const c = o ? "Nothing active right now." : `Nothing active in ${r}.`;
|
|
651
|
-
return /* @__PURE__ */ s("div", { id: "active-list", children: /* @__PURE__ */ s("div", { className: "empty", children: c }) });
|
|
652
|
-
}
|
|
653
|
-
return /* @__PURE__ */ s("div", { id: "active-list", children: We(a).map((c) => {
|
|
654
|
-
const l = c.primaries.length === 1 && c.narrower.length === 0, i = B(c.primaries.concat(c.narrower)[0]);
|
|
655
|
-
return l ? /* @__PURE__ */ s(
|
|
656
|
-
Ye,
|
|
657
|
-
{
|
|
658
|
-
task: c.primaries[0],
|
|
659
|
-
nowMs: n,
|
|
660
|
-
allRepos: o
|
|
661
|
-
},
|
|
662
|
-
i
|
|
663
|
-
) : /* @__PURE__ */ s(Ve, { group: c, nowMs: n, allRepos: o }, i);
|
|
664
|
-
}) });
|
|
665
|
-
}
|
|
666
|
-
const Ze = (e) => `${e.agentName}|${e.repo}|${e.createdAt}`, Je = (e) => e === null || e === "__all__";
|
|
667
|
-
function Qe({
|
|
668
|
-
tasks: e,
|
|
669
|
-
nowMs: n,
|
|
670
|
-
selectedRepo: r,
|
|
671
|
-
doneShown: o,
|
|
672
|
-
onLoadMore: a
|
|
673
|
-
}) {
|
|
674
|
-
const c = Je(r), l = e.filter(
|
|
675
|
-
(d) => d.status !== "active" && C(d, r)
|
|
676
|
-
);
|
|
677
|
-
if (l.length === 0) {
|
|
678
|
-
const d = c ? "No finished tasks yet." : `No finished tasks in ${r} yet.`;
|
|
679
|
-
return /* @__PURE__ */ s("div", { id: "done-list", children: /* @__PURE__ */ s("div", { className: "empty", children: d }) });
|
|
680
|
-
}
|
|
681
|
-
const i = l.slice(0, o);
|
|
682
|
-
let f = null;
|
|
683
|
-
return /* @__PURE__ */ m("div", { id: "done-list", children: [
|
|
684
|
-
i.map((d) => {
|
|
685
|
-
const u = Ue(d.endedAt ?? d.createdAt, n), h = u !== f ? u : null;
|
|
686
|
-
f = u;
|
|
687
|
-
const _ = d.status === "dropped", N = _ ? `went offline ${G(d.endedAt ?? d.createdAt, n)} — no done signal` : `finished ${G(d.endedAt ?? d.createdAt, n)}${ee(d.createdAt, d.endedAt) ? " · " + ee(d.createdAt, d.endedAt) : ""}`;
|
|
688
|
-
return /* @__PURE__ */ m(_e, { children: [
|
|
689
|
-
h !== null && /* @__PURE__ */ s("div", { className: "day", children: h }),
|
|
690
|
-
/* @__PURE__ */ m("div", { className: "task", children: [
|
|
691
|
-
/* @__PURE__ */ m("div", { className: "task__r1", children: [
|
|
692
|
-
/* @__PURE__ */ s("span", { className: "task__who", children: d.agentName }),
|
|
693
|
-
c && /* @__PURE__ */ s("span", { className: "task__repo", children: d.repo }),
|
|
694
|
-
/* @__PURE__ */ s(
|
|
695
|
-
"span",
|
|
696
|
-
{
|
|
697
|
-
className: "task__stat" + (_ ? " task__stat--drop" : ""),
|
|
698
|
-
children: Oe(d.status)
|
|
699
|
-
}
|
|
700
|
-
)
|
|
701
|
-
] }),
|
|
702
|
-
/* @__PURE__ */ s("div", { className: "task__intent", children: d.intent }),
|
|
703
|
-
/* @__PURE__ */ s(me, { globs: d.pathGlobs }),
|
|
704
|
-
/* @__PURE__ */ s("div", { className: "task__meta", children: N })
|
|
705
|
-
] })
|
|
706
|
-
] }, Ze(d));
|
|
707
|
-
}),
|
|
708
|
-
l.length > o && /* @__PURE__ */ s(
|
|
709
|
-
"div",
|
|
710
|
-
{
|
|
711
|
-
className: "more",
|
|
712
|
-
role: "button",
|
|
713
|
-
tabIndex: 0,
|
|
714
|
-
onClick: a,
|
|
715
|
-
onKeyDown: (d) => {
|
|
716
|
-
(d.key === "Enter" || d.key === " ") && (d.preventDefault(), a());
|
|
717
|
-
},
|
|
718
|
-
children: `Load older · ${o} of ${l.length}`
|
|
719
|
-
}
|
|
720
|
-
)
|
|
721
|
-
] });
|
|
722
|
-
}
|
|
723
|
-
const et = 80;
|
|
724
|
-
function tt({ announcements: e, selectedRepo: n, nowMs: r }) {
|
|
725
|
-
const o = E(null), a = E(!0), c = o.current;
|
|
726
|
-
c && (a.current = c.scrollHeight - c.scrollTop - c.clientHeight < et);
|
|
727
|
-
const l = [...e].filter((i) => C(i, n)).reverse();
|
|
728
|
-
return Ne(() => {
|
|
729
|
-
a.current && o.current && (o.current.scrollTop = o.current.scrollHeight);
|
|
730
|
-
}, [l.length]), /* @__PURE__ */ s("div", { id: "chat", className: "chat", ref: o, children: l.length === 0 ? /* @__PURE__ */ s("div", { className: "empty", children: "No announcements yet — agents will post here as they coordinate." }) : l.map((i, f) => {
|
|
731
|
-
const u = "msg" + (i.targetAgentName !== null || i.toAdmin ? " msg--targeted" : "") + (i.fromAdmin ? " msg--me" : "");
|
|
732
|
-
return (
|
|
733
|
-
// The feed has no stable id; index is acceptable because the list is
|
|
734
|
-
// append-only oldest->newest and rows are never reordered in place.
|
|
735
|
-
/* @__PURE__ */ m("div", { className: u, children: [
|
|
736
|
-
/* @__PURE__ */ s(
|
|
737
|
-
"div",
|
|
738
|
-
{
|
|
739
|
-
className: "msg__avatar",
|
|
740
|
-
style: { background: H(i.fromAgentName) },
|
|
741
|
-
children: Z(i.fromAgentName)
|
|
742
|
-
}
|
|
743
|
-
),
|
|
744
|
-
/* @__PURE__ */ m("div", { className: "msg__body", children: [
|
|
745
|
-
/* @__PURE__ */ m("div", { className: "msg__head", children: [
|
|
746
|
-
/* @__PURE__ */ s(
|
|
747
|
-
"span",
|
|
748
|
-
{
|
|
749
|
-
className: "msg__who",
|
|
750
|
-
style: { color: H(i.fromAgentName) },
|
|
751
|
-
children: i.fromAgentName
|
|
752
|
-
}
|
|
753
|
-
),
|
|
754
|
-
i.fromHuman ? /* @__PURE__ */ s("span", { className: "msg__human", children: i.fromHuman }) : null,
|
|
755
|
-
i.targetAgentName !== null ? /* @__PURE__ */ s("span", { className: "msg__to", children: `→ @${i.targetAgentName}` }) : i.toAdmin ? /* @__PURE__ */ s("span", { className: "msg__to", children: "→ admin" }) : null,
|
|
756
|
-
/* @__PURE__ */ s("span", { className: "msg__time", children: G(i.createdAt, r) })
|
|
757
|
-
] }),
|
|
758
|
-
/* @__PURE__ */ s("div", { className: "msg__text", children: i.body })
|
|
759
|
-
] })
|
|
760
|
-
] }, f)
|
|
761
|
-
);
|
|
762
|
-
}) });
|
|
763
|
-
}
|
|
764
|
-
const nt = 8;
|
|
765
|
-
function at({ agents: e, selectedRepo: n, onSent: r }) {
|
|
766
|
-
const o = le(), a = E(null), [c, l] = y(""), [i, f] = y([]), [d, u] = y(0), [h, _] = y(null), [N, b] = y(!1), [w, L] = y(!1), T = He(
|
|
767
|
-
e.map((p) => ({ name: p.name, presence: p.presence, repo: p.repo ?? "" })),
|
|
768
|
-
n
|
|
769
|
-
), D = i.length > 0, A = k(() => {
|
|
770
|
-
f([]), _(null);
|
|
771
|
-
}, []), x = k(
|
|
772
|
-
(p, v) => {
|
|
773
|
-
const g = Pe(p, v);
|
|
774
|
-
if (!g) {
|
|
775
|
-
A();
|
|
776
|
-
return;
|
|
777
|
-
}
|
|
778
|
-
const S = g.query.toLowerCase(), M = T.filter((he) => he.toLowerCase().startsWith(S)).slice(0, nt);
|
|
779
|
-
f(M), _({ start: g.start, end: g.end }), u(0);
|
|
780
|
-
},
|
|
781
|
-
[T, A]
|
|
782
|
-
), j = k(
|
|
783
|
-
(p) => {
|
|
784
|
-
if (!h) return;
|
|
785
|
-
const v = "@" + p + " ", g = c.slice(0, h.start) + v + c.slice(h.end), S = h.start + v.length;
|
|
786
|
-
l(g), A(), requestAnimationFrame(() => {
|
|
787
|
-
const M = a.current;
|
|
788
|
-
M && (M.focus(), M.setSelectionRange(S, S));
|
|
789
|
-
});
|
|
790
|
-
},
|
|
791
|
-
[h, c, A]
|
|
792
|
-
), P = k(
|
|
793
|
-
(p) => {
|
|
794
|
-
var g;
|
|
795
|
-
l(p);
|
|
796
|
-
const v = ((g = a.current) == null ? void 0 : g.selectionStart) ?? p.length;
|
|
797
|
-
x(p, v);
|
|
798
|
-
},
|
|
799
|
-
[x]
|
|
800
|
-
), R = k(
|
|
801
|
-
(p) => {
|
|
802
|
-
D && (p.key === "ArrowDown" ? (p.preventDefault(), u((v) => (v + 1) % i.length)) : p.key === "ArrowUp" ? (p.preventDefault(), u((v) => (v - 1 + i.length) % i.length)) : p.key === "Enter" || p.key === "Tab" ? (p.preventDefault(), j(i[d])) : p.key === "Escape" && (p.preventDefault(), A()));
|
|
803
|
-
},
|
|
804
|
-
[D, i, d, j, A]
|
|
805
|
-
), F = k(
|
|
806
|
-
async (p) => {
|
|
807
|
-
p.preventDefault();
|
|
808
|
-
const v = c.trim();
|
|
809
|
-
if (!v) return;
|
|
810
|
-
const g = Ge(v, T), S = n === null || n === "__all__" ? null : n;
|
|
811
|
-
b(!0), L(!1);
|
|
812
|
-
try {
|
|
813
|
-
await o.announce({ body: v, targetAgentName: g, repo: S }), l(""), A(), await r();
|
|
814
|
-
} catch {
|
|
815
|
-
L(!0);
|
|
816
|
-
} finally {
|
|
817
|
-
b(!1);
|
|
818
|
-
}
|
|
819
|
-
},
|
|
820
|
-
[c, T, n, o, A, r]
|
|
821
|
-
);
|
|
822
|
-
return /* @__PURE__ */ m("div", { className: "composer", children: [
|
|
823
|
-
/* @__PURE__ */ s(
|
|
824
|
-
"div",
|
|
825
|
-
{
|
|
826
|
-
id: "mention-pop",
|
|
827
|
-
className: "mention-pop",
|
|
828
|
-
role: "listbox",
|
|
829
|
-
"aria-label": "Agents to mention",
|
|
830
|
-
hidden: !D,
|
|
831
|
-
children: i.map((p, v) => /* @__PURE__ */ m(
|
|
832
|
-
"button",
|
|
833
|
-
{
|
|
834
|
-
id: `mention-opt-${v}`,
|
|
835
|
-
type: "button",
|
|
836
|
-
role: "option",
|
|
837
|
-
"aria-selected": v === d,
|
|
838
|
-
className: "mention-mi" + (v === d ? " on" : ""),
|
|
839
|
-
onMouseDown: (g) => {
|
|
840
|
-
g.preventDefault(), j(p);
|
|
841
|
-
},
|
|
842
|
-
children: [
|
|
843
|
-
/* @__PURE__ */ s("div", { className: "ma", style: { background: H(p) }, children: Z(p) }),
|
|
844
|
-
/* @__PURE__ */ s("span", { children: p })
|
|
845
|
-
]
|
|
846
|
-
},
|
|
847
|
-
p
|
|
848
|
-
))
|
|
849
|
-
}
|
|
850
|
-
),
|
|
851
|
-
/* @__PURE__ */ m(
|
|
852
|
-
"form",
|
|
853
|
-
{
|
|
854
|
-
id: "chat-form",
|
|
855
|
-
className: "chat-form",
|
|
856
|
-
onSubmit: (p) => {
|
|
857
|
-
F(p);
|
|
858
|
-
},
|
|
859
|
-
children: [
|
|
860
|
-
/* @__PURE__ */ s(
|
|
861
|
-
"input",
|
|
862
|
-
{
|
|
863
|
-
id: "chat-input",
|
|
864
|
-
className: "chat-input",
|
|
865
|
-
type: "text",
|
|
866
|
-
autoComplete: "off",
|
|
867
|
-
"aria-label": "Message the team",
|
|
868
|
-
placeholder: "Message the team… use @name to direct it",
|
|
869
|
-
role: "combobox",
|
|
870
|
-
"aria-expanded": D,
|
|
871
|
-
"aria-controls": "mention-pop",
|
|
872
|
-
"aria-autocomplete": "list",
|
|
873
|
-
"aria-activedescendant": D ? `mention-opt-${d}` : void 0,
|
|
874
|
-
ref: a,
|
|
875
|
-
value: c,
|
|
876
|
-
onChange: (p) => P(p.target.value),
|
|
877
|
-
onKeyDown: R
|
|
878
|
-
}
|
|
879
|
-
),
|
|
880
|
-
/* @__PURE__ */ s("button", { id: "chat-send", className: "chat-send", type: "submit", disabled: N, children: "Send" })
|
|
881
|
-
]
|
|
882
|
-
}
|
|
883
|
-
),
|
|
884
|
-
w ? /* @__PURE__ */ s("div", { className: "chat__note", role: "status", children: "send failed — retry" }) : null
|
|
885
|
-
] });
|
|
886
|
-
}
|
|
887
|
-
const re = "shepherd.tab", W = "shepherd.repo", z = 10, st = {
|
|
888
|
-
live: { text: "live", kind: "ok" },
|
|
889
|
-
reconnecting: { text: "reconnecting…", kind: "warn" },
|
|
890
|
-
// app.js cleared the token and re-prompted on 401; in the auth-agnostic port
|
|
891
|
-
// the injected client's onUnauthorized owns any token handling, so the board
|
|
892
|
-
// only surfaces the rejected state.
|
|
893
|
-
unauthorized: { text: "token rejected", kind: "error" }
|
|
894
|
-
};
|
|
895
|
-
function oe(e) {
|
|
896
|
-
try {
|
|
897
|
-
return localStorage.getItem(e);
|
|
898
|
-
} catch {
|
|
899
|
-
return null;
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
function K(e, n) {
|
|
903
|
-
try {
|
|
904
|
-
localStorage.setItem(e, n);
|
|
905
|
-
} catch {
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
function rt(e, n, r) {
|
|
909
|
-
const o = ue(n.tasks);
|
|
910
|
-
let a = e;
|
|
911
|
-
if (a === null && o.length >= 2 && (a = Q(n.tasks)), a !== null && a !== "__all__" && !o.includes(a) && (a = "__all__"), r && a !== null && a !== "__all__") {
|
|
912
|
-
const c = n.tasks.some(
|
|
913
|
-
(i) => i.status === "active" && i.repo === a
|
|
914
|
-
), l = n.tasks.some((i) => i.status === "active");
|
|
915
|
-
!c && l && (a = Q(n.tasks));
|
|
916
|
-
}
|
|
917
|
-
return a;
|
|
918
|
-
}
|
|
919
|
-
function ot(e) {
|
|
920
|
-
const n = {}, r = (o, a) => {
|
|
921
|
-
const c = n[o] ?? (n[o] = { active: 0, done: 0 });
|
|
922
|
-
c[a]++;
|
|
923
|
-
};
|
|
924
|
-
for (const o of e.tasks) {
|
|
925
|
-
const a = o.status === "active" ? "active" : "done";
|
|
926
|
-
r(o.repo, a), r("__all__", a);
|
|
927
|
-
}
|
|
928
|
-
return n;
|
|
929
|
-
}
|
|
930
|
-
function ht() {
|
|
931
|
-
const { snapshot: e, status: n, lastUpdatedMs: r, refresh: o } = Le(), [a, c] = y(
|
|
932
|
-
() => oe(re) === "chat" ? "chat" : "tasks"
|
|
933
|
-
), [l, i] = y(
|
|
934
|
-
() => oe(W)
|
|
935
|
-
), [f, d] = y(z), u = E(!0), h = k((g) => {
|
|
936
|
-
c(g), K(re, g);
|
|
937
|
-
}, []), _ = k((g) => {
|
|
938
|
-
const S = g === null ? "__all__" : g;
|
|
939
|
-
i(S), K(W, S), d(z);
|
|
940
|
-
}, []), N = k(() => {
|
|
941
|
-
d((g) => g + z);
|
|
942
|
-
}, []), b = e ? rt(l, e, u.current) : l;
|
|
943
|
-
V(() => {
|
|
944
|
-
e && (u.current = !1, b !== l && (i(b), b !== null && b !== "__all__" && K(W, b)));
|
|
945
|
-
}, [e, b, l]);
|
|
946
|
-
const w = e ? Date.parse(e.serverTime) : Date.now(), L = e ? ue(e.tasks) : [], T = e ? ot(e) : {}, D = e ? e.agents.filter(
|
|
947
|
-
(g) => g.presence === "live" && C({ repo: g.repo ?? "" }, b)
|
|
948
|
-
).length : 0, A = e ? e.tasks.filter((g) => g.status === "active" && C(g, b)).length : 0, x = st[n], j = r === null ? "" : `updated ${Math.floor((Date.now() - r) / 1e3)}s ago`, P = (e == null ? void 0 : e.agents) ?? [], R = (e == null ? void 0 : e.tasks) ?? [], F = (e == null ? void 0 : e.announcements) ?? [], p = R.filter(
|
|
949
|
-
(g) => g.status === "active" && C(g, b)
|
|
950
|
-
).length, v = R.filter(
|
|
951
|
-
(g) => g.status !== "active" && C(g, b)
|
|
952
|
-
).length;
|
|
953
|
-
return /* @__PURE__ */ m("div", { id: "board", children: [
|
|
954
|
-
/* @__PURE__ */ m("header", { children: [
|
|
955
|
-
/* @__PURE__ */ s("span", { className: "brand", children: "Shepherd" }),
|
|
956
|
-
/* @__PURE__ */ s(
|
|
957
|
-
ze,
|
|
958
|
-
{
|
|
959
|
-
repos: L,
|
|
960
|
-
counts: T,
|
|
961
|
-
selected: b,
|
|
962
|
-
onSelect: _
|
|
963
|
-
}
|
|
964
|
-
),
|
|
965
|
-
/* @__PURE__ */ m("span", { className: "vitals", children: [
|
|
966
|
-
/* @__PURE__ */ s("b", { id: "vitals-online", children: D }),
|
|
967
|
-
" online · ",
|
|
968
|
-
/* @__PURE__ */ s("b", { id: "vitals-active", children: A }),
|
|
969
|
-
" active"
|
|
970
|
-
] }),
|
|
971
|
-
/* @__PURE__ */ s("span", { className: "grow" }),
|
|
972
|
-
/* @__PURE__ */ s("span", { id: "status", className: "status" + (x.kind ? ` status--${x.kind}` : ""), children: x.text }),
|
|
973
|
-
/* @__PURE__ */ s("span", { id: "freshness", className: "freshness", children: j }),
|
|
974
|
-
/* @__PURE__ */ m("nav", { className: "tabs", role: "tablist", "aria-label": "Dashboard views", children: [
|
|
975
|
-
/* @__PURE__ */ s(
|
|
976
|
-
"button",
|
|
977
|
-
{
|
|
978
|
-
className: "tab" + (a === "tasks" ? " tab--active" : ""),
|
|
979
|
-
"data-tab": "tasks",
|
|
980
|
-
type: "button",
|
|
981
|
-
role: "tab",
|
|
982
|
-
id: "tab-tasks",
|
|
983
|
-
"aria-controls": "panel-tasks",
|
|
984
|
-
"aria-selected": a === "tasks",
|
|
985
|
-
onClick: () => h("tasks"),
|
|
986
|
-
children: "Tasks"
|
|
987
|
-
}
|
|
988
|
-
),
|
|
989
|
-
/* @__PURE__ */ s(
|
|
990
|
-
"button",
|
|
991
|
-
{
|
|
992
|
-
className: "tab" + (a === "chat" ? " tab--active" : ""),
|
|
993
|
-
"data-tab": "chat",
|
|
994
|
-
type: "button",
|
|
995
|
-
role: "tab",
|
|
996
|
-
id: "tab-chat",
|
|
997
|
-
"aria-controls": "panel-chat",
|
|
998
|
-
"aria-selected": a === "chat",
|
|
999
|
-
onClick: () => h("chat"),
|
|
1000
|
-
children: "Chat"
|
|
1001
|
-
}
|
|
1002
|
-
)
|
|
1003
|
-
] })
|
|
1004
|
-
] }),
|
|
1005
|
-
/* @__PURE__ */ m(
|
|
1006
|
-
"section",
|
|
1007
|
-
{
|
|
1008
|
-
id: "panel-tasks",
|
|
1009
|
-
role: "tabpanel",
|
|
1010
|
-
"aria-labelledby": "tab-tasks",
|
|
1011
|
-
hidden: a !== "tasks",
|
|
1012
|
-
children: [
|
|
1013
|
-
/* @__PURE__ */ s(Ke, { agents: P, tasks: R, selectedRepo: b }),
|
|
1014
|
-
/* @__PURE__ */ m("div", { className: "board", children: [
|
|
1015
|
-
/* @__PURE__ */ m("div", { className: "col", children: [
|
|
1016
|
-
/* @__PURE__ */ m("div", { className: "colhead", children: [
|
|
1017
|
-
/* @__PURE__ */ s("h2", { children: "Active" }),
|
|
1018
|
-
/* @__PURE__ */ s("span", { className: "n", id: "active-count", children: p })
|
|
1019
|
-
] }),
|
|
1020
|
-
/* @__PURE__ */ s(Xe, { tasks: R, nowMs: w, selectedRepo: b })
|
|
1021
|
-
] }),
|
|
1022
|
-
/* @__PURE__ */ s("div", { className: "board__rule" }),
|
|
1023
|
-
/* @__PURE__ */ m("div", { className: "col", children: [
|
|
1024
|
-
/* @__PURE__ */ m("div", { className: "colhead", children: [
|
|
1025
|
-
/* @__PURE__ */ s("h2", { children: "Done" }),
|
|
1026
|
-
/* @__PURE__ */ s("span", { className: "n", id: "done-count", children: v })
|
|
1027
|
-
] }),
|
|
1028
|
-
/* @__PURE__ */ s(
|
|
1029
|
-
Qe,
|
|
1030
|
-
{
|
|
1031
|
-
tasks: R,
|
|
1032
|
-
nowMs: w,
|
|
1033
|
-
selectedRepo: b,
|
|
1034
|
-
doneShown: f,
|
|
1035
|
-
onLoadMore: N
|
|
1036
|
-
}
|
|
1037
|
-
)
|
|
1038
|
-
] })
|
|
1039
|
-
] })
|
|
1040
|
-
]
|
|
1041
|
-
}
|
|
1042
|
-
),
|
|
1043
|
-
/* @__PURE__ */ s(
|
|
1044
|
-
"section",
|
|
1045
|
-
{
|
|
1046
|
-
id: "panel-chat",
|
|
1047
|
-
role: "tabpanel",
|
|
1048
|
-
"aria-labelledby": "tab-chat",
|
|
1049
|
-
hidden: a !== "chat",
|
|
1050
|
-
children: /* @__PURE__ */ m("div", { className: "chat-wrap", children: [
|
|
1051
|
-
/* @__PURE__ */ s(tt, { announcements: F, selectedRepo: b, nowMs: w }),
|
|
1052
|
-
/* @__PURE__ */ s(at, { agents: P, selectedRepo: b, onSent: o })
|
|
1053
|
-
] })
|
|
1054
|
-
}
|
|
1055
|
-
)
|
|
1056
|
-
] });
|
|
1057
|
-
}
|
|
1058
|
-
export {
|
|
1059
|
-
ht as D,
|
|
1060
|
-
I as S,
|
|
1061
|
-
mt as a,
|
|
1062
|
-
ut as c,
|
|
1063
|
-
le as u
|
|
1064
|
-
};
|