@hivey/cli 0.9.68 → 0.9.71
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/native/darwin-arm64/hivey +0 -0
- package/package.json +1 -1
- package/repo/plugins/slack-relay/relay.py +70 -5
- package/repo/plugins/slack-relay/test_relay.py +43 -0
- package/repo/skills/hivey-agent-creator/SKILL.md +1 -1
- package/repo/skills/hivey-agent-creator/scripts/agent_gate.py +54 -1
- package/repo/skills/hivey-agent-creator/scripts/status_check.py +121 -0
- package/repo/skills/hivey-agent-map/SKILL.md +11 -11
- package/repo/skills/hivey-agent-map/scripts/agent_map.py +8 -6
- package/repo/skills/hivey-agent-map/scripts/enhance.py +6 -2
- package/repo/skills/hivey-agent-map/scripts/{office/office.html → fleet/fleet.html} +21 -8
- package/repo/skills/hivey-agent-map/scripts/{office/office.js → fleet/fleet.js} +83 -46
- package/repo/skills/hivey-agent-map/scripts/{office → fleet}/music/README.txt +1 -1
- package/repo/skills/hivey-agent-map/scripts/{office → fleet}/ship.js +2 -2
- package/repo/skills/hivey-agent-map/scripts/{office.py → fleet.py} +106 -23
- package/repo/skills/hivey-agent-map/scripts/report.py +4 -4
- package/repo/skills/hivey-agent-map/scripts/serve.py +140 -63
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/OutlineEffect.js +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/RoomEnvironment.js +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/loaders/GLTFLoader.js +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/LICENSE-kenney-space-kit.txt +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/LICENSE-kenney-space-station-kit.txt +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/LICENSE-robot.txt +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/astronautA.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/astronautB.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/barrels.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/barrels_rail.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/craft_cargoA.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/craft_racer.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/craft_speederA.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/desk_chairArms.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/desk_computer.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/machine_generator.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/machine_generatorLarge.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/machine_wireless.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/robot.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/satelliteDish_detailed.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/satelliteDish_large.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/station/Textures/colormap.png.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/station/chair-cushion-headrest.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/station/computer-system.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/station/computer-wide.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/station/container-flat.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/station/container-tall.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/station/container-wide.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/station/display-wall-wide.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/station/pipe-ring-colored.glb.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/music/space.mp3.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/music/space_02.mp3.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/music/track_01.mp3.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/music/track_02.mp3.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/music/track_03.mp3.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/music/track_04.mp3.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/music/track_05.mp3.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/music/track_06.mp3.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/music/track_07.mp3.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/music/track_08.mp3.b64 +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/postprocessing/EffectComposer.js +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/postprocessing/MaskPass.js +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/postprocessing/OutputPass.js +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/postprocessing/Pass.js +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/postprocessing/RenderPass.js +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/postprocessing/ShaderPass.js +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/postprocessing/UnrealBloomPass.js +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/shaders/CopyShader.js +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/shaders/LuminosityHighPassShader.js +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/shaders/OutputShader.js +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/three.module.min.js +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/utils/BufferGeometryUtils.js +0 -0
- /package/repo/skills/hivey-agent-map/scripts/{office → fleet}/utils/SkeletonUtils.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// hivey
|
|
2
|
-
// serve.py while this page is open). Three.js draws the
|
|
1
|
+
// hivey fleet: every live agent at a desk. Data: ./fleet.json (fleet.py, refreshed every 5 min by
|
|
2
|
+
// serve.py while this page is open). Three.js draws the fleet; the board and the list are plain HTML.
|
|
3
3
|
// Click an agent: open its terminal in hivey. Right-click (or ⓘ): details. Only working agents move.
|
|
4
4
|
import * as THREE from './three.module.min.js';
|
|
5
5
|
import { RoomEnvironment } from './RoomEnvironment.js';
|
|
@@ -22,13 +22,16 @@ const st = s => STATUS[s] || { label: s || '?', emoji: '•', color: '#64748b' }
|
|
|
22
22
|
const REDUCED = matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
23
23
|
|
|
24
24
|
let data = null, agents = [], selected = null;
|
|
25
|
-
|
|
26
|
-
ui.
|
|
25
|
+
// settings saved before the rename (the page was the agent office) carry over
|
|
26
|
+
const ui = JSON.parse(localStorage.getItem('hv-fleet-ship') || localStorage.getItem('hv-' + 'off' + 'ice-ship') || '{}');
|
|
27
|
+
ui.view ||= 'fleet';
|
|
28
|
+
const VIEWS = ['fleet', 'board', 'list', 'jobs'];
|
|
29
|
+
{ const v = new URLSearchParams(location.search).get('view'); if (VIEWS.includes(v)) ui.view = v; if (v) history.replaceState(null, '', location.pathname); } // ?view=jobs from the menu or a jobs page
|
|
27
30
|
ui.filter ||= null;
|
|
28
31
|
if (ui.toon === undefined) ui.toon = false;
|
|
29
|
-
const save = () => localStorage.setItem('hv-
|
|
30
|
-
// ship positions also live on the
|
|
31
|
-
const saveShips = () => { save(); fetch('/hv-
|
|
32
|
+
const save = () => localStorage.setItem('hv-fleet-ship', JSON.stringify({ view: ui.view, filter: ui.filter, toon: ui.toon, music: ui.music, ships: ui.ships, space: ui.space, track: ui.track }));
|
|
33
|
+
// ship positions also live on the fleet server, so every browser opens the fleet where you left it
|
|
34
|
+
const saveShips = () => { save(); fetch('/hv-fleet-settings', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ ships: ui.ships || {} }) }).catch(() => {}); };
|
|
32
35
|
|
|
33
36
|
// ---------------------------------------------------------------- helpers
|
|
34
37
|
function hue(name) { let h = 0; for (const c of name || '') h = (h * 31 + c.charCodeAt(0)) >>> 0; return h % 360; }
|
|
@@ -121,35 +124,35 @@ document.addEventListener('keydown', e => { if (e.key === 'Escape') closeShipMen
|
|
|
121
124
|
async function stopSession(name) {
|
|
122
125
|
toast(`Stopping session ${name}…`);
|
|
123
126
|
try {
|
|
124
|
-
const r = await fetch('/hv-
|
|
127
|
+
const r = await fetch('/hv-fleet-action', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action: 'stop-session', session: name }) });
|
|
125
128
|
const j = await r.json();
|
|
126
129
|
toast(j.message || (j.ok ? `Session ${name} stopped` : `Could not stop session ${name}`));
|
|
127
|
-
if (j.ok) fetch('/hv-
|
|
128
|
-
} catch (e) { toast('The
|
|
130
|
+
if (j.ok) fetch('/hv-fleet-refresh', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: '{"quick":true}' }).then(() => setTimeout(poll, 2500));
|
|
131
|
+
} catch (e) { toast('The fleet server is not answering: run `hivey agent-map fleet` again'); }
|
|
129
132
|
}
|
|
130
133
|
// click on a ship's name tag: that hivey session in a terminal (a new one if none shows it; starts a stopped one)
|
|
131
134
|
async function openSession(name, running) {
|
|
132
135
|
warpPing();
|
|
133
136
|
toast(running ? `Opening session ${name}…` : `Starting session ${name}…`);
|
|
134
137
|
try {
|
|
135
|
-
const r = await fetch('/hv-
|
|
138
|
+
const r = await fetch('/hv-fleet-action', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action: 'session', session: name }) });
|
|
136
139
|
const j = await r.json();
|
|
137
140
|
toast(j.message || (j.ok ? `Session ${name} opened` : `Could not open session ${name}`));
|
|
138
|
-
if (j.ok && !running) setTimeout(() => fetch('/hv-
|
|
139
|
-
} catch (e) { toast('The
|
|
141
|
+
if (j.ok && !running) setTimeout(() => fetch('/hv-fleet-refresh', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: '{"quick":true}' }).then(() => setTimeout(poll, 2500)), 4000);
|
|
142
|
+
} catch (e) { toast('The fleet server is not answering: run `hivey agent-map fleet` again'); }
|
|
140
143
|
}
|
|
141
144
|
async function act(a, action) {
|
|
142
145
|
if (action === 'focus' || action === 'compact') {
|
|
143
146
|
warpPing();
|
|
144
147
|
toast(action === 'focus' ? `Opening ${a.name} in hivey…` : `Compacting ${a.name}…`);
|
|
145
|
-
|
|
148
|
+
fleet.flash(a.id);
|
|
146
149
|
document.querySelectorAll(`[data-id="${CSS.escape(a.id)}"]`).forEach(el => { el.classList.remove('flash'); void el.offsetWidth; el.classList.add('flash'); });
|
|
147
150
|
}
|
|
148
151
|
try {
|
|
149
|
-
const r = await fetch('/hv-
|
|
152
|
+
const r = await fetch('/hv-fleet-action', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: a.id, pane: a.pane, action }) });
|
|
150
153
|
const j = await r.json();
|
|
151
154
|
toast(j.ok && action === 'focus' && !/new terminal/.test(j.message || '') ? `${a.name} is open in hivey ↗` : `${a.name}: ${j.message}`);
|
|
152
|
-
} catch (e) { toast('The
|
|
155
|
+
} catch (e) { toast('The fleet server is not answering: run `hivey agent-map fleet` again'); }
|
|
153
156
|
}
|
|
154
157
|
// clear needs a second click within 3 s (no browser dialogs); compact goes at once
|
|
155
158
|
function armed(btn, a, action) {
|
|
@@ -197,7 +200,7 @@ function renderHeader() {
|
|
|
197
200
|
$('#pills').querySelectorAll('.pill').forEach(p => p.onclick = () => { ui.filter = ui.filter === p.dataset.f ? null : p.dataset.f; save(); renderAll(); });
|
|
198
201
|
tickSub();
|
|
199
202
|
}
|
|
200
|
-
let every = 'minute'; // the refresh setting, kept by the
|
|
203
|
+
let every = 'minute'; // the refresh setting, kept by the fleet server (shared by every open page)
|
|
201
204
|
const EVERY_S = { minute: 60, '5min': 300, '15min': 900, '1h': 3600 };
|
|
202
205
|
function tickSub() {
|
|
203
206
|
if (!data) return;
|
|
@@ -287,6 +290,12 @@ function openDrawer(a) {
|
|
|
287
290
|
${(s.done || []).length ? `<dt>Achieved</dt><dd>${s.done.map(d => '✓ ' + esc(d)).join('<br>')}</dd>` : ''}
|
|
288
291
|
${s.next ? `<dt>Next</dt><dd>→ ${esc(s.next)}</dd>` : ''}
|
|
289
292
|
${a.about ? `<dt>About</dt><dd>${esc(a.about)}</dd>` : ''}
|
|
293
|
+
${a.wiki ? `<dt>📚 Wiki</dt><dd class="wiki">
|
|
294
|
+
<div class="wiki-head"><a href="#" data-wiki="" title="Open its index in Obsidian">${esc(a.wiki.short)}</a> <span class="meta">${a.wiki.pages} pages${a.wiki.vault ? '' : ' · not an Obsidian vault yet'}</span></div>
|
|
295
|
+
${(a.wiki.recent || []).length ? `<div class="meta wiki-sub">Newest pages and reports</div>` + a.wiki.recent.map(r => `<a href="#" class="wiki-page" data-wiki="${esc(r.path)}" title="${esc(r.path)}: open in Obsidian">
|
|
296
|
+
<span class="wt">${/report|daily|brief/i.test(r.path) ? '📊' : '📄'} ${esc(r.title)}</span><span class="meta">${esc(r.folder || '')}${r.folder ? ' · ' : ''}${ago(r.at)}</span></a>`).join('') : ''}
|
|
297
|
+
${(a.wiki.log || []).length ? `<div class="meta wiki-sub">Latest log entries</div>` + a.wiki.log.map(l => `<div class="wiki-log"><span class="meta">${esc(l.date)}</span> ${esc(l.what)}</div>`).join('') : ''}
|
|
298
|
+
</dd>` : ''}
|
|
290
299
|
${a.team?.length ? `<dt>Swarm team</dt><dd>${a.team.map(m => `${st(m.status).emoji} ${esc(m.name)} <span class="meta">${esc(m.role)}</span>`).join('<br>')}</dd>` : ''}
|
|
291
300
|
${a.last_prompt ? `<dt>Your last prompt</dt><dd>${esc(a.last_prompt)}</dd>` : ''}
|
|
292
301
|
${a.recap ? `<dt>Session recap</dt><dd>${esc(a.recap)}</dd>` : ''}
|
|
@@ -303,9 +312,17 @@ function openDrawer(a) {
|
|
|
303
312
|
const el = $('#drawer');
|
|
304
313
|
el.dataset.id = a.id;
|
|
305
314
|
wireDrawer(a);
|
|
306
|
-
|
|
315
|
+
fleet.markSelected();
|
|
307
316
|
}
|
|
308
317
|
function wireDrawer(a) {
|
|
318
|
+
$('#drawer').querySelectorAll('[data-wiki]').forEach(l => l.onclick = async e => {
|
|
319
|
+
e.preventDefault(); e.stopPropagation();
|
|
320
|
+
try {
|
|
321
|
+
const r = await fetch('/hv-fleet-action', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: a.id, action: 'wiki', path: l.dataset.wiki }) });
|
|
322
|
+
const j = await r.json();
|
|
323
|
+
toast(j.ok ? `📚 ${j.message}` : `${a.name}: ${j.message}`);
|
|
324
|
+
} catch (err) { toast('The fleet server is not answering: run `hivey agent-map fleet` again'); }
|
|
325
|
+
});
|
|
309
326
|
$('#drawer').querySelectorAll('button[data-act]').forEach(b => b.onclick = e => {
|
|
310
327
|
e.stopPropagation();
|
|
311
328
|
if (b.disabled) return;
|
|
@@ -315,11 +332,11 @@ function wireDrawer(a) {
|
|
|
315
332
|
armed(b, a, k);
|
|
316
333
|
});
|
|
317
334
|
}
|
|
318
|
-
function closeDrawer() { $('#drawer').classList.remove('open'); selected = null;
|
|
335
|
+
function closeDrawer() { $('#drawer').classList.remove('open'); selected = null; fleet.markSelected(); }
|
|
319
336
|
|
|
320
|
-
// ---------------------------------------------------------------- the 3D
|
|
321
|
-
const
|
|
322
|
-
const host = $('#
|
|
337
|
+
// ---------------------------------------------------------------- the 3D fleet
|
|
338
|
+
const fleet = (() => {
|
|
339
|
+
const host = $('#fleet'), labels = $('#labels');
|
|
323
340
|
let renderer;
|
|
324
341
|
try { renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); } catch (e) { return { ok: false, build() {}, markSelected() {}, resize() {}, fit() {}, flash() {}, setSpace() {} }; }
|
|
325
342
|
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
|
|
@@ -685,7 +702,7 @@ const office = (() => {
|
|
|
685
702
|
cam.lookAt(target);
|
|
686
703
|
dirty = true;
|
|
687
704
|
}
|
|
688
|
-
// fit = project the
|
|
705
|
+
// fit = project the fleet's corners into the camera's view and frame them with a margin
|
|
689
706
|
function fit() {
|
|
690
707
|
target.set(bounds.cx, 0, bounds.cz);
|
|
691
708
|
placeCam(); cam.updateMatrixWorld();
|
|
@@ -850,7 +867,7 @@ const office = (() => {
|
|
|
850
867
|
let last = 0, lastCode = 0;
|
|
851
868
|
function frame(t) {
|
|
852
869
|
requestAnimationFrame(frame);
|
|
853
|
-
if (document.hidden || ui.view !== '
|
|
870
|
+
if (document.hidden || ui.view !== 'fleet') return;
|
|
854
871
|
const busy = flashes.length > 0 || (!REDUCED && desks.some(d => d.a.status === 'working' || d.a.status === 'blocked' || d.team.some(m => m.status === 'working')));
|
|
855
872
|
const moving = busy || (!REDUCED && ship.thrusting());
|
|
856
873
|
const dt = Math.min(0.1, (t - (frame.prev || t)) / 1000); frame.prev = t;
|
|
@@ -915,33 +932,53 @@ function renderAll() {
|
|
|
915
932
|
renderHeader();
|
|
916
933
|
renderInbox();
|
|
917
934
|
document.querySelectorAll('#views button').forEach(b => b.classList.toggle('on', b.dataset.v === ui.view));
|
|
918
|
-
$('#
|
|
935
|
+
$('#fleet').style.display = ui.view === 'fleet' ? '' : 'none';
|
|
919
936
|
$('#board').style.display = ui.view === 'board' ? 'block' : 'none';
|
|
920
937
|
$('#list').style.display = ui.view === 'list' ? 'block' : 'none';
|
|
921
|
-
|
|
938
|
+
showJobs();
|
|
939
|
+
if (ui.view === 'fleet') { fleet.build(agents.filter(visible), data.sessions); fleet.resize(); }
|
|
922
940
|
if (ui.view === 'board') renderBoard();
|
|
923
941
|
if (ui.view === 'list') renderList();
|
|
924
942
|
if (selected) { const a = agents.find(x => x.id === selected); if (a && $('#drawer').classList.contains('open')) openDrawer(a); }
|
|
925
943
|
}
|
|
944
|
+
// the agent jobs pages (Map, Stats, Logs, Sessions) in a frame, loaded the first time the tab opens;
|
|
945
|
+
// the server redirects /hv-jobs to the latest report or builds the first one
|
|
946
|
+
function showJobs() {
|
|
947
|
+
const on = ui.view === 'jobs', frame = $('#jobsframe');
|
|
948
|
+
document.body.classList.toggle('v-jobs', on);
|
|
949
|
+
$('#jobs').style.display = on ? 'block' : 'none';
|
|
950
|
+
if (!on) return;
|
|
951
|
+
if (!frame.dataset.loaded) { // an older page server has no /hv-jobs: the latest map straight away
|
|
952
|
+
frame.dataset.loaded = '1';
|
|
953
|
+
fetch('/hv-jobs', { cache: 'no-store' }).then(r => { frame.src = r.ok ? r.url : '/latest/agent-map.html'; })
|
|
954
|
+
.catch(() => { frame.src = '/latest/agent-map.html'; });
|
|
955
|
+
}
|
|
956
|
+
fitJobs();
|
|
957
|
+
}
|
|
958
|
+
function fitJobs() {
|
|
959
|
+
const frame = $('#jobsframe');
|
|
960
|
+
if (ui.view === 'jobs') frame.style.height = Math.max(420, innerHeight - frame.getBoundingClientRect().top) + 'px';
|
|
961
|
+
}
|
|
962
|
+
addEventListener('resize', fitJobs);
|
|
926
963
|
async function poll() {
|
|
927
964
|
try {
|
|
928
|
-
if (
|
|
929
|
-
const r = await fetch('./
|
|
965
|
+
if (fleet.ready) await fleet.ready.catch(() => {});
|
|
966
|
+
const r = await fetch('./fleet.json?ts=' + Date.now(), { cache: 'no-store' });
|
|
930
967
|
const j = await r.json();
|
|
931
968
|
if (j.generated !== lastGenerated) {
|
|
932
969
|
lastGenerated = j.generated; data = j;
|
|
933
|
-
if (refreshing && Date.parse(j.generated) > refreshing) { refreshing = false; $('#refresh').innerHTML = '⟳'; toast('
|
|
970
|
+
if (refreshing && Date.parse(j.generated) > refreshing) { refreshing = false; $('#refresh').innerHTML = '⟳'; toast('Fleet updated'); }
|
|
934
971
|
renderAll();
|
|
935
972
|
}
|
|
936
|
-
} catch (e) { console.error('hivey fleet:', e); $('#sub').textContent = 'cannot read
|
|
973
|
+
} catch (e) { console.error('hivey fleet:', e); $('#sub').textContent = 'cannot read fleet.json: is the fleet server running? (hivey menu → agent fleet)'; }
|
|
937
974
|
}
|
|
938
975
|
async function refreshNow() {
|
|
939
976
|
if (refreshing) return;
|
|
940
977
|
refreshing = Date.now();
|
|
941
978
|
$('#refresh').innerHTML = '<span class="spin">⟳</span>';
|
|
942
979
|
tickSub();
|
|
943
|
-
try { await fetch('/hv-
|
|
944
|
-
catch (e) { toast('The
|
|
980
|
+
try { await fetch('/hv-fleet-refresh', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: '{}' }); }
|
|
981
|
+
catch (e) { toast('The fleet server is not answering'); refreshing = false; $('#refresh').innerHTML = '⟳'; }
|
|
945
982
|
setTimeout(() => { if (refreshing) { refreshing = false; $('#refresh').innerHTML = '⟳'; } }, 180000);
|
|
946
983
|
}
|
|
947
984
|
document.querySelectorAll('#views button').forEach(b => b.onclick = () => { ui.view = b.dataset.v; save(); renderAll(); });
|
|
@@ -1002,7 +1039,7 @@ $('#track').onchange = e => {
|
|
|
1002
1039
|
loadTrack(pickTrack());
|
|
1003
1040
|
if (!ui.music) setMusic(true); else bgm.play().catch(() => startOnTouch());
|
|
1004
1041
|
toast(ui.track === 'random' ? `A new track each time (now: ${TRACKS[trackNo - 1][1]})` : `Music: ${TRACKS[trackNo - 1][1]}, always`);
|
|
1005
|
-
post('/hv-
|
|
1042
|
+
post('/hv-fleet-settings', { track: ui.track }).catch(() => {});
|
|
1006
1043
|
};
|
|
1007
1044
|
if (ui.music) { loadTrack(pickTrack()); bgm.play().catch(() => startOnTouch()); }
|
|
1008
1045
|
// only while the page is in front of you: pause when you switch to the terminal or another app or tab
|
|
@@ -1010,7 +1047,7 @@ const inFront = () => !document.hidden && document.hasFocus();
|
|
|
1010
1047
|
function followFocus() { if (!ui.music) return; if (inFront()) bgm.play().catch(() => {}); else bgm.pause(); }
|
|
1011
1048
|
addEventListener('blur', followFocus); addEventListener('focus', followFocus);
|
|
1012
1049
|
document.addEventListener('visibilitychange', followFocus);
|
|
1013
|
-
$('#fit').onclick = () =>
|
|
1050
|
+
$('#fit').onclick = () => fleet.fit();
|
|
1014
1051
|
function toggleStyle() { ui.toon = !ui.toon; save(); $('#style').textContent = ui.toon ? '🎨 comic' : '✨ HD'; renderAll(); }
|
|
1015
1052
|
$('#style').onclick = toggleStyle;
|
|
1016
1053
|
$('#style').textContent = ui.toon ? '🎨 comic' : '✨ HD';
|
|
@@ -1020,14 +1057,14 @@ addEventListener('keydown', e => {
|
|
|
1020
1057
|
if (e.target.matches('input')) { if (e.key === 'Escape') { e.target.value = ''; e.target.blur(); renderAll(); } return; }
|
|
1021
1058
|
if (e.key === '/') { e.preventDefault(); $('#q').focus(); }
|
|
1022
1059
|
else if (e.key === 'Escape') closeDrawer();
|
|
1023
|
-
else if (e.key
|
|
1060
|
+
else if (e.key >= '1' && e.key <= '4') { ui.view = VIEWS[+e.key - 1]; save(); renderAll(); }
|
|
1024
1061
|
else if (e.key === 'r') refreshNow();
|
|
1025
|
-
else if (e.key === 'f')
|
|
1062
|
+
else if (e.key === 'f') fleet.fit();
|
|
1026
1063
|
else if (e.key === 't') toggleStyle();
|
|
1027
1064
|
else if (e.key === 'm') setMusic(!ui.music);
|
|
1028
1065
|
});
|
|
1029
|
-
if (!
|
|
1030
|
-
if (!
|
|
1066
|
+
if (!fleet.ok && ui.view === 'fleet') ui.view = 'board';
|
|
1067
|
+
if (!fleet.ok) document.querySelector('#views [data-v="fleet"]').disabled = true;
|
|
1031
1068
|
setInterval(poll, 15000);
|
|
1032
1069
|
setInterval(tickSub, 1000);
|
|
1033
1070
|
poll();
|
|
@@ -1040,26 +1077,26 @@ const SPACE_NAMES = ['violet', 'emerald', 'crimson', 'deep blue', 'golden', 'sin
|
|
|
1040
1077
|
$('#space').value = /^[1-6]$/.test(String(ui.space)) ? String(ui.space) : 'random';
|
|
1041
1078
|
$('#space').onchange = e => {
|
|
1042
1079
|
ui.space = e.target.value; save();
|
|
1043
|
-
const n =
|
|
1080
|
+
const n = fleet.setSpace(ui.space);
|
|
1044
1081
|
toast(ui.space === 'random' ? `A new space scene every time you open the page (now: ${SPACE_NAMES[n - 1] || '?'})` : `Background: ${SPACE_NAMES[n - 1]}, always`);
|
|
1045
|
-
post('/hv-
|
|
1082
|
+
post('/hv-fleet-settings', { space: ui.space }).catch(() => {});
|
|
1046
1083
|
};
|
|
1047
|
-
post('/hv-
|
|
1084
|
+
post('/hv-fleet-refresh', { load: true }).then(j => {
|
|
1048
1085
|
showEvery(j.every);
|
|
1049
1086
|
if (j.space && j.space !== String(ui.space || 'random')) { // the server's choice wins (set in another browser)
|
|
1050
1087
|
ui.space = j.space; save(); $('#space').value = j.space;
|
|
1051
|
-
if (j.space !== 'random')
|
|
1052
|
-
} else if (!j.space && ui.space) post('/hv-
|
|
1088
|
+
if (j.space !== 'random') fleet.setSpace(j.space);
|
|
1089
|
+
} else if (!j.space && ui.space) post('/hv-fleet-settings', { space: String(ui.space) }).catch(() => {});
|
|
1053
1090
|
if (j.track && j.track !== String(ui.track || 'random')) { // the music choice made in another browser
|
|
1054
1091
|
ui.track = j.track; save(); $('#track').value = j.track;
|
|
1055
1092
|
if (fixedTrack() && fixedTrack() !== trackNo) { loadTrack(fixedTrack()); if (ui.music) bgm.play().catch(() => startOnTouch()); }
|
|
1056
|
-
} else if (!j.track && ui.track) post('/hv-
|
|
1093
|
+
} else if (!j.track && ui.track) post('/hv-fleet-settings', { track: String(ui.track) }).catch(() => {});
|
|
1057
1094
|
const server = j.ships || {}, local = ui.ships || {};
|
|
1058
1095
|
if (Object.keys(server).length) { // the server's positions win; rebuild if they differ from this browser's
|
|
1059
1096
|
if (JSON.stringify(server) !== JSON.stringify(local)) { ui.ships = server; save(); if (data) renderAll(); }
|
|
1060
1097
|
} else if (Object.keys(local).length) saveShips(); // first time: hand this browser's positions to the server
|
|
1061
1098
|
setTimeout(poll, 2500); setTimeout(poll, 8000);
|
|
1062
1099
|
}).catch(() => {});
|
|
1063
|
-
$('#every').onchange = e => post('/hv-
|
|
1100
|
+
$('#every').onchange = e => post('/hv-fleet-settings', { every: e.target.value })
|
|
1064
1101
|
.then(j => { showEvery(j.every); toast({ minute: 'Updates every minute (summaries only for agents that changed)', '5min': 'Updates every 5 minutes', '15min': 'Updates every 15 minutes', '1h': 'Updates every hour', reload: 'Updates only when you reload or press ⟳' }[j.every]); })
|
|
1065
|
-
.catch(() => toast('The
|
|
1102
|
+
.catch(() => toast('The fleet server is not answering'));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Background music for the hivey agent
|
|
1
|
+
Background music for the hivey agent fleet: generated locally with Meta MusicGen (large, MLX) for hivey,
|
|
2
2
|
28 s each, loudness-normalized. The page plays a new one each time (moving on when one ends) or always the
|
|
3
3
|
one picked in its 🎵 menu.
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// hivey
|
|
1
|
+
// hivey fleet, spacecraft edition: the deck of a ship, its workstations and its crew of mini robots.
|
|
2
2
|
// Everything is built from primitives and canvas textures (no image assets): physically based shells,
|
|
3
3
|
// glass visors and emissive LEDs that the bloom pass makes glow.
|
|
4
4
|
import * as THREE from './three.module.min.js';
|
|
@@ -24,7 +24,7 @@ export function createShip(opts) {
|
|
|
24
24
|
let robotScale = 1;
|
|
25
25
|
async function load() {
|
|
26
26
|
const loader = new GLTFLoader();
|
|
27
|
-
await Promise.all(Object.entries(FILES).map(([k, url]) => loader.loadAsync(url).then(g => { MODELS[k] = g; }).catch(e => console.warn('hivey
|
|
27
|
+
await Promise.all(Object.entries(FILES).map(([k, url]) => loader.loadAsync(url).then(g => { MODELS[k] = g; }).catch(e => console.warn('hivey fleet: model', k, e))));
|
|
28
28
|
const c = new THREE.Vector3();
|
|
29
29
|
for (const [k, g] of Object.entries(MODELS)) {
|
|
30
30
|
g.scene.updateMatrixWorld(true);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""The agent
|
|
1
|
+
"""The agent fleet: what every live agent is doing now, drawn as a 3D fleet of desks.
|
|
2
2
|
|
|
3
3
|
One desk per agent you talk to in hivey: solo agents, extra sessions in a space, and each swarm's
|
|
4
4
|
coordinator (a swarm's workers and critics are folded into their coordinator's desk as its team).
|
|
@@ -16,11 +16,11 @@ desk: the current job, a speech-bubble line, what it achieved, what it waits for
|
|
|
16
16
|
sent again, in batches, so 100 agents cost a few calls per refresh. Without a model (--no-llm, or the
|
|
17
17
|
call fails) the summary comes from the recap and the last prompt.
|
|
18
18
|
|
|
19
|
-
Output: ~/.hivey/agent-map/reports/
|
|
19
|
+
Output: ~/.hivey/agent-map/reports/fleet/fleet.json, read by fleet.html (Three.js, vendored), served
|
|
20
20
|
by serve.py, which reruns this every 5 minutes while the page is open. Python standard library only.
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
fleet.py run [--no-llm] [--quick] [--model haiku] one refresh (--quick: the 1-minute live pass)
|
|
23
|
+
fleet.py open start the server, refresh if stale, open the page
|
|
24
24
|
"""
|
|
25
25
|
from __future__ import annotations
|
|
26
26
|
|
|
@@ -45,10 +45,10 @@ import context_window # noqa: E402
|
|
|
45
45
|
|
|
46
46
|
HOME = Path.home()
|
|
47
47
|
STATE = HOME / ".hivey" / "agent-map"
|
|
48
|
-
OUT = STATE / "reports" / "
|
|
49
|
-
CACHE = STATE / "
|
|
50
|
-
LOCK = STATE / "
|
|
51
|
-
RUN_DIR = STATE / "
|
|
48
|
+
OUT = STATE / "reports" / "fleet"
|
|
49
|
+
CACHE = STATE / "fleet-cache.json"
|
|
50
|
+
LOCK = STATE / "fleet.lock"
|
|
51
|
+
RUN_DIR = STATE / "fleet-run" # neutral cwd for the model calls (no CLAUDE.md, no project)
|
|
52
52
|
|
|
53
53
|
STANDARD_WINDOW = 200_000
|
|
54
54
|
LARGE_WINDOW = 1_000_000
|
|
@@ -94,7 +94,7 @@ def now_iso() -> str:
|
|
|
94
94
|
return dt.datetime.now(dt.timezone.utc).isoformat(timespec="seconds")
|
|
95
95
|
|
|
96
96
|
|
|
97
|
-
# ---------------------------------------------------------------- who is in the
|
|
97
|
+
# ---------------------------------------------------------------- who is in the fleet
|
|
98
98
|
|
|
99
99
|
def hv_sessions(hv: str) -> list[dict]:
|
|
100
100
|
"""Every named hivey session: [{name, running, default, socket}] (the default one first)."""
|
|
@@ -216,6 +216,85 @@ def asleep_desks(hs: dict) -> list[dict]:
|
|
|
216
216
|
return out
|
|
217
217
|
|
|
218
218
|
|
|
219
|
+
# ---------------------------------------------------------------- its wiki: newest pages and log entries
|
|
220
|
+
|
|
221
|
+
WIKI_SKIP = {"raw", ".obsidian", ".trash", ".git", "node_modules", "assets", "attachments", "templates", "_templates"}
|
|
222
|
+
WIKI_META = {"log.md", "index.md", "claude.md", "agents.md", "ingest-ledger.md", "readme.md"}
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def obsidian_vaults() -> list[str]:
|
|
226
|
+
"""Folders Obsidian knows as vaults (pages inside them open with obsidian://open)."""
|
|
227
|
+
try:
|
|
228
|
+
got = json.loads((HOME / "Library/Application Support/obsidian/obsidian.json").read_text())
|
|
229
|
+
return [os.path.realpath(v["path"]) for v in (got.get("vaults") or {}).values() if v.get("path")]
|
|
230
|
+
except (OSError, ValueError, AttributeError, TypeError):
|
|
231
|
+
return []
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def wiki_dir(folder: str | None, space: str = "") -> Path | None:
|
|
235
|
+
"""The agent's or swarm's own wiki: a `<name>-wiki/` folder in its folder (or the folder itself); when its
|
|
236
|
+
terminal sits one level up (~/swarms), the folder named after its space."""
|
|
237
|
+
bases = [Path(folder)] if folder and os.path.isdir(folder) else []
|
|
238
|
+
if space and re.fullmatch(r"[\w.-]{1,64}", space):
|
|
239
|
+
bases += [b / space for b in bases] + [HOME / "agents" / space, HOME / "swarms" / space]
|
|
240
|
+
for base in bases:
|
|
241
|
+
if not base.is_dir():
|
|
242
|
+
continue
|
|
243
|
+
for cand in [base] + sorted(base.glob("*-wiki")):
|
|
244
|
+
if cand.is_dir() and cand.name.endswith("-wiki") and any((cand / n).exists() for n in ("index.md", "log.md", "wiki")):
|
|
245
|
+
return cand
|
|
246
|
+
return None
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def wiki_info(folder: str | None, vaults: list[str], space: str = "") -> dict | None:
|
|
250
|
+
"""The newest pages and reports the agent wrote in its wiki and its latest log entries."""
|
|
251
|
+
root = wiki_dir(folder, space)
|
|
252
|
+
if not root:
|
|
253
|
+
return None
|
|
254
|
+
pages, seen = [], 0
|
|
255
|
+
for dirpath, dirnames, filenames in os.walk(root):
|
|
256
|
+
dirnames[:] = [d for d in dirnames if d.lower() not in WIKI_SKIP and not d.startswith(".")]
|
|
257
|
+
for f in filenames:
|
|
258
|
+
if not f.endswith(".md") or f.lower() in WIKI_META or f.endswith(".excalidraw.md"):
|
|
259
|
+
continue
|
|
260
|
+
seen += 1
|
|
261
|
+
p = os.path.join(dirpath, f)
|
|
262
|
+
try:
|
|
263
|
+
pages.append((os.path.getmtime(p), p))
|
|
264
|
+
except OSError:
|
|
265
|
+
pass
|
|
266
|
+
if seen > 20000:
|
|
267
|
+
break
|
|
268
|
+
recent = []
|
|
269
|
+
for mtime, p in sorted(pages, reverse=True)[:8]:
|
|
270
|
+
title = Path(p).stem.replace("-", " ")
|
|
271
|
+
try:
|
|
272
|
+
with open(p, encoding="utf-8", errors="replace") as fh:
|
|
273
|
+
for line in fh.read(4000).splitlines():
|
|
274
|
+
if line.startswith("# "):
|
|
275
|
+
title = line[2:].strip()
|
|
276
|
+
break
|
|
277
|
+
except OSError:
|
|
278
|
+
pass
|
|
279
|
+
rel = os.path.relpath(p, root)
|
|
280
|
+
recent.append({"path": rel, "title": title[:120], "folder": os.path.dirname(rel),
|
|
281
|
+
"at": dt.datetime.fromtimestamp(mtime, dt.timezone.utc).isoformat(timespec="seconds")})
|
|
282
|
+
log = []
|
|
283
|
+
for lp in (root / "log.md", root / "wiki" / "log.md"):
|
|
284
|
+
try:
|
|
285
|
+
text = lp.read_text(errors="replace")[-20000:]
|
|
286
|
+
except OSError:
|
|
287
|
+
continue
|
|
288
|
+
for m in re.finditer(r"^## \[([^\]]+)\]\s*(.+)$", text, re.M):
|
|
289
|
+
log.append({"date": m.group(1).strip(), "what": m.group(2).strip()[:140]})
|
|
290
|
+
log = log[-5:][::-1]
|
|
291
|
+
break
|
|
292
|
+
real = os.path.realpath(root)
|
|
293
|
+
vault = next((v for v in vaults if real == v or real.startswith(v + os.sep)), None)
|
|
294
|
+
return {"dir": str(root), "short": short(str(root)), "vault": bool(vault), "pages": len(pages),
|
|
295
|
+
"recent": recent, "log": log}
|
|
296
|
+
|
|
297
|
+
|
|
219
298
|
# ---------------------------------------------------------------- what each one shows
|
|
220
299
|
|
|
221
300
|
def screen(hv: str, pane: str, sock: str | None = None) -> str:
|
|
@@ -325,7 +404,7 @@ def window_for(desk: dict, ctx: int) -> int:
|
|
|
325
404
|
|
|
326
405
|
# ---------------------------------------------------------------- the summaries
|
|
327
406
|
|
|
328
|
-
PROMPT = """You are the receptionist of
|
|
407
|
+
PROMPT = """You are the receptionist of a fleet of AI coding agents. For each agent below you get its
|
|
329
408
|
status, its terminal screen (bottom of the screen = now) and, for Claude Code agents, facts from its session
|
|
330
409
|
log. Write what a busy manager needs at a glance. Plain words, no jargon, no markdown.
|
|
331
410
|
|
|
@@ -442,8 +521,10 @@ def collect(hv: str, sessions: list[dict] | None = None) -> list[dict]:
|
|
|
442
521
|
for d in (desks(hv, hs) if hs["running"] else asleep_desks(hs))]
|
|
443
522
|
with cf.ThreadPoolExecutor(max_workers=8) as pool:
|
|
444
523
|
screens = list(pool.map(lambda d: "" if d.get("asleep") else screen(hv, d["pane"], d.get("sock")), people))
|
|
524
|
+
vaults = obsidian_vaults()
|
|
445
525
|
for d, scr in zip(people, screens):
|
|
446
526
|
d["screen"] = scr
|
|
527
|
+
d["wiki"] = wiki_info(d.get("folder"), vaults, d.get("space", ""))
|
|
447
528
|
log = session_log(transcript_of(d["session"], d["cli_id"]))
|
|
448
529
|
d["_log"] = log
|
|
449
530
|
d["log_uuid"] = log.get("uuid", "")
|
|
@@ -461,9 +542,11 @@ def collect(hv: str, sessions: list[dict] | None = None) -> list[dict]:
|
|
|
461
542
|
|
|
462
543
|
|
|
463
544
|
def run(model: str = "haiku", use_llm: bool = True, quick: bool = False) -> int:
|
|
545
|
+
import serve
|
|
546
|
+
serve.migrate_legacy()
|
|
464
547
|
hv = hivey_bin()
|
|
465
548
|
if not hv:
|
|
466
|
-
print("
|
|
549
|
+
print("fleet: hivey not found", file=sys.stderr)
|
|
467
550
|
return 1
|
|
468
551
|
STATE.mkdir(parents=True, exist_ok=True)
|
|
469
552
|
try:
|
|
@@ -472,7 +555,7 @@ def run(model: str = "haiku", use_llm: bool = True, quick: bool = False) -> int:
|
|
|
472
555
|
os.close(fd)
|
|
473
556
|
except FileExistsError:
|
|
474
557
|
if time.time() - LOCK.stat().st_mtime < 600:
|
|
475
|
-
print("
|
|
558
|
+
print("fleet: a refresh is already running")
|
|
476
559
|
return 0
|
|
477
560
|
LOCK.unlink(missing_ok=True)
|
|
478
561
|
return run(model, use_llm, quick)
|
|
@@ -556,7 +639,7 @@ def _run(hv: str, model: str, use_llm: bool, quick: bool = False) -> int:
|
|
|
556
639
|
full_at = now_iso()
|
|
557
640
|
if quick: # a live pass: the last full summary pass stays the one already on the page
|
|
558
641
|
try:
|
|
559
|
-
full_at = json.loads((OUT / "
|
|
642
|
+
full_at = json.loads((OUT / "fleet.json").read_text()).get("full_at") or full_at
|
|
560
643
|
except (OSError, ValueError):
|
|
561
644
|
pass
|
|
562
645
|
data = {"generated": now_iso(), "kind": "quick" if quick else "full", "full_at": full_at, "seconds": round(time.time() - start, 1), "model": model if use_llm else None,
|
|
@@ -567,14 +650,14 @@ def _run(hv: str, model: str, use_llm: bool, quick: bool = False) -> int:
|
|
|
567
650
|
"advice": {k: sum(1 for d in people if d["summary"].get("advice") == k and not d.get("asleep"))
|
|
568
651
|
for k in ("compact", "clear")}}
|
|
569
652
|
write(data)
|
|
570
|
-
print(f"
|
|
653
|
+
print(f"fleet: {len(people)} desks, {len(todo) if use_llm else 0} summarized"
|
|
571
654
|
f"{' (' + error + ')' if error else ''} in {data['seconds']}s → {OUT / 'index.html'}")
|
|
572
655
|
return 0
|
|
573
656
|
|
|
574
657
|
|
|
575
658
|
def write(data: dict) -> None:
|
|
576
659
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
577
|
-
assets = SCRIPTS / "
|
|
660
|
+
assets = SCRIPTS / "fleet" # the page and its modules (Three.js, post-processing, the ship)
|
|
578
661
|
for src in assets.rglob("*"):
|
|
579
662
|
if not src.is_file() or src.name.startswith("."):
|
|
580
663
|
continue
|
|
@@ -582,35 +665,35 @@ def write(data: dict) -> None:
|
|
|
582
665
|
blob = src.read_bytes()
|
|
583
666
|
if rel.suffix == ".b64": # binary models travel base64 (skills install text files)
|
|
584
667
|
rel, blob = rel.with_suffix(""), base64.b64decode(blob)
|
|
585
|
-
dst = OUT / ("index.html" if rel.as_posix() == "
|
|
668
|
+
dst = OUT / ("index.html" if rel.as_posix() == "fleet.html" else rel)
|
|
586
669
|
if not dst.is_file() or dst.read_bytes() != blob:
|
|
587
670
|
dst.parent.mkdir(parents=True, exist_ok=True)
|
|
588
671
|
dst.write_bytes(blob)
|
|
589
|
-
tmp = OUT / "
|
|
672
|
+
tmp = OUT / "fleet.json.tmp"
|
|
590
673
|
tmp.write_text(json.dumps(data, ensure_ascii=False))
|
|
591
|
-
os.replace(tmp, OUT / "
|
|
674
|
+
os.replace(tmp, OUT / "fleet.json")
|
|
592
675
|
|
|
593
676
|
|
|
594
677
|
def open_page(model: str) -> int:
|
|
595
678
|
import serve
|
|
596
|
-
data = OUT / "
|
|
679
|
+
data = OUT / "fleet.json"
|
|
597
680
|
fresh = data.is_file() and time.time() - data.stat().st_mtime < STALE_SECONDS
|
|
598
681
|
if not fresh:
|
|
599
682
|
run(model, use_llm=False) # seconds: desks and terminal lines now, summaries follow
|
|
600
683
|
port = serve.ensure()
|
|
601
684
|
if not port:
|
|
602
|
-
print("
|
|
685
|
+
print("fleet: the local page server did not start (see ~/.hivey/agent-map/server.log)", file=sys.stderr)
|
|
603
686
|
return 1
|
|
604
687
|
if not fresh:
|
|
605
|
-
serve.
|
|
606
|
-
url = f"http://127.0.0.1:{port}/
|
|
688
|
+
serve.request_fleet_refresh(port)
|
|
689
|
+
url = f"http://127.0.0.1:{port}/fleet/"
|
|
607
690
|
subprocess.run(["open", url], capture_output=True)
|
|
608
691
|
print(f"agent fleet: {url}")
|
|
609
692
|
return 0
|
|
610
693
|
|
|
611
694
|
|
|
612
695
|
def main(argv: list[str] | None = None) -> int:
|
|
613
|
-
ap = argparse.ArgumentParser(prog="
|
|
696
|
+
ap = argparse.ArgumentParser(prog="fleet.py", description=__doc__.split("\n\n")[0])
|
|
614
697
|
sub = ap.add_subparsers(dest="cmd")
|
|
615
698
|
r = sub.add_parser("run")
|
|
616
699
|
r.add_argument("--no-llm", action="store_true")
|
|
@@ -792,10 +792,10 @@ def first_run_busy() -> bool:
|
|
|
792
792
|
return False
|
|
793
793
|
|
|
794
794
|
|
|
795
|
-
def open_latest(model: str) -> int:
|
|
795
|
+
def open_latest(model: str, show: bool = True) -> int:
|
|
796
796
|
folder = latest_report()
|
|
797
797
|
if folder:
|
|
798
|
-
return 0 if open_page(folder) else 1
|
|
798
|
+
return 0 if not show or open_page(folder) else 1
|
|
799
799
|
# No report yet: the pages without a model first (seconds), open them, then the map in the background.
|
|
800
800
|
if first_run_busy(): # a second click while the first report is being built
|
|
801
801
|
notify("Your first agent map is still being built; it opens when ready.")
|
|
@@ -807,13 +807,13 @@ def open_latest(model: str) -> int:
|
|
|
807
807
|
subprocess.run([sys.executable, "-I", str(SCRIPTS / "agent_map.py"), "refresh"], stdout=fh, stderr=fh,
|
|
808
808
|
stdin=subprocess.DEVNULL, timeout=600)
|
|
809
809
|
folder = latest_report()
|
|
810
|
-
if folder:
|
|
810
|
+
if folder and show:
|
|
811
811
|
open_page(folder)
|
|
812
812
|
# the map needs the model: drawn in the background; the page's Refresh (or reopening) shows it
|
|
813
813
|
bg = subprocess.Popen([sys.executable, "-I", str(SCRIPTS / "agent_map.py"), "nightly", "--model", model],
|
|
814
814
|
stdout=fh, stderr=fh, stdin=subprocess.DEVNULL, start_new_session=True)
|
|
815
815
|
FIRST_RUN.write_text(json.dumps({"pid": bg.pid, "started": time.time()}))
|
|
816
|
-
if folder:
|
|
816
|
+
if folder and show:
|
|
817
817
|
notify("Stats, logs and sessions are open; the map is being drawn (a few minutes).")
|
|
818
818
|
print("first report: pages built; the map is being drawn in the background (log: ~/.hivey/agent-map/first-run.log)")
|
|
819
819
|
return 0
|