@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
|
@@ -5,22 +5,26 @@ http://127.0.0.1:<port>/latest/. It listens on 127.0.0.1 only, serves ~/.hivey/a
|
|
|
5
5
|
has these actions, answered only for the pages it serves (Origin check), so other web pages can't
|
|
6
6
|
trigger them:
|
|
7
7
|
|
|
8
|
+
GET /hv-jobs the agent jobs pages for the fleet page's Jobs tab: a redirect to the latest
|
|
9
|
+
map (else stats, logs, sessions); with no report yet it starts the first build
|
|
10
|
+
(`agent_map.py open --no-open`) and answers a page that reloads until it is ready
|
|
8
11
|
POST /hv-refresh `agent_map.py refresh` (free: no model)
|
|
9
|
-
|
|
10
|
-
POST /hv-
|
|
12
|
+
GET /fleet/ the agent fleet page (files in reports/fleet/; old /fleet/ links redirect here)
|
|
13
|
+
POST /hv-fleet-refresh `fleet.py run` in the background (the agent fleet, /fleet/)
|
|
14
|
+
POST /hv-fleet-action {"action": "session", "session": "<name>"} shows a hivey session in a terminal (a
|
|
11
15
|
new one if none shows it; `hivey session attach` starts a stopped session),
|
|
12
16
|
{"action": "stop-session", "session": "<name>"} stops a non-default session (all
|
|
13
17
|
its agents) and closes its terminal windows, or
|
|
14
18
|
{"id": "wN:p1" | "<session>/wN:p1", "action": "focus" | "compact" | "clear"} for a desk on the
|
|
15
|
-
|
|
19
|
+
fleet page: focus opens the agent's terminal in hivey (and brings the
|
|
16
20
|
terminal app forward); compact/clear type /compact or /clear into an agent
|
|
17
21
|
that is not working
|
|
18
22
|
|
|
19
|
-
While
|
|
23
|
+
While a fleet page is open (it polls /fleet/fleet.json), a live pass runs every minute (status,
|
|
20
24
|
context, screen; only desks whose status changed go to the model) and a full re-summary every 5 minutes.
|
|
21
|
-
The
|
|
22
|
-
~/.hivey/agent-map/
|
|
23
|
-
or on reload only (no clock). POST /hv-
|
|
25
|
+
The fleet page's ⏱ setting (POST /hv-fleet-settings {"every": "minute" | "5min" | "15min" | "1h" | "reload"}, saved in
|
|
26
|
+
~/.hivey/agent-map/fleet-settings.json) picks every minute (above), every 5 / 15 minutes or every hour (full passes only)
|
|
27
|
+
or on reload only (no clock). POST /hv-fleet-refresh: {} a full pass now (⟳), {"load": true} when a page
|
|
24
28
|
opens (a quick pass in minute mode, a full one otherwise), {"quick": true} a quick pass.
|
|
25
29
|
It stops after 2 hours unused. Python standard library only.
|
|
26
30
|
"""
|
|
@@ -36,11 +40,12 @@ import subprocess
|
|
|
36
40
|
import sys
|
|
37
41
|
import threading
|
|
38
42
|
import time
|
|
43
|
+
import urllib.parse
|
|
39
44
|
import urllib.request
|
|
40
45
|
from pathlib import Path
|
|
41
46
|
|
|
42
47
|
STATE = Path.home() / ".hivey" / "agent-map"
|
|
43
|
-
|
|
48
|
+
FLEET_SETTINGS = STATE / "fleet-settings.json" # {"every": "minute" | ..., "ships": {"<session>": {"x", "z"}}}
|
|
44
49
|
EVERY_MODES = ("minute", "5min", "15min", "1h", "reload")
|
|
45
50
|
FULL_EVERY = {"minute": 300, "5min": 300, "15min": 900, "1h": 3600} # seconds between full passes per mode
|
|
46
51
|
REPORTS = STATE / "reports"
|
|
@@ -49,12 +54,13 @@ SCRIPTS = Path(__file__).resolve().parent
|
|
|
49
54
|
PREFERRED_PORT = 42817 # unregistered and below macOS's temporary-port range, so no other app picks it
|
|
50
55
|
IDLE_SECONDS = 2 * 3600
|
|
51
56
|
PING = "/hv-ping"
|
|
57
|
+
LEGACY_PAGE = "/office" # the fleet page's address before it was renamed; redirected to /fleet/
|
|
52
58
|
MARK = b"hivey-agent-map"
|
|
53
|
-
VERSION = b"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
VERSION = b"fleet-16" # bump when the server gains actions, so `ensure` replaces an older one
|
|
60
|
+
FLEET_EVERY = 300 # seconds between full fleet refreshes (every terminal re-summarized) while its page is open
|
|
61
|
+
FLEET_LIVE = 60 # seconds between live passes (status, context, screen; only changed statuses summarized)
|
|
62
|
+
FLEET_WATCHED = 600 # the page counts as open for this long after its last poll
|
|
63
|
+
FLEET_JSON = REPORTS / "fleet" / "fleet.json"
|
|
58
64
|
PANE = re.compile(r"^[\w-]{1,24}:[\w-]{1,24}$")
|
|
59
65
|
TERMINAL_APPS = {"Apple_Terminal": "Terminal", "iTerm.app": "iTerm", "ghostty": "Ghostty",
|
|
60
66
|
"WezTerm": "WezTerm", "WarpTerminal": "Warp", "vscode": "Visual Studio Code"}
|
|
@@ -65,16 +71,16 @@ def hivey_bin() -> str | None:
|
|
|
65
71
|
return exe if exe and os.path.isfile(exe) else shutil.which("hivey")
|
|
66
72
|
|
|
67
73
|
|
|
68
|
-
def
|
|
74
|
+
def fleet_settings() -> dict:
|
|
69
75
|
try:
|
|
70
|
-
got = json.loads(
|
|
76
|
+
got = json.loads(FLEET_SETTINGS.read_text())
|
|
71
77
|
return got if isinstance(got, dict) else {}
|
|
72
78
|
except (OSError, ValueError):
|
|
73
79
|
return {}
|
|
74
80
|
|
|
75
81
|
|
|
76
82
|
def clean_ships(ships: object) -> dict:
|
|
77
|
-
"""{session: {x, z}} where you dragged each ship on the
|
|
83
|
+
"""{session: {x, z}} where you dragged each ship on the fleet page (bad entries dropped)."""
|
|
78
84
|
out = {}
|
|
79
85
|
for name, p in (ships.items() if isinstance(ships, dict) else []):
|
|
80
86
|
try:
|
|
@@ -86,25 +92,25 @@ def clean_ships(ships: object) -> dict:
|
|
|
86
92
|
return out
|
|
87
93
|
|
|
88
94
|
|
|
89
|
-
def
|
|
90
|
-
"""The
|
|
95
|
+
def fleet_every() -> str:
|
|
96
|
+
"""The fleet page's refresh setting (every minute by default)."""
|
|
91
97
|
try:
|
|
92
|
-
mode =
|
|
98
|
+
mode = fleet_settings().get("every")
|
|
93
99
|
except (OSError, ValueError, AttributeError):
|
|
94
100
|
mode = None
|
|
95
101
|
return mode if mode in EVERY_MODES else "minute"
|
|
96
102
|
|
|
97
103
|
|
|
98
|
-
def
|
|
99
|
-
"""
|
|
100
|
-
cmd = [sys.executable, "-I", str(SCRIPTS / "
|
|
104
|
+
def start_fleet_refresh(llm: bool = True, quick: bool = False) -> None:
|
|
105
|
+
"""fleet.py run in the background (it holds its own lock, so overlapping starts are dropped)."""
|
|
106
|
+
cmd = [sys.executable, "-I", str(SCRIPTS / "fleet.py"), "run"] + ([] if llm else ["--no-llm"]) \
|
|
101
107
|
+ (["--quick"] if quick else [])
|
|
102
|
-
with open(STATE / "
|
|
108
|
+
with open(STATE / "fleet.log", "a") as fh:
|
|
103
109
|
subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=fh, stderr=fh, start_new_session=True)
|
|
104
110
|
|
|
105
111
|
|
|
106
|
-
def
|
|
107
|
-
req = urllib.request.Request(f"http://127.0.0.1:{port}/hv-
|
|
112
|
+
def request_fleet_refresh(port: int) -> None:
|
|
113
|
+
req = urllib.request.Request(f"http://127.0.0.1:{port}/hv-fleet-refresh", data=b"{}", method="POST",
|
|
108
114
|
headers={"Origin": f"http://127.0.0.1:{port}", "Content-Type": "application/json"})
|
|
109
115
|
try:
|
|
110
116
|
urllib.request.urlopen(req, timeout=3).read()
|
|
@@ -263,10 +269,10 @@ def raise_terminal(session: str | None = None) -> str:
|
|
|
263
269
|
return "raised"
|
|
264
270
|
|
|
265
271
|
|
|
266
|
-
def
|
|
267
|
-
"""The desk on the
|
|
272
|
+
def fleet_desk(desk_id: str) -> dict | None:
|
|
273
|
+
"""The desk on the fleet page with this id (pane id, or "<session>/<pane>" outside the default session)."""
|
|
268
274
|
try:
|
|
269
|
-
agents = json.loads(
|
|
275
|
+
agents = json.loads(FLEET_JSON.read_text()).get("agents", [])
|
|
270
276
|
except (OSError, ValueError):
|
|
271
277
|
return None
|
|
272
278
|
return next((a for a in agents if a.get("id") == desk_id), None) \
|
|
@@ -333,7 +339,7 @@ def stop_session(session: str) -> tuple[bool, str]:
|
|
|
333
339
|
if not exe or not SESSION_NAME.match(session or ""):
|
|
334
340
|
return False, "unknown session"
|
|
335
341
|
if session == "default":
|
|
336
|
-
return False, "the default session is not stopped from here (it runs this
|
|
342
|
+
return False, "the default session is not stopped from here (it runs this fleet); quit it in hivey"
|
|
337
343
|
ttys = client_ttys(session, only=True)
|
|
338
344
|
p = subprocess.run([exe, "session", "stop", session], capture_output=True, text=True, timeout=60)
|
|
339
345
|
if p.returncode != 0:
|
|
@@ -360,7 +366,26 @@ def session_action(session: str) -> tuple[bool, str]:
|
|
|
360
366
|
if how else (False, f"could not open a terminal; run: hivey session attach {session}")
|
|
361
367
|
|
|
362
368
|
|
|
363
|
-
def
|
|
369
|
+
def open_wiki_page(desk: dict, rel: str) -> tuple[bool, str]:
|
|
370
|
+
"""Open a page of the agent's own wiki in Obsidian (only .md files inside that wiki)."""
|
|
371
|
+
wiki = desk.get("wiki") or {}
|
|
372
|
+
root = os.path.realpath(wiki.get("dir") or "")
|
|
373
|
+
if not root or not os.path.isdir(root):
|
|
374
|
+
return False, "this agent has no wiki"
|
|
375
|
+
target = os.path.realpath(os.path.join(root, rel or ""))
|
|
376
|
+
if os.path.isdir(target) and target == root: # the wiki itself: its index
|
|
377
|
+
target = next((os.path.join(root, n) for n in ("index.md", "wiki/index.md") if os.path.isfile(os.path.join(root, n))), "")
|
|
378
|
+
if not target.endswith(".md") or not target.startswith(root + os.sep) or not os.path.isfile(target):
|
|
379
|
+
return False, "not a page of this agent's wiki"
|
|
380
|
+
if wiki.get("vault"):
|
|
381
|
+
p = subprocess.run(["open", "obsidian://open?path=" + urllib.parse.quote(target, safe="")],
|
|
382
|
+
capture_output=True, text=True, timeout=10)
|
|
383
|
+
return (p.returncode == 0), ("opened in Obsidian" if p.returncode == 0 else (p.stderr or "open failed").strip()[-200:])
|
|
384
|
+
subprocess.run(["open", target], capture_output=True, timeout=10)
|
|
385
|
+
return True, f"opened (not an Obsidian vault yet: in Obsidian, Open folder as vault → {wiki.get('short')})"
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
def fleet_action(desk_id: str, action: str, session: str = "", path: str = "") -> tuple[bool, str]:
|
|
364
389
|
if action == "session":
|
|
365
390
|
return session_action(session)
|
|
366
391
|
if action == "stop-session":
|
|
@@ -368,11 +393,13 @@ def office_action(desk_id: str, action: str, session: str = "") -> tuple[bool, s
|
|
|
368
393
|
exe = hivey_bin()
|
|
369
394
|
if not exe:
|
|
370
395
|
return False, "hivey not found"
|
|
371
|
-
desk =
|
|
396
|
+
desk = fleet_desk(desk_id)
|
|
372
397
|
pane = (desk or {}).get("pane") or ""
|
|
373
398
|
if not desk or not PANE.match(pane):
|
|
374
399
|
return False, "unknown agent"
|
|
375
400
|
sock = desk.get("sock") or None
|
|
401
|
+
if action == "wiki": # works for asleep agents too: their wiki is on disk
|
|
402
|
+
return open_wiki_page(desk, path)
|
|
376
403
|
if desk.get("asleep"): # an agent of a stopped session: start the session (compact/clear wait until then)
|
|
377
404
|
if action == "focus":
|
|
378
405
|
return session_action(desk.get("hv_session") or "")
|
|
@@ -446,8 +473,8 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
|
|
446
473
|
server_version = "hivey-agent-map"
|
|
447
474
|
busy = threading.Lock()
|
|
448
475
|
last_used = time.time()
|
|
449
|
-
|
|
450
|
-
|
|
476
|
+
fleet_polled = 0.0
|
|
477
|
+
fleet_full = 0.0 # last full (all re-summarized) fleet refresh started by this server
|
|
451
478
|
|
|
452
479
|
def __init__(self, *args, **kwargs):
|
|
453
480
|
super().__init__(*args, directory=str(REPORTS), **kwargs)
|
|
@@ -470,26 +497,60 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
|
|
470
497
|
Handler.last_used = time.time()
|
|
471
498
|
if self.path == PING:
|
|
472
499
|
return self.answer(200, MARK + b" " + VERSION, "text/plain")
|
|
473
|
-
|
|
474
|
-
|
|
500
|
+
path, _, query = self.path.partition("?")
|
|
501
|
+
if path == "/fleet" or path == LEGACY_PAGE or path.startswith(LEGACY_PAGE + "/"): # old links: /fleet/
|
|
502
|
+
self.send_response(301)
|
|
503
|
+
self.send_header("Location", "/fleet/" + ("?" + query if query else ""))
|
|
504
|
+
self.send_header("Content-Length", "0")
|
|
505
|
+
self.end_headers()
|
|
506
|
+
return None
|
|
507
|
+
if path == "/fleet/fleet.json":
|
|
508
|
+
Handler.fleet_polled = time.time()
|
|
509
|
+
if self.path.split("?")[0] == "/hv-jobs":
|
|
510
|
+
return self.jobs()
|
|
475
511
|
return super().do_GET()
|
|
476
512
|
|
|
513
|
+
def jobs(self) -> None:
|
|
514
|
+
"""The fleet page's Jobs tab: the latest agent jobs page, or the first report being built."""
|
|
515
|
+
import report
|
|
516
|
+
folder = report.latest_report()
|
|
517
|
+
page = next((p for p in report.PAGES if folder and (folder / p).is_file()), None)
|
|
518
|
+
if folder and page:
|
|
519
|
+
rel = "latest" if report.LATEST.exists() and report.LATEST.resolve() == folder.resolve() else folder.name
|
|
520
|
+
self.send_response(302)
|
|
521
|
+
self.send_header("Location", f"/{rel}/{page}")
|
|
522
|
+
self.send_header("Content-Length", "0")
|
|
523
|
+
self.end_headers()
|
|
524
|
+
return None
|
|
525
|
+
if not report.first_run_busy():
|
|
526
|
+
log = open(STATE / "first-run.log", "a")
|
|
527
|
+
subprocess.Popen([sys.executable, "-I", str(SCRIPTS / "agent_map.py"), "open", "--no-open"],
|
|
528
|
+
stdout=log, stderr=log, stdin=subprocess.DEVNULL, start_new_session=True)
|
|
529
|
+
log.close()
|
|
530
|
+
body = ("<!doctype html><meta charset=utf-8><meta http-equiv=refresh content=5>"
|
|
531
|
+
"<body style=\"font:15px system-ui;background:#0b0e15;color:#cbd5e1;display:grid;place-items:center;"
|
|
532
|
+
"height:90vh;margin:0\"><div style=\"text-align:center\"><div style=\"font-size:34px\">📊</div>"
|
|
533
|
+
"<p><b>Building your first agent jobs report…</b></p><p style=\"opacity:.7\">Stats, logs and "
|
|
534
|
+
"sessions take a few seconds; the map is drawn in the background. This page reloads by itself."
|
|
535
|
+
"</p></div></body>")
|
|
536
|
+
return self.answer(200, body.encode(), "text/html; charset=utf-8")
|
|
537
|
+
|
|
477
538
|
def do_POST(self) -> None:
|
|
478
539
|
Handler.last_used = time.time()
|
|
479
540
|
port = self.server.server_address[1]
|
|
480
|
-
if self.path not in ("/hv-refresh", "/hv-
|
|
541
|
+
if self.path not in ("/hv-refresh", "/hv-fleet-refresh", "/hv-fleet-action", "/hv-fleet-settings"):
|
|
481
542
|
return self.answer(404, b'{"ok":false,"error":"not found"}')
|
|
482
543
|
if self.headers.get("Origin") not in (f"http://127.0.0.1:{port}", f"http://localhost:{port}"):
|
|
483
544
|
return self.answer(403, b'{"ok":false,"error":"only the agent map pages can do this"}')
|
|
484
|
-
if self.path in ("/hv-
|
|
545
|
+
if self.path in ("/hv-fleet-refresh", "/hv-fleet-settings"):
|
|
485
546
|
try:
|
|
486
547
|
length = min(int(self.headers.get("Content-Length") or 0), 4096)
|
|
487
548
|
req = json.loads(self.rfile.read(length) or b"{}")
|
|
488
549
|
req = req if isinstance(req, dict) else {}
|
|
489
550
|
except ValueError:
|
|
490
551
|
req = {}
|
|
491
|
-
if self.path == "/hv-
|
|
492
|
-
cur =
|
|
552
|
+
if self.path == "/hv-fleet-settings":
|
|
553
|
+
cur = fleet_settings()
|
|
493
554
|
if "every" in req:
|
|
494
555
|
if req.get("every") not in EVERY_MODES:
|
|
495
556
|
return self.answer(400, b'{"ok":false,"error":"every: minute, 5min, 15min, 1h or reload"}')
|
|
@@ -502,27 +563,27 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
|
|
502
563
|
if not re.fullmatch(r"random|[1-9]|10", str(req["track"])):
|
|
503
564
|
return self.answer(400, b'{"ok":false,"error":"track: random or 1..10"}')
|
|
504
565
|
cur["track"] = str(req["track"])
|
|
505
|
-
if "ships" in req: # the ship positions you dragged on the
|
|
566
|
+
if "ships" in req: # the ship positions you dragged on the fleet page
|
|
506
567
|
cur["ships"] = clean_ships(req["ships"])
|
|
507
|
-
|
|
508
|
-
return self.answer(200, json.dumps({"ok": True, "every":
|
|
568
|
+
FLEET_SETTINGS.write_text(json.dumps(cur))
|
|
569
|
+
return self.answer(200, json.dumps({"ok": True, "every": fleet_every(), "space": cur.get("space"), "track": cur.get("track"),
|
|
509
570
|
"ships": cur.get("ships", {})}).encode())
|
|
510
|
-
every =
|
|
571
|
+
every = fleet_every()
|
|
511
572
|
# a page load: a quick pass when updating every minute, a full one otherwise; ⟳: always full
|
|
512
573
|
quick = bool(req.get("quick")) or (bool(req.get("load")) and every == "minute")
|
|
513
|
-
Handler.
|
|
574
|
+
Handler.fleet_polled = time.time()
|
|
514
575
|
if not quick:
|
|
515
|
-
Handler.
|
|
516
|
-
|
|
576
|
+
Handler.fleet_full = time.time()
|
|
577
|
+
start_fleet_refresh(quick=quick)
|
|
517
578
|
return self.answer(200, json.dumps({"ok": True, "started": True, "every": every,
|
|
518
|
-
"space":
|
|
519
|
-
"ships": clean_ships(
|
|
520
|
-
if self.path == "/hv-
|
|
579
|
+
"space": fleet_settings().get("space"), "track": fleet_settings().get("track"),
|
|
580
|
+
"ships": clean_ships(fleet_settings().get("ships"))}).encode())
|
|
581
|
+
if self.path == "/hv-fleet-action":
|
|
521
582
|
try:
|
|
522
583
|
length = min(int(self.headers.get("Content-Length") or 0), 4096)
|
|
523
584
|
req = json.loads(self.rfile.read(length) or b"{}")
|
|
524
|
-
ok, msg =
|
|
525
|
-
str(req.get("session") or ""))
|
|
585
|
+
ok, msg = fleet_action(str(req.get("id") or req.get("pane") or ""), str(req.get("action", "")),
|
|
586
|
+
str(req.get("session") or ""), str(req.get("path") or ""))
|
|
526
587
|
except (ValueError, OSError, subprocess.SubprocessError) as e:
|
|
527
588
|
ok, msg = False, str(e)[:200]
|
|
528
589
|
return self.answer(200, json.dumps({"ok": ok, "message": msg}).encode())
|
|
@@ -541,7 +602,23 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
|
|
541
602
|
return self.answer(200, json.dumps(body).encode())
|
|
542
603
|
|
|
543
604
|
|
|
605
|
+
def migrate_legacy() -> None:
|
|
606
|
+
"""The fleet page was called the agent office: move its saved files to their new names, once."""
|
|
607
|
+
old = "off" + "ice" # spelled apart so a search for the old name finds only this migration
|
|
608
|
+
for name, new in ((f"{old}-settings.json", FLEET_SETTINGS), (f"{old}-cache.json", STATE / "fleet-cache.json"),
|
|
609
|
+
(f"{old}.log", STATE / "fleet.log")):
|
|
610
|
+
src = STATE / name
|
|
611
|
+
try:
|
|
612
|
+
if src.is_file() and not new.exists():
|
|
613
|
+
src.rename(new)
|
|
614
|
+
except OSError:
|
|
615
|
+
pass
|
|
616
|
+
shutil.rmtree(STATE / f"{old}-run", ignore_errors=True) # an empty working folder, now fleet-run/
|
|
617
|
+
shutil.rmtree(REPORTS / old, ignore_errors=True) # the old page and data; fleet.py writes reports/fleet/
|
|
618
|
+
|
|
619
|
+
|
|
544
620
|
def serve() -> int:
|
|
621
|
+
migrate_legacy()
|
|
545
622
|
REPORTS.mkdir(parents=True, exist_ok=True)
|
|
546
623
|
try:
|
|
547
624
|
httpd = http.server.ThreadingHTTPServer(("127.0.0.1", PREFERRED_PORT), Handler)
|
|
@@ -557,27 +634,27 @@ def serve() -> int:
|
|
|
557
634
|
httpd.shutdown()
|
|
558
635
|
return
|
|
559
636
|
|
|
560
|
-
def
|
|
561
|
-
"""While
|
|
637
|
+
def fleet_clock() -> None:
|
|
638
|
+
"""While a fleet page is open: a live pass every minute, a full re-summary every 5 minutes."""
|
|
562
639
|
while True:
|
|
563
640
|
time.sleep(10)
|
|
564
|
-
every =
|
|
565
|
-
if every == "reload" or time.time() - Handler.
|
|
641
|
+
every = fleet_every()
|
|
642
|
+
if every == "reload" or time.time() - Handler.fleet_polled > FLEET_WATCHED:
|
|
566
643
|
continue
|
|
567
644
|
try:
|
|
568
|
-
age = time.time() -
|
|
645
|
+
age = time.time() - FLEET_JSON.stat().st_mtime
|
|
569
646
|
except OSError:
|
|
570
|
-
age =
|
|
571
|
-
if time.time() - Handler.
|
|
572
|
-
Handler.
|
|
573
|
-
|
|
647
|
+
age = FLEET_EVERY
|
|
648
|
+
if time.time() - Handler.fleet_full >= FULL_EVERY.get(every, FLEET_EVERY):
|
|
649
|
+
Handler.fleet_full = time.time()
|
|
650
|
+
start_fleet_refresh()
|
|
574
651
|
time.sleep(30) # give it time to write before checking the age again
|
|
575
|
-
elif every == "minute" and age >=
|
|
576
|
-
|
|
652
|
+
elif every == "minute" and age >= FLEET_LIVE:
|
|
653
|
+
start_fleet_refresh(quick=True)
|
|
577
654
|
time.sleep(20)
|
|
578
655
|
|
|
579
656
|
threading.Thread(target=watchdog, daemon=True).start()
|
|
580
|
-
threading.Thread(target=
|
|
657
|
+
threading.Thread(target=fleet_clock, daemon=True).start()
|
|
581
658
|
print(f"agent map pages: http://127.0.0.1:{port}/latest/agent-stats.html", flush=True)
|
|
582
659
|
httpd.serve_forever()
|
|
583
660
|
try:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/LICENSE-kenney-space-kit.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/machine_generator.glb.b64
RENAMED
|
File without changes
|
/package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/machine_generatorLarge.glb.b64
RENAMED
|
File without changes
|
/package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/machine_wireless.glb.b64
RENAMED
|
File without changes
|
|
File without changes
|
/package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/satelliteDish_detailed.glb.b64
RENAMED
|
File without changes
|
/package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/satelliteDish_large.glb.b64
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/station/computer-system.glb.b64
RENAMED
|
File without changes
|
/package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/station/computer-wide.glb.b64
RENAMED
|
File without changes
|
/package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/station/container-flat.glb.b64
RENAMED
|
File without changes
|
/package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/station/container-tall.glb.b64
RENAMED
|
File without changes
|
/package/repo/skills/hivey-agent-map/scripts/{office → fleet}/models/station/container-wide.glb.b64
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/repo/skills/hivey-agent-map/scripts/{office → fleet}/postprocessing/EffectComposer.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/repo/skills/hivey-agent-map/scripts/{office → fleet}/postprocessing/UnrealBloomPass.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/repo/skills/hivey-agent-map/scripts/{office → fleet}/shaders/LuminosityHighPassShader.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|