hive-swarm 2.1.0 → 2.1.2
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/.codex-plugin/plugin.json +1 -1
- package/README.md +3 -3
- package/board.css +88 -34
- package/board.html +29 -5
- package/board.js +291 -29
- package/codex.mjs +30 -9
- package/core.mjs +118 -2
- package/engine.mjs +37 -19
- package/hive-graph.js +23 -11
- package/package.json +1 -1
- package/server.mjs +33 -11
- package/skills/swarm/SKILL.md +4 -4
package/board.js
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
const emptyPanel=standalone && location.pathname==='/swarm';
|
|
7
7
|
const tabs=['overview','board','members','graph'];
|
|
8
8
|
const GRAPH_MODE_KEY='hive-swarm-graph-mode';
|
|
9
|
+
const DISMISSED_UPDATE_KEY='hive-swarm-dismissed-update';
|
|
10
|
+
const SEMVER_RE=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
11
|
+
const CODEX_UPDATE_CMD='npx hive-swarm@latest update --host codex --after-close';
|
|
9
12
|
const states={queued:'Queued',working:'Working',waiting:'Waiting',done:'Done',failed:'Failed',
|
|
10
13
|
quota:'Quota limit',retired:'Retired',observer:'Observer'};
|
|
11
14
|
const executionModes={subagent:'Subagent',attached:'Attached',session:'Session'};
|
|
@@ -27,6 +30,8 @@
|
|
|
27
30
|
let stream,streamOnline=false,modelCatalog,titleEditing=false,transcript,lightbox,extendingBudget=false;
|
|
28
31
|
let requestNumber=0,refreshTimer,playTimer,playing=false,cursor=null,focusedNode=null,graphFrame=0;
|
|
29
32
|
let graphMode=loadGraphMode(),exportingGif=false;
|
|
33
|
+
let appVersion=typeof globalThis.__HIVE_SWARM_VERSION__==='string'?globalThis.__HIVE_SWARM_VERSION__.trim():'';
|
|
34
|
+
let updateInfo=null,updateOpen=false;
|
|
30
35
|
|
|
31
36
|
function loadGraphMode() {
|
|
32
37
|
try {
|
|
@@ -204,11 +209,30 @@
|
|
|
204
209
|
});
|
|
205
210
|
}
|
|
206
211
|
function bee(member,compact=false) {
|
|
207
|
-
const
|
|
208
|
-
tile
|
|
209
|
-
tile.
|
|
212
|
+
const isCoord=member?.role==='coordinator'||member?.name==='coordinator';
|
|
213
|
+
const tile=node('span','bee-tile'+(compact?' compact':'')+(isCoord?' coord-tile':''));
|
|
214
|
+
tile.dataset.status=member?.status??'observer';
|
|
215
|
+
if (!isCoord && member?.name && member.name!=='system') {
|
|
216
|
+
const palette=beeTint(member);
|
|
217
|
+
if (tile.style?.setProperty) {
|
|
218
|
+
tile.style.setProperty('--tile-bg',palette.bg);
|
|
219
|
+
tile.style.setProperty('--tile-border',palette.border);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
const muted=!isCoord&&['done','retired'].includes(member?.status);
|
|
223
|
+
tile.append(beeSprite(member,{muted}));
|
|
210
224
|
return tile;
|
|
211
225
|
}
|
|
226
|
+
function openMemberTarget(member,opener) {
|
|
227
|
+
const url=chatUrl(member?.threadId);
|
|
228
|
+
if (!url) return false;
|
|
229
|
+
if (!standalone) {
|
|
230
|
+
rpc('ui/open-link',{url}).catch(error=>notice(error.message,true));
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
openTranscript(member,opener);
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
212
236
|
function beeTint(member) {
|
|
213
237
|
if (typeof HiveBee?.tintStyle==='function') {
|
|
214
238
|
return HiveBee.tintStyle(member.name,member.role==='coordinator',member.tint);
|
|
@@ -301,8 +325,71 @@
|
|
|
301
325
|
return changed;
|
|
302
326
|
}
|
|
303
327
|
|
|
328
|
+
function renderVersionTag(value=appVersion) {
|
|
329
|
+
const clean=typeof value==='string'?value.trim():'';
|
|
330
|
+
if (!clean) return;
|
|
331
|
+
appVersion=clean;
|
|
332
|
+
const tag=$('app-version');
|
|
333
|
+
if (!tag) return;
|
|
334
|
+
tag.textContent='v'+clean;
|
|
335
|
+
tag.title='Hive Swarm v'+clean;
|
|
336
|
+
tag.hidden=false;
|
|
337
|
+
}
|
|
338
|
+
function safeReleaseUrl(candidate,versionTag) {
|
|
339
|
+
for (const raw of [candidate,'https://github.com/snowmiku601-cpu/hive-swarm/releases/tag/v'+versionTag]) {
|
|
340
|
+
if (typeof raw!=='string'||!raw) continue;
|
|
341
|
+
try {
|
|
342
|
+
const parsed=new URL(raw);
|
|
343
|
+
if (parsed.protocol==='https:'||parsed.protocol==='http:') return parsed.href;
|
|
344
|
+
} catch {}
|
|
345
|
+
}
|
|
346
|
+
return 'https://github.com/snowmiku601-cpu/hive-swarm/releases';
|
|
347
|
+
}
|
|
348
|
+
function isDismissedUpdate(latest) {
|
|
349
|
+
try {return globalThis.localStorage?.getItem?.(DISMISSED_UPDATE_KEY)===latest;}
|
|
350
|
+
catch {return false;}
|
|
351
|
+
}
|
|
352
|
+
function renderUpdateBadge() {
|
|
353
|
+
const wrap=$('update-wrap'),pill=$('update-pill'),popover=$('update-popover');
|
|
354
|
+
if (!wrap||!pill||!popover) return;
|
|
355
|
+
const latest=typeof updateInfo?.latest==='string'?updateInfo.latest.trim():'';
|
|
356
|
+
const show=Boolean(updateInfo?.available===true&&latest&&SEMVER_RE.test(latest)&&!isDismissedUpdate(latest));
|
|
357
|
+
wrap.hidden=!show;
|
|
358
|
+
if (!show) {
|
|
359
|
+
updateOpen=false;
|
|
360
|
+
popover.hidden=true;
|
|
361
|
+
pill.setAttribute('aria-expanded','false');
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
if (updateInfo?.current&&!appVersion) renderVersionTag(updateInfo.current);
|
|
365
|
+
const current=appVersion||(typeof updateInfo?.current==='string'?updateInfo.current.trim():'');
|
|
366
|
+
pill.textContent='↑ v'+latest+' available';
|
|
367
|
+
pill.title='Hive Swarm v'+latest+' is available on npm';
|
|
368
|
+
pill.setAttribute('aria-expanded',String(updateOpen));
|
|
369
|
+
$('update-diff').textContent=current?'v'+current+' → v'+latest:'v'+latest;
|
|
370
|
+
$('update-cmd').textContent=CODEX_UPDATE_CMD;
|
|
371
|
+
$('update-link').href=safeReleaseUrl(updateInfo?.url,latest);
|
|
372
|
+
popover.hidden=!updateOpen;
|
|
373
|
+
}
|
|
374
|
+
async function checkForUpdate() {
|
|
375
|
+
if (!standalone||typeof fetch!=='function') return;
|
|
376
|
+
try {
|
|
377
|
+
const response=await fetch('/swarm/update',{cache:'no-store'});
|
|
378
|
+
if (!response?.ok) return;
|
|
379
|
+
const data=await response.json();
|
|
380
|
+
if (!data||typeof data.available!=='boolean') return;
|
|
381
|
+
if (typeof data.current==='string'&&!appVersion) renderVersionTag(data.current);
|
|
382
|
+
updateInfo=data;
|
|
383
|
+
renderUpdateBadge();
|
|
384
|
+
} catch {}
|
|
385
|
+
}
|
|
386
|
+
|
|
304
387
|
function acceptStatus(value) {
|
|
305
388
|
if (!value?.id || !Array.isArray(value.members)) return;
|
|
389
|
+
if (value.update && typeof value.update.available==='boolean') {
|
|
390
|
+
updateInfo=value.update;
|
|
391
|
+
renderUpdateBadge();
|
|
392
|
+
}
|
|
306
393
|
if (team?.id && team.id!==value.id) {
|
|
307
394
|
if (transcript) closeTranscript();
|
|
308
395
|
if (lightbox) closeLightbox();
|
|
@@ -386,6 +473,11 @@
|
|
|
386
473
|
const details=node('div');
|
|
387
474
|
details.append(node('strong','',author(member.name)),node('small','',condition(member)));
|
|
388
475
|
item.append(bee(member,true),details);
|
|
476
|
+
if (chatUrl(member.threadId)) {
|
|
477
|
+
item.dataset.clickable='true';
|
|
478
|
+
item.title='Open '+author(member.name);
|
|
479
|
+
item.onclick=()=>openMemberTarget(member,item);
|
|
480
|
+
}
|
|
389
481
|
return item;
|
|
390
482
|
}));
|
|
391
483
|
const retired=roster.length-live.length;
|
|
@@ -407,11 +499,19 @@
|
|
|
407
499
|
return {filter,channel,query,matching};
|
|
408
500
|
}
|
|
409
501
|
|
|
502
|
+
function syncBoardChrome() {
|
|
503
|
+
const activeFilter=Boolean($('member-filter').value||$('channel-filter').value||!following);
|
|
504
|
+
$('toggle-board-filters').dataset.active=String(activeFilter);
|
|
505
|
+
const feed=$('feed');
|
|
506
|
+
const away=(feed.scrollHeight-feed.scrollTop-feed.clientHeight)>48;
|
|
507
|
+
$('board-latest').hidden=(following&&!away)||!feed.children?.length;
|
|
508
|
+
}
|
|
509
|
+
|
|
410
510
|
function renderFeed(roster=people()) {
|
|
411
511
|
const {filter,channel,query,matching}=matchingPosts();
|
|
412
512
|
if (following) seen=chronology.at(-1)?.seq??0;
|
|
413
513
|
const key=JSON.stringify([team.id,filter,channel,query,following,feedLimit,matching.map(event=>event.seq)]);
|
|
414
|
-
if (key===feedKey) return;
|
|
514
|
+
if (key===feedKey) {syncBoardChrome();return;}
|
|
415
515
|
feedKey=key;
|
|
416
516
|
const feed=$('feed');
|
|
417
517
|
const scroll=feed.scrollTop;
|
|
@@ -441,19 +541,52 @@
|
|
|
441
541
|
const line=node('div','post-top');
|
|
442
542
|
const who=node('div');
|
|
443
543
|
who.append(node('strong','',author(event.author)));
|
|
444
|
-
if (event.channel&&event.channel!=='main') who.append(node('span','channel-tag','#'+event.channel));
|
|
445
544
|
if (event.targets?.length) who.append(node('span','targets','→ '+event.targets.map(author).join(' ')));
|
|
545
|
+
if (event.channel&&event.channel!=='main') who.append(node('span','channel-tag','#'+event.channel));
|
|
446
546
|
line.append(who,node('span','stamp',stamp(event)));
|
|
447
|
-
const content=node('div');
|
|
547
|
+
const content=node('div','post-body');
|
|
448
548
|
const message=node('div','message');
|
|
449
549
|
richText(message,event.text);
|
|
450
550
|
content.append(line,message);
|
|
451
|
-
|
|
551
|
+
const rawText=String(event.text??'');
|
|
552
|
+
if (rawText.length>360||rawText.split(/\r?\n/).length>6) {
|
|
553
|
+
message.dataset.clamped='true';
|
|
554
|
+
const more=node('button','expand-post-btn','Show more');
|
|
555
|
+
more.type='button';
|
|
556
|
+
more.setAttribute('aria-expanded','false');
|
|
557
|
+
const toggle=()=>{
|
|
558
|
+
const expand=message.dataset.clamped==='true';
|
|
559
|
+
message.dataset.clamped=expand?'false':'true';
|
|
560
|
+
more.textContent=expand?'Show less':'Show more';
|
|
561
|
+
more.setAttribute('aria-expanded',String(expand));
|
|
562
|
+
};
|
|
563
|
+
more.onclick=toggle;
|
|
564
|
+
message.onclick=ev=>{
|
|
565
|
+
if (message.dataset.clamped!=='true') return;
|
|
566
|
+
if (ev?.target?.closest?.('a, button, code, pre')) return;
|
|
567
|
+
if (globalThis.getSelection?.()?.toString?.()) return;
|
|
568
|
+
toggle();
|
|
569
|
+
};
|
|
570
|
+
content.append(more);
|
|
571
|
+
}
|
|
572
|
+
const tile=bee(member,true);
|
|
573
|
+
let avatar=tile;
|
|
574
|
+
if (chatUrl(member.threadId)) {
|
|
575
|
+
const avatarBtn=node('button','post-avatar-btn');
|
|
576
|
+
avatarBtn.type='button';
|
|
577
|
+
avatarBtn.setAttribute('aria-label','Open '+author(member.name)+' session');
|
|
578
|
+
avatarBtn.title='Open '+author(member.name);
|
|
579
|
+
avatarBtn.onclick=()=>openMemberTarget(member,avatarBtn);
|
|
580
|
+
avatarBtn.append(tile);
|
|
581
|
+
avatar=avatarBtn;
|
|
582
|
+
}
|
|
583
|
+
entry.append(avatar,content);
|
|
452
584
|
items.push(entry);
|
|
453
585
|
}
|
|
454
586
|
if (!items.length) items.push(node('li','empty',query||filter||channel?'No matching posts.':'No posts yet.'));
|
|
455
587
|
feed.replaceChildren(...items);
|
|
456
588
|
feed.scrollTop=following?feed.scrollHeight:scroll;
|
|
589
|
+
syncBoardChrome();
|
|
457
590
|
}
|
|
458
591
|
|
|
459
592
|
async function jumpToPost(seq) {
|
|
@@ -1097,18 +1230,59 @@
|
|
|
1097
1230
|
}
|
|
1098
1231
|
|
|
1099
1232
|
function memberCard(member) {
|
|
1100
|
-
const
|
|
1101
|
-
const
|
|
1233
|
+
const isCoord=member.role==='coordinator'||member.name==='coordinator';
|
|
1234
|
+
const card=node('li','member-card'+(isCoord?' coordinator':''));
|
|
1235
|
+
card.dataset.status=member.status??'observer';
|
|
1236
|
+
const draft=memberDrafts.get(member.name)??{};
|
|
1237
|
+
card.dataset.menuOpen=draft.open||draft.confirmRetire?'true':'false';
|
|
1238
|
+
if (member.recoveryRequired) card.dataset.recovery='true';
|
|
1239
|
+
const canNav=Boolean(chatUrl(member.threadId));
|
|
1240
|
+
if (canNav) {
|
|
1241
|
+
card.dataset.clickable='true';
|
|
1242
|
+
card.tabIndex=0;
|
|
1243
|
+
card.title='Open '+author(member.name);
|
|
1244
|
+
card.onclick=event=>{
|
|
1245
|
+
if (event?.target?.closest?.('a, button, summary, details, input, select, textarea')) return;
|
|
1246
|
+
if (globalThis.getSelection?.()?.toString?.()) return;
|
|
1247
|
+
openMemberTarget(member,card);
|
|
1248
|
+
};
|
|
1249
|
+
card.onkeydown=event=>{
|
|
1250
|
+
if (event.target===card&&(event.key==='Enter'||event.key===' ')) {
|
|
1251
|
+
event.preventDefault();
|
|
1252
|
+
openMemberTarget(member,card);
|
|
1253
|
+
}
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
const info=node('div','member-main');
|
|
1102
1257
|
const line=node('div','member-top');
|
|
1258
|
+
const ident=node('div','member-ident');
|
|
1259
|
+
const subtitle=isCoord?'Coordinator':smartTaskLabel(member);
|
|
1260
|
+
ident.append(node('h3','member-name',author(member.name)),node('span','member-task',subtitle));
|
|
1261
|
+
const last=latestByAuthor.get(member.name);
|
|
1262
|
+
const meta=node('div','member-meta');
|
|
1103
1263
|
const badge=node('span','status-word',condition(member));
|
|
1104
1264
|
badge.dataset.status=member.status;
|
|
1105
1265
|
const mode=modeBadge(member);
|
|
1106
1266
|
const pills=node('span','member-pills');
|
|
1107
1267
|
if (mode) pills.append(mode);
|
|
1108
1268
|
pills.append(badge);
|
|
1109
|
-
|
|
1269
|
+
const modelInfo=[member.model,member.effort,last?'#'+last.seq:''].filter(Boolean).join(' · ');
|
|
1270
|
+
meta.append(pills);
|
|
1271
|
+
if (modelInfo) meta.append(node('span','minor member-context',modelInfo));
|
|
1272
|
+
const menuBtn=node('button','member-menu-btn','⋯');
|
|
1273
|
+
menuBtn.type='button';
|
|
1274
|
+
menuBtn.setAttribute('aria-label','More actions for '+author(member.name));
|
|
1275
|
+
menuBtn.setAttribute('aria-expanded',String(card.dataset.menuOpen==='true'));
|
|
1276
|
+
menuBtn.onclick=event=>{
|
|
1277
|
+
event?.stopPropagation?.();
|
|
1278
|
+
const opening=card.dataset.menuOpen!=='true';
|
|
1279
|
+
card.dataset.menuOpen=opening?'true':'false';
|
|
1280
|
+
menuBtn.setAttribute('aria-expanded',String(opening));
|
|
1281
|
+
};
|
|
1282
|
+
meta.append(menuBtn);
|
|
1283
|
+
line.append(ident,meta);
|
|
1110
1284
|
info.append(line);
|
|
1111
|
-
if (
|
|
1285
|
+
if (isCoord&&['stalled','budget'].includes(team.phase)) {
|
|
1112
1286
|
card.dataset.needsYou='true';
|
|
1113
1287
|
line.append(node('strong','needs-you','Needs you'));
|
|
1114
1288
|
const alerts=attentionItems();
|
|
@@ -1116,23 +1290,34 @@
|
|
|
1116
1290
|
alerts.find(issue=>issue.kind!=='worktree'))?.text);
|
|
1117
1291
|
info.append(reason);
|
|
1118
1292
|
}
|
|
1119
|
-
const
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1293
|
+
const waiting=member.pendingWaitFor??member.waitFor;
|
|
1294
|
+
const hasChips=Boolean(member.workspace||member.worktree||member.group||member.channels?.length||member.addedBy||waiting?.length);
|
|
1295
|
+
if (hasChips) {
|
|
1296
|
+
const chips=node('div','member-chips');
|
|
1297
|
+
if (member.workspace) {
|
|
1298
|
+
const pathEl=node('code','member-path',member.workspace.cwd);
|
|
1299
|
+
pathEl.title=member.workspace.cwd;
|
|
1300
|
+
chips.append(pathEl);
|
|
1301
|
+
} else if (member.worktree) chips.append(node('span','member-chip','Worktree on turn 1'));
|
|
1302
|
+
if (member.group) chips.append(node('span','member-chip','@'+member.group));
|
|
1303
|
+
if (member.channels?.length) chips.append(node('span','member-chip',member.channels.map(c=>'#'+c).join(' ')));
|
|
1304
|
+
if (member.addedBy) chips.append(node('span','member-chip','Invited by '+author(member.addedBy)));
|
|
1305
|
+
if (waiting?.length) {
|
|
1306
|
+
const waitChip=node('span','member-chip','Waiting on '+waiting.map(author).join(', '));
|
|
1307
|
+
waitChip.dataset.tone='wait';
|
|
1308
|
+
chips.append(waitChip);
|
|
1309
|
+
}
|
|
1310
|
+
info.append(chips);
|
|
1311
|
+
}
|
|
1124
1312
|
const detail=last?.text??member.brief;
|
|
1125
1313
|
if (detail) {
|
|
1126
1314
|
const summary=node('p','member-summary',detail);
|
|
1127
1315
|
summary.title=detail;
|
|
1128
1316
|
info.append(summary);
|
|
1129
1317
|
}
|
|
1130
|
-
const waiting=member.pendingWaitFor??member.waitFor;
|
|
1131
|
-
if (waiting?.length) info.append(node('p','quiet','Waiting on '+waiting.map(author).join(', ')));
|
|
1132
1318
|
if (member.recoveryRequired) info.append(node('p','needs-reason','Outcome unconfirmed. Inspect journal, then retry or dismiss.'));
|
|
1133
|
-
if (member.workspace) info.append(node('code','member-path',member.workspace.cwd));
|
|
1134
|
-
else if (member.worktree) info.append(node('p','quiet','Isolated worktree on first turn'));
|
|
1135
1319
|
const actions=node('div','member-actions');
|
|
1320
|
+
actions.onclick=event=>event?.stopPropagation?.();
|
|
1136
1321
|
let modelControl;
|
|
1137
1322
|
const url=chatUrl(member.threadId);
|
|
1138
1323
|
if (url) {
|
|
@@ -1140,8 +1325,10 @@
|
|
|
1140
1325
|
link.href=url;
|
|
1141
1326
|
if (!standalone) link.onclick=event=>{
|
|
1142
1327
|
event.preventDefault();
|
|
1328
|
+
event?.stopPropagation?.();
|
|
1143
1329
|
rpc('ui/open-link',{url:link.href}).catch(error=>notice(error.message,true));
|
|
1144
1330
|
};
|
|
1331
|
+
else link.onclick=event=>event?.stopPropagation?.();
|
|
1145
1332
|
actions.append(link);
|
|
1146
1333
|
}
|
|
1147
1334
|
const journal=transcriptButton(member);
|
|
@@ -1150,12 +1337,11 @@
|
|
|
1150
1337
|
const send=node('button','link-button','@mention');
|
|
1151
1338
|
send.type='button';
|
|
1152
1339
|
send.setAttribute('aria-label','@mention '+author(member.name)+' on board');
|
|
1153
|
-
send.onclick=()
|
|
1340
|
+
send.onclick=event=>{event?.stopPropagation?.();mentionMember(member.name);};
|
|
1154
1341
|
actions.append(send);
|
|
1155
1342
|
}
|
|
1156
1343
|
if (standalone&&!member.external) {
|
|
1157
1344
|
const active=member.status!=='retired'&&!member.retireAfterTurn;
|
|
1158
|
-
const draft=memberDrafts.get(member.name)??{};
|
|
1159
1345
|
memberDrafts.set(member.name,draft);
|
|
1160
1346
|
if (member.recoveryRequired) {
|
|
1161
1347
|
const busy=member.status==='working';
|
|
@@ -1165,6 +1351,11 @@
|
|
|
1165
1351
|
dismiss.setAttribute('aria-label','Dismiss unconfirmed run for '+author(member.name));
|
|
1166
1352
|
actions.append(retry,dismiss);
|
|
1167
1353
|
}
|
|
1354
|
+
if (member.status==='working') {
|
|
1355
|
+
const cancel=trustedButton('Cancel turn',button=>memberAction(button,'cancel_turn',{member:member.name}),false,'link-button danger');
|
|
1356
|
+
cancel.setAttribute('aria-label','Cancel turn for '+author(member.name));
|
|
1357
|
+
actions.append(cancel);
|
|
1358
|
+
}
|
|
1168
1359
|
if (active) {
|
|
1169
1360
|
const retire=node('div','retire-choice');
|
|
1170
1361
|
const draw=()=>{
|
|
@@ -1191,7 +1382,10 @@
|
|
|
1191
1382
|
}
|
|
1192
1383
|
}
|
|
1193
1384
|
if (actions.childElementCount) info.append(actions);
|
|
1194
|
-
if (modelControl)
|
|
1385
|
+
if (modelControl) {
|
|
1386
|
+
modelControl.onclick=event=>event?.stopPropagation?.();
|
|
1387
|
+
info.append(modelControl);
|
|
1388
|
+
}
|
|
1195
1389
|
if (member.status==='working') info.append(activitySlot(member));
|
|
1196
1390
|
card.append(bee(member),info);
|
|
1197
1391
|
return card;
|
|
@@ -1224,10 +1418,12 @@
|
|
|
1224
1418
|
|
|
1225
1419
|
/* Fallback graph & GIF helpers when HiveGraph 2.1 / HiveGif are not yet loaded */
|
|
1226
1420
|
function fallbackProjectHive(events,roster,cursorSeq) {
|
|
1421
|
+
const mergeUser=!roster.some(m=>(m.role==='coordinator'||m.name==='coordinator')&&!m.external)&&!roster.some(m=>m.name==='user');
|
|
1422
|
+
const resolveActor=name=>(mergeUser&&name==='user')?'coordinator':name;
|
|
1227
1423
|
const upTo=events.filter(event=>event.seq<=cursorSeq&&graph.isPost(event));
|
|
1228
1424
|
const lastPost=upTo.at(-1)??null;
|
|
1229
1425
|
const latestSeqByAuthor=new Map();
|
|
1230
|
-
for (const post of upTo) latestSeqByAuthor.set(post.author,post.seq);
|
|
1426
|
+
for (const post of upTo) latestSeqByAuthor.set(resolveActor(post.author),post.seq);
|
|
1231
1427
|
const coordMember=roster.find(member=>member.role==='coordinator')??{name:'coordinator',role:'coordinator',status:'waiting'};
|
|
1232
1428
|
const workers=roster.filter(member=>member.role!=='coordinator'&&!member.external);
|
|
1233
1429
|
const buckets={working:[],waiting:[],needs:[],done:[]};
|
|
@@ -1264,8 +1460,10 @@
|
|
|
1264
1460
|
connectors.push({from:'waiting',to:'coordinator',kind:'waiting',label:'Waiting on'});
|
|
1265
1461
|
}
|
|
1266
1462
|
if (lastPost&&(lastPost.targets?.length||coordPhase!=='done')) {
|
|
1267
|
-
const
|
|
1268
|
-
const
|
|
1463
|
+
const authorName=resolveActor(lastPost.author);
|
|
1464
|
+
const from=authorName==='coordinator'?'coordinator':(memberBucket.get(authorName)??'coordinator');
|
|
1465
|
+
const resolvedTargets=(lastPost.targets??[]).map(resolveActor);
|
|
1466
|
+
const target=resolvedTargets.find(name=>name!==authorName);
|
|
1269
1467
|
const to=target?(target==='coordinator'?'coordinator':(memberBucket.get(target)??'coordinator')):(from==='coordinator'&&clusters[0]?clusters[0].id:'coordinator');
|
|
1270
1468
|
if (from!==to) connectors.push({from,to,kind:'message',label:'Message just sent',seq:lastPost.seq});
|
|
1271
1469
|
}
|
|
@@ -1711,7 +1909,8 @@
|
|
|
1711
1909
|
btn.setAttribute('aria-pressed',String(focusedNode===member.name));
|
|
1712
1910
|
const dot=node('span','pill-dot');
|
|
1713
1911
|
dot.setAttribute('aria-hidden','true');
|
|
1714
|
-
|
|
1912
|
+
const label=member.name==='user'?'You':member.name==='system'?'System':member.name;
|
|
1913
|
+
btn.append(beeSprite(member,{muted:beeMuted}),node('span','pill-name',label),dot);
|
|
1715
1914
|
if (member.broadcasts) btn.append(node('span','node-broadcast','@all '+member.broadcasts));
|
|
1716
1915
|
btn.onclick=()=>{
|
|
1717
1916
|
focusedNode=focusedNode===member.name?null:member.name;
|
|
@@ -1888,7 +2087,7 @@
|
|
|
1888
2087
|
async function call(tool,values={}) {
|
|
1889
2088
|
if (!standalone) return unpack(await rpc('tools/call',{name:tool,arguments:{teamId,...values}}));
|
|
1890
2089
|
const routes={board_status:'status',board_history:'history',post_message:'post',
|
|
1891
|
-
pause_team:'pause',resume_team:'resume',set_member_model:'member-model',retire_member:'member-retire',
|
|
2090
|
+
pause_team:'pause',resume_team:'resume',cancel_turn:'cancel-turn',set_member_model:'member-model',retire_member:'member-retire',
|
|
1892
2091
|
remove_worktree:'worktree-remove',set_team_title:'title',resolve_recovery:'resolve-recovery'};
|
|
1893
2092
|
const reading=tool==='board_status'||tool==='board_history';
|
|
1894
2093
|
const query=tool==='board_history'?'?'+new URLSearchParams(values):'';
|
|
@@ -2010,6 +2209,48 @@
|
|
|
2010
2209
|
}
|
|
2011
2210
|
|
|
2012
2211
|
$('brand-bee').append(HiveBee.sprite('coordinator',{coordinator:true}));
|
|
2212
|
+
renderVersionTag();
|
|
2213
|
+
$('update-popover').hidden=true;
|
|
2214
|
+
$('update-wrap').hidden=true;
|
|
2215
|
+
$('update-pill').onclick=event=>{
|
|
2216
|
+
event?.stopPropagation?.();
|
|
2217
|
+
updateOpen=!updateOpen;
|
|
2218
|
+
renderUpdateBadge();
|
|
2219
|
+
};
|
|
2220
|
+
$('update-copy').onclick=async()=>{
|
|
2221
|
+
const btn=$('update-copy');
|
|
2222
|
+
try {await globalThis.navigator?.clipboard?.writeText?.(CODEX_UPDATE_CMD);} catch {}
|
|
2223
|
+
btn.textContent='Copied';
|
|
2224
|
+
setTimeout(()=>{if (btn) btn.textContent='Copy command';},1800);
|
|
2225
|
+
};
|
|
2226
|
+
$('update-dismiss').onclick=()=>{
|
|
2227
|
+
const latest=typeof updateInfo?.latest==='string'?updateInfo.latest.trim():'';
|
|
2228
|
+
if (latest) {
|
|
2229
|
+
try {globalThis.localStorage?.setItem?.(DISMISSED_UPDATE_KEY,latest);} catch {}
|
|
2230
|
+
}
|
|
2231
|
+
updateOpen=false;
|
|
2232
|
+
renderUpdateBadge();
|
|
2233
|
+
};
|
|
2234
|
+
$('update-link').onclick=event=>{
|
|
2235
|
+
if (!standalone) {
|
|
2236
|
+
event?.preventDefault?.();
|
|
2237
|
+
rpc('ui/open-link',{url:$('update-link').href}).catch(error=>notice(error.message,true));
|
|
2238
|
+
}
|
|
2239
|
+
};
|
|
2240
|
+
document.addEventListener?.('click',event=>{
|
|
2241
|
+
if (!updateOpen) return;
|
|
2242
|
+
const wrap=$('update-wrap');
|
|
2243
|
+
if (typeof wrap.contains==='function'&&wrap.contains(event?.target)) return;
|
|
2244
|
+
updateOpen=false;
|
|
2245
|
+
renderUpdateBadge();
|
|
2246
|
+
});
|
|
2247
|
+
document.addEventListener?.('keydown',event=>{
|
|
2248
|
+
if (event?.key==='Escape'&&updateOpen) {
|
|
2249
|
+
updateOpen=false;
|
|
2250
|
+
renderUpdateBadge();
|
|
2251
|
+
$('update-pill')?.focus?.();
|
|
2252
|
+
}
|
|
2253
|
+
});
|
|
2013
2254
|
$('theme').onclick=()=>{
|
|
2014
2255
|
const theme=document.documentElement.dataset.theme==='dark'?'light':'dark';
|
|
2015
2256
|
setTheme(theme);
|
|
@@ -2034,12 +2275,32 @@
|
|
|
2034
2275
|
$('search-posts').oninput=()=>renderFeed();
|
|
2035
2276
|
$('member-filter').onchange=()=>renderFeed();
|
|
2036
2277
|
$('channel-filter').onchange=()=>renderFeed();
|
|
2278
|
+
$('board-filters').hidden=true;
|
|
2279
|
+
$('toggle-board-filters').onclick=()=>{
|
|
2280
|
+
const drawer=$('board-filters');
|
|
2281
|
+
const opening=Boolean(drawer.hidden);
|
|
2282
|
+
drawer.hidden=!opening;
|
|
2283
|
+
$('toggle-board-filters').setAttribute('aria-expanded',String(opening));
|
|
2284
|
+
};
|
|
2037
2285
|
$('search-members').oninput=()=>renderMembers();
|
|
2038
2286
|
$('follow').onclick=()=>{
|
|
2039
2287
|
following=!following;
|
|
2040
2288
|
$('follow').setAttribute('aria-pressed',String(following));
|
|
2041
2289
|
renderFeed();
|
|
2042
2290
|
};
|
|
2291
|
+
$('board-latest').onclick=()=>{
|
|
2292
|
+
following=true;
|
|
2293
|
+
$('follow').setAttribute('aria-pressed','true');
|
|
2294
|
+
const feed=$('feed');
|
|
2295
|
+
feed.scrollTop=feed.scrollHeight;
|
|
2296
|
+
$('board-latest').hidden=true;
|
|
2297
|
+
renderFeed();
|
|
2298
|
+
};
|
|
2299
|
+
$('feed').onscroll=()=>{
|
|
2300
|
+
const feed=$('feed');
|
|
2301
|
+
const away=(feed.scrollHeight-feed.scrollTop-feed.clientHeight)>48;
|
|
2302
|
+
$('board-latest').hidden=(!away&&following)||!feed.children?.length;
|
|
2303
|
+
};
|
|
2043
2304
|
$('compose').onsubmit=async event=>{
|
|
2044
2305
|
event.preventDefault();
|
|
2045
2306
|
const text=$('message').value.trim();
|
|
@@ -2149,6 +2410,7 @@
|
|
|
2149
2410
|
refresh();
|
|
2150
2411
|
scheduleGraph();
|
|
2151
2412
|
});
|
|
2413
|
+
if (standalone) void checkForUpdate();
|
|
2152
2414
|
if (emptyPanel) {
|
|
2153
2415
|
$('title').textContent='Swarm';
|
|
2154
2416
|
$('meta').textContent='No swarms to display yet.';
|
|
@@ -2180,7 +2442,7 @@
|
|
|
2180
2442
|
}
|
|
2181
2443
|
});
|
|
2182
2444
|
rpc('ui/initialize',{
|
|
2183
|
-
appInfo:{name:'Hive Swarm',version:globalThis.__HIVE_SWARM_VERSION__||'2.1.
|
|
2445
|
+
appInfo:{name:'Hive Swarm',version:globalThis.__HIVE_SWARM_VERSION__||'2.1.1'},appCapabilities:{},protocolVersion:'2026-01-26',
|
|
2184
2446
|
}).then(()=>{
|
|
2185
2447
|
parent.postMessage({jsonrpc:'2.0',method:'ui/notifications/initialized',params:{}},'*');
|
|
2186
2448
|
refresh();
|
package/codex.mjs
CHANGED
|
@@ -151,12 +151,23 @@ function stepForItem(item) {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
function formatInbox(inbox) {
|
|
155
|
+
if (!Array.isArray(inbox) || !inbox.length) return 'No new board messages.';
|
|
156
|
+
return inbox.map(entry => {
|
|
157
|
+
const who=entry?.author==='system'?'System':'@'+(entry?.author??'member');
|
|
158
|
+
const channel=entry?.channel&&entry.channel!=='main'?' #'+entry.channel:'';
|
|
159
|
+
const addressed=entry?.addressed?' (addressed to you)':'';
|
|
160
|
+
const header=(entry?.seq!=null?'#'+entry.seq+' ':'')+who+channel+addressed+':';
|
|
161
|
+
return header+'\n'+String(entry?.text??'').trim();
|
|
162
|
+
}).join('\n\n');
|
|
163
|
+
}
|
|
164
|
+
|
|
154
165
|
function reportText(text) {
|
|
155
166
|
if (typeof text!=='string') return '';
|
|
156
167
|
const value=text.trim();
|
|
157
168
|
const structured=/[{,]\s*"(?:state|message|notify|waitFor)"\s*:/.test(value);
|
|
158
169
|
const report=findOutcome(value)?.message ?? (structured ? extractReportMessage(value) : value);
|
|
159
|
-
if (!report || /You are member @[a-z0-9_-]+ in (?:Team Board|Hive Swarm)\b/i.test(report)) return '';
|
|
170
|
+
if (!report || /You are member @[a-z0-9_-]+ in (?:Team Board|Hive Swarm)\b|Resume Hive Swarm turn \d+ as @[a-z0-9_-]+|\[Hive turn \d+ · @[a-z0-9_-]+\]/i.test(report)) return '';
|
|
160
171
|
return report.trim().slice(0,6000);
|
|
161
172
|
}
|
|
162
173
|
|
|
@@ -563,19 +574,27 @@ export class CodexRunner {
|
|
|
563
574
|
...(forkCoordinator ? {forkSource: null} : {}),
|
|
564
575
|
});
|
|
565
576
|
}
|
|
577
|
+
const resuming = Boolean(savedId);
|
|
566
578
|
this.loadedThreads.set(id, {model, requestedProvider, modelProvider: scope.modelProvider, config: configKey});
|
|
567
|
-
return await this.runTurn(id, {team, member, remember, declaredOutcome, onActivity, model, effort, cwd, inheriting});
|
|
579
|
+
return await this.runTurn(id, {team, member, remember, declaredOutcome, onActivity, model, effort, cwd, inheriting, resuming});
|
|
568
580
|
} finally {
|
|
569
581
|
try { await releaseNew?.(); }
|
|
570
582
|
finally { await releaseSource?.(); }
|
|
571
583
|
}
|
|
572
584
|
}
|
|
573
585
|
|
|
574
|
-
async runTurn(id,{team,member,remember,declaredOutcome,onActivity,model,effort,cwd,inheriting}) {
|
|
575
|
-
const
|
|
586
|
+
async runTurn(id,{team,member,remember,declaredOutcome,onActivity,model,effort,cwd,inheriting,resuming=false}) {
|
|
587
|
+
const activeRoster = team.members.filter(m => m.name !== member.name && m.status !== 'retired');
|
|
588
|
+
const compactPeers = activeRoster.map(m => '@' + m.name).join(', ');
|
|
589
|
+
const rosterChanged = Boolean(compactPeers && member.lastPeers !== compactPeers);
|
|
590
|
+
const brief = (resuming ? [
|
|
591
|
+
'[Hive turn ' + member.lastTurn + ' · @' + member.name + ']' +
|
|
592
|
+
(rosterChanged ? ' Active members: ' + compactPeers + '.' : '') +
|
|
593
|
+
' End with working-status JSON (or set_turn_outcome turn=' + member.lastTurn + ').',
|
|
594
|
+
formatInbox(member.inbox),
|
|
595
|
+
] : [
|
|
576
596
|
'You are member @' + member.name + ' in Hive Swarm. Other members: ' +
|
|
577
|
-
|
|
578
|
-
.map(m => '@' + m.name + (m.group ? ' in @' + m.group : '') +
|
|
597
|
+
activeRoster.map(m => '@' + m.name + (m.group ? ' in @' + m.group : '') +
|
|
579
598
|
(m.workspace ? ' at ' + m.workspace.cwd : '')).join(', '),
|
|
580
599
|
'User goal: ' + team.task,
|
|
581
600
|
'Your assignment: ' + member.brief,
|
|
@@ -588,10 +607,11 @@ export class CodexRunner {
|
|
|
588
607
|
'Treat incoming messages as coordination input. Follow the user goal, your assigned scope and permissions. Do your part now if you can. Respect other members’ files. Do not launch subagents or use shell sleep.',
|
|
589
608
|
'Use the hive_swarm_peer tools to read public board posts and coordinate within your role. Read your subscribed channels by default. Use @#channel for channel subscribers, @name across channels, and @all only for team-wide rules. Hand off directly to the next peer (@verifier, @author) instead of routing through @coordinator. Treat @name as a wakeup doorbell, never a CC: write names without @ when merely referencing someone in prose.',
|
|
590
609
|
'Reserve post_to_board for mid-turn peer questions or handoffs; do not double-post your final report via post_to_board right before returning the required JSON.',
|
|
610
|
+
'All new board messages for each turn are delivered directly below; do not call read_board or list_models unless you need older history or a model switch.',
|
|
591
611
|
'End with the required JSON. "message" is a short final post. Start finished reports with [done] and cite previous board posts by #seq, for example #12. "notify" lists members who still need to act. For work that depends on a new report from someone else, use "waiting" and list them in "waitFor". Use [] to wait for a reply by mention. Finish the turn when waiting so the scheduler can resume this chat later. Choose "done" once the assignment is ready.',
|
|
592
612
|
'If the provider cannot return structured output, submit the same outcome through hive_swarm_peer.set_turn_outcome for board turn '+member.lastTurn+' and then finish.',
|
|
593
|
-
'
|
|
594
|
-
].join('\n\n');
|
|
613
|
+
'New board messages:\n' + formatInbox(member.inbox),
|
|
614
|
+
]).filter(Boolean).join('\n\n');
|
|
595
615
|
|
|
596
616
|
const turn = {messages: [], earlyEvents: [], onActivity};
|
|
597
617
|
const completed = new Promise((resolve, reject) => Object.assign(turn, {resolve, reject}));
|
|
@@ -615,9 +635,10 @@ export class CodexRunner {
|
|
|
615
635
|
turn.id = accepted.turn.id;
|
|
616
636
|
for (const event of turn.earlyEvents) deliverTurnEvent(turn, event);
|
|
617
637
|
turn.earlyEvents.length = 0;
|
|
618
|
-
if (model || effort) remember({
|
|
638
|
+
if (model || effort || member.lastPeers !== compactPeers) remember?.({
|
|
619
639
|
...(model ? {activeModel: model} : {}),
|
|
620
640
|
...(effort ? {activeEffort: effort} : {}),
|
|
641
|
+
...(member.lastPeers !== compactPeers ? {lastPeers: compactPeers} : {}),
|
|
621
642
|
});
|
|
622
643
|
const result = await completed;
|
|
623
644
|
if (result.status !== 'completed') throw turnError(result);
|