@hivey/cli 0.9.76 → 0.9.79
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/skills/hivey-agent-creator/references/agent-claude-md.md +3 -0
- package/repo/skills/hivey-agent-map/SKILL.md +9 -0
- package/repo/skills/hivey-agent-map/scripts/agent_map.py +3 -0
- package/repo/skills/hivey-agent-map/scripts/dashboards.py +327 -0
- package/repo/skills/hivey-agent-map/scripts/fleet/fleet.html +55 -0
- package/repo/skills/hivey-agent-map/scripts/fleet/fleet.js +171 -5
- package/repo/skills/hivey-agent-map/scripts/serve.py +54 -5
- package/repo/skills/hivey-dashboards/SKILL.md +77 -0
|
Binary file
|
package/package.json
CHANGED
|
@@ -35,6 +35,9 @@ for Codex, Grok and agy** below when the agent isn't on Claude Code.
|
|
|
35
35
|
- **Spend:** a script you write that calls an LLM API directly (not through Claude Code, Codex
|
|
36
36
|
or Grok CLI) logs each call with `hivey_spend.record(response, agent="<agent name>")` from
|
|
37
37
|
`~/.claude/skills/hivey-agent-map/scripts/hivey_spend.py`, so the agent map counts its cost.
|
|
38
|
+
- **Dashboards:** when you build or deploy a dashboard, report site or web view, register it on
|
|
39
|
+
the agent fleet so the user finds it with the others: `hivey agent-map dashboard add "<name>"
|
|
40
|
+
<url> --agent <agent name> --note "<what it shows>"` (`hivey-dashboards` skill).
|
|
38
41
|
- Ask before anything destructive or outward-facing (deleting data, publishing, sending
|
|
39
42
|
email or posts, spending money). Draft first, then ask.
|
|
40
43
|
- Commit your work in this folder; never push.
|
|
@@ -218,6 +218,15 @@ each swarm's coordinator get a desk; a swarm's workers and critics stand beside
|
|
|
218
218
|
Quaternius, CC0: Idle + nods when working, Wave when blocked, ThumbsUp when done, Sitting when idle), Kenney
|
|
219
219
|
Space Kit and Space Station Kit pieces (CC0: desks, chairs, generators, dishes, small craft, astronauts,
|
|
220
220
|
consoles, crates), licences in `models/LICENSE-*`; 10 MusicGen electronic space tracks (`music/README.txt` has their prompts), 🔇/🎵 or `m`; the 🎵 menu plays a new one each time (moving on when one ends) or always one (saved with the other settings). Browsers allow sound only after you touch the page, so when playing at once is refused the music starts with your first click or key press anywhere.
|
|
221
|
+
- **🖥 Dashboards tab** (key 5): the dashboards the user's agents keep, listed on the left; the one you pick loads
|
|
222
|
+
in a frame on the right (⟳, Open in tab ↗, Edit, Remove), with a live up/down dot per dashboard (`GET
|
|
223
|
+
/hv-dashboard-status`, checked from this Mac). The list is in `fleet-settings.json` under `dashboards`
|
|
224
|
+
(owner-only file); **+ Add** on the page or `hivey agent-map dashboard add|list|edit|remove …` (`scripts/dashboards.py`,
|
|
225
|
+
the `hivey-dashboards` skill) edit the same list. A dashboard can carry a login token (a value or an EnvSave
|
|
226
|
+
`es_…` key): the frame opens `GET /hv-dashboard-open?id=…`, which redirects to its URL with the token added as a
|
|
227
|
+
query parameter (`token_param`, default `token`), so the page never holds tokens. A site behind Vercel's login
|
|
228
|
+
is flagged (it refuses frames); its Protection Bypass for Automation secret with `--vercel` opens it in the
|
|
229
|
+
frame, logged in. Sites that forbid framing show an Open in tab button instead.
|
|
221
230
|
- **CEO**: the space named `ceo` gets the captain's bridge, its own room in the ship's nose (gold trim, main
|
|
222
231
|
viewscreen); its master sits at the captain's console.
|
|
223
232
|
|
|
@@ -1050,6 +1050,9 @@ def context_cmd(agents: list, size: str | None) -> int:
|
|
|
1050
1050
|
|
|
1051
1051
|
|
|
1052
1052
|
def main() -> int:
|
|
1053
|
+
if sys.argv[1:2] in (["dashboard"], ["dashboards"]): # the fleet page's Dashboards list, from the shell
|
|
1054
|
+
import dashboards
|
|
1055
|
+
return dashboards.main(sys.argv[2:])
|
|
1053
1056
|
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
1054
1057
|
sub = ap.add_subparsers(dest="cmd", required=True)
|
|
1055
1058
|
s = sub.add_parser("scan")
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
"""The dashboards your agents keep: one list, shown on the fleet page's 🖥 Dashboards tab.
|
|
2
|
+
|
|
3
|
+
Each entry is {"id", "name", "url", "agent", "note", "token", "token_param"}; they live in
|
|
4
|
+
~/.hivey/agent-map/fleet-settings.json (owner-only) under "dashboards", so every browser sees the same list.
|
|
5
|
+
The page lists them on the left and shows the one you pick in a frame on the right; it adds, edits and
|
|
6
|
+
removes them (POST /hv-fleet-settings {"dashboards": [...]}). An agent that builds or deploys a dashboard
|
|
7
|
+
registers it from the shell:
|
|
8
|
+
|
|
9
|
+
python3 -I dashboards.py add "Trading dashboard" https://example.vercel.app --agent trading-strategies
|
|
10
|
+
python3 -I dashboards.py add "Trading dashboard" https://example.vercel.app --token es_… --vercel
|
|
11
|
+
python3 -I dashboards.py list [--json]
|
|
12
|
+
python3 -I dashboards.py edit "Trading dashboard" --name "Paper trading" --url https://… --note "…"
|
|
13
|
+
python3 -I dashboards.py remove "Trading dashboard" (by name, id or URL)
|
|
14
|
+
|
|
15
|
+
The same commands run as `hivey agent-map dashboard add|list|edit|remove …` (the hivey-dashboards skill).
|
|
16
|
+
`add` with a name or URL already in the list updates that entry.
|
|
17
|
+
|
|
18
|
+
Logins: a dashboard can carry a token. Opening it (GET /hv-dashboard-open?id=…) redirects to its URL with
|
|
19
|
+
the token added as a query parameter (`token_param`, default `token`), so a dashboard that accepts a token
|
|
20
|
+
logs you in by itself. The token is a literal value or an EnvSave opaque key (`es_…`, read with
|
|
21
|
+
`envsave get` when the dashboard opens; no Touch ID). It is never sent to the page's list. For a site behind
|
|
22
|
+
Vercel's login (Deployment Protection), use its "Protection Bypass for Automation" secret with --vercel:
|
|
23
|
+
the parameter becomes `x-vercel-protection-bypass` plus a bypass cookie that also works in the frame.
|
|
24
|
+
Python standard library only.
|
|
25
|
+
"""
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
import argparse
|
|
29
|
+
import concurrent.futures
|
|
30
|
+
import json
|
|
31
|
+
import os
|
|
32
|
+
import re
|
|
33
|
+
import shutil
|
|
34
|
+
import subprocess
|
|
35
|
+
import sys
|
|
36
|
+
import time
|
|
37
|
+
import urllib.error
|
|
38
|
+
import urllib.parse
|
|
39
|
+
import urllib.request
|
|
40
|
+
from pathlib import Path
|
|
41
|
+
|
|
42
|
+
SETTINGS = Path.home() / ".hivey" / "agent-map" / "fleet-settings.json"
|
|
43
|
+
MAX = 100
|
|
44
|
+
LIMITS = {"name": 80, "url": 2000, "agent": 80, "note": 300}
|
|
45
|
+
VERCEL = "x-vercel-protection-bypass"
|
|
46
|
+
PARAM = re.compile(r"^[A-Za-z0-9_.-]{1,64}$")
|
|
47
|
+
FIELDS = ("name", "url", "agent", "note", "token", "token_param")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _settings() -> dict:
|
|
51
|
+
try:
|
|
52
|
+
got = json.loads(SETTINGS.read_text())
|
|
53
|
+
return got if isinstance(got, dict) else {}
|
|
54
|
+
except (OSError, ValueError):
|
|
55
|
+
return {}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def valid_url(url: str) -> bool:
|
|
59
|
+
p = urllib.parse.urlsplit(url)
|
|
60
|
+
return p.scheme in ("http", "https") and bool(p.netloc) and not any(c.isspace() for c in url)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _slug(text: str) -> str:
|
|
64
|
+
return re.sub(r"[^a-z0-9]+", "-", text.lower()).strip("-")[:40] or "dashboard"
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def clean(items: object, old: list[dict] | None = None) -> list[dict]:
|
|
68
|
+
"""Keep well-formed entries only: an http(s) URL, a name (the host when missing), short fields, unique ids.
|
|
69
|
+
|
|
70
|
+
With `old` (the saved list), an entry whose id is saved and that has no "token" key keeps its saved
|
|
71
|
+
token: the page never sees tokens, so it sends none back unless you typed a new one ("" removes it)."""
|
|
72
|
+
saved = {d["id"]: d for d in old or []}
|
|
73
|
+
out, ids = [], set()
|
|
74
|
+
for d in items if isinstance(items, list) else []:
|
|
75
|
+
if not isinstance(d, dict):
|
|
76
|
+
continue
|
|
77
|
+
e = {k: str(d.get(k) or "").strip()[:n] for k, n in LIMITS.items()}
|
|
78
|
+
if not valid_url(e["url"]):
|
|
79
|
+
continue
|
|
80
|
+
e["name"] = e["name"] or urllib.parse.urlsplit(e["url"]).netloc
|
|
81
|
+
prev = saved.get(str(d.get("id") or ""), {})
|
|
82
|
+
token = d["token"] if "token" in d else prev.get("token", "")
|
|
83
|
+
e["token"] = str(token or "").strip()[:4000]
|
|
84
|
+
param = str(d.get("token_param") or (prev.get("token_param") if "token_param" not in d else "") or "").strip()
|
|
85
|
+
e["token_param"] = param if PARAM.match(param) else ""
|
|
86
|
+
base = _slug(str(d.get("id") or "") or e["name"])
|
|
87
|
+
i, n = base, 2
|
|
88
|
+
while i in ids:
|
|
89
|
+
i, n = f"{base}-{n}", n + 1
|
|
90
|
+
ids.add(i)
|
|
91
|
+
out.append({"id": i, **e})
|
|
92
|
+
if len(out) >= MAX:
|
|
93
|
+
break
|
|
94
|
+
return out
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def public(items: list[dict]) -> list[dict]:
|
|
98
|
+
"""The list for the page: tokens replaced by what kind of login each one has."""
|
|
99
|
+
out = []
|
|
100
|
+
for d in items:
|
|
101
|
+
p = {k: v for k, v in d.items() if k != "token"}
|
|
102
|
+
tok = d.get("token") or ""
|
|
103
|
+
p["login"] = "" if not tok else "envsave" if tok.startswith("es_") else "token"
|
|
104
|
+
out.append(p)
|
|
105
|
+
return out
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def load() -> list[dict]:
|
|
109
|
+
return clean(_settings().get("dashboards"))
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def write(cur: dict) -> None:
|
|
113
|
+
"""Save the settings file readable by you only (it can hold dashboard tokens)."""
|
|
114
|
+
SETTINGS.parent.mkdir(parents=True, exist_ok=True)
|
|
115
|
+
tmp = SETTINGS.with_suffix(".tmp")
|
|
116
|
+
fd = os.open(tmp, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
|
|
117
|
+
with os.fdopen(fd, "w") as f:
|
|
118
|
+
f.write(json.dumps(cur))
|
|
119
|
+
os.chmod(tmp, 0o600)
|
|
120
|
+
tmp.replace(SETTINGS)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def save(items: list[dict]) -> list[dict]:
|
|
124
|
+
cur = _settings()
|
|
125
|
+
cur["dashboards"] = clean(items, clean(cur.get("dashboards")))
|
|
126
|
+
write(cur)
|
|
127
|
+
return cur["dashboards"]
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _match(d: dict, key: str) -> bool:
|
|
131
|
+
k = key.strip().lower()
|
|
132
|
+
return k in (d["id"].lower(), d["name"].lower(), d["url"].lower().rstrip("/"), d["url"].lower())
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def _changes(name=None, url=None, agent=None, note=None, token=None, token_param=None, vercel=False) -> dict:
|
|
136
|
+
ch = {k: v for k, v in dict(name=name, url=url, agent=agent, note=note, token=token, token_param=token_param).items()
|
|
137
|
+
if v is not None}
|
|
138
|
+
if vercel:
|
|
139
|
+
ch["token_param"] = VERCEL
|
|
140
|
+
if "url" in ch and not valid_url(ch["url"]):
|
|
141
|
+
raise ValueError(f"not an http(s) URL: {ch['url']}")
|
|
142
|
+
if ch.get("token_param") and not PARAM.match(ch["token_param"]):
|
|
143
|
+
raise ValueError(f"bad token parameter name: {ch['token_param']}")
|
|
144
|
+
return ch
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def add(name: str, url: str, agent: str = "", note: str = "", token: str | None = None,
|
|
148
|
+
token_param: str | None = None, vercel: bool = False) -> dict:
|
|
149
|
+
ch = _changes(name=name, url=url, agent=agent or None, note=note or None, token=token,
|
|
150
|
+
token_param=token_param, vercel=vercel)
|
|
151
|
+
items = load()
|
|
152
|
+
for i, d in enumerate(items):
|
|
153
|
+
if _match(d, name) or _match(d, url.rstrip("/")):
|
|
154
|
+
items[i] = {**d, **ch, "id": d["id"]}
|
|
155
|
+
break
|
|
156
|
+
else:
|
|
157
|
+
items.append(ch)
|
|
158
|
+
saved = save(items)
|
|
159
|
+
return next(d for d in saved if d["url"] == url or d["name"] == name)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def edit(key: str, **changes) -> dict | None:
|
|
163
|
+
"""Change the given fields of the dashboard named key (name, id or URL); None if there is none."""
|
|
164
|
+
ch = _changes(**changes)
|
|
165
|
+
items = load()
|
|
166
|
+
for i, d in enumerate(items):
|
|
167
|
+
if _match(d, key):
|
|
168
|
+
items[i] = {**d, **ch}
|
|
169
|
+
return save(items)[i]
|
|
170
|
+
return None
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def remove(key: str) -> bool:
|
|
174
|
+
items = load()
|
|
175
|
+
kept = [d for d in items if not _match(d, key)]
|
|
176
|
+
if len(kept) == len(items):
|
|
177
|
+
return False
|
|
178
|
+
save(kept)
|
|
179
|
+
return True
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
_resolved: dict[str, tuple[float, str]] = {}
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def resolve(token: str) -> str:
|
|
186
|
+
"""A literal token as is; an EnvSave opaque key read with `envsave get es_…` (cached for 10 minutes)."""
|
|
187
|
+
if not token.startswith("es_"):
|
|
188
|
+
return token
|
|
189
|
+
hit = _resolved.get(token)
|
|
190
|
+
if hit and time.time() - hit[0] < 600:
|
|
191
|
+
return hit[1]
|
|
192
|
+
exe = shutil.which("envsave") or next((p for p in ("/opt/homebrew/bin/envsave", "/usr/local/bin/envsave")
|
|
193
|
+
if os.path.isfile(p)), None)
|
|
194
|
+
if not exe:
|
|
195
|
+
raise RuntimeError("envsave is not installed, so the dashboard's es_ token cannot be read")
|
|
196
|
+
p = subprocess.run([exe, "get", token], capture_output=True, text=True, timeout=20, stdin=subprocess.DEVNULL)
|
|
197
|
+
value = p.stdout.strip()
|
|
198
|
+
if p.returncode or not value:
|
|
199
|
+
raise RuntimeError(f"envsave get {token[:10]}… failed: {(p.stderr or 'empty').strip()[:120]}")
|
|
200
|
+
_resolved[token] = (time.time(), value)
|
|
201
|
+
return value
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def open_url(d: dict) -> str:
|
|
205
|
+
"""The URL to open: with its token as a query parameter when it has one."""
|
|
206
|
+
if not d.get("token"):
|
|
207
|
+
return d["url"]
|
|
208
|
+
param = d.get("token_param") or "token"
|
|
209
|
+
extra = [(param, resolve(d["token"]))]
|
|
210
|
+
if param == VERCEL: # a SameSite=None bypass cookie, so pages inside the fleet's frame stay logged in
|
|
211
|
+
extra.append(("x-vercel-set-bypass-cookie", "samesitenone"))
|
|
212
|
+
u = urllib.parse.urlsplit(d["url"])
|
|
213
|
+
q = [(k, v) for k, v in urllib.parse.parse_qsl(u.query, keep_blank_values=True) if k not in dict(extra)]
|
|
214
|
+
return urllib.parse.urlunsplit(u._replace(query=urllib.parse.urlencode(q + extra)))
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def find(key: str) -> dict | None:
|
|
218
|
+
return next((d for d in load() if d["id"] == key), None)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def _frameable(headers) -> bool:
|
|
222
|
+
"""Whether the page lets another site show it in a frame (X-Frame-Options, CSP frame-ancestors)."""
|
|
223
|
+
if (headers.get("X-Frame-Options") or "").strip().upper() in ("DENY", "SAMEORIGIN"):
|
|
224
|
+
return False
|
|
225
|
+
m = re.search(r"frame-ancestors([^;]*)", headers.get("Content-Security-Policy") or "", re.I)
|
|
226
|
+
if not m:
|
|
227
|
+
return True
|
|
228
|
+
srcs = m.group(1).split()
|
|
229
|
+
return "*" in srcs or any(s.rstrip("/") in ("http://127.0.0.1:*", "http://localhost:*", "http:") for s in srcs)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def _probe(d: dict) -> dict:
|
|
233
|
+
"""Is the dashboard up, and can it show in the frame? Any answer below 500 counts as up."""
|
|
234
|
+
start = time.time()
|
|
235
|
+
try:
|
|
236
|
+
url = open_url(d)
|
|
237
|
+
except (RuntimeError, OSError, subprocess.SubprocessError) as e:
|
|
238
|
+
return {"ok": False, "error": str(e)[:160], "ms": 0}
|
|
239
|
+
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0 hivey-fleet-dashboards"})
|
|
240
|
+
try:
|
|
241
|
+
with urllib.request.urlopen(req, timeout=8) as r:
|
|
242
|
+
code, final, headers = r.status, r.geturl(), r.headers
|
|
243
|
+
except urllib.error.HTTPError as e:
|
|
244
|
+
code, final, headers = e.code, e.geturl() or url, e.headers
|
|
245
|
+
except (urllib.error.URLError, OSError, ValueError) as e:
|
|
246
|
+
return {"ok": False, "error": str(getattr(e, "reason", e))[:120], "ms": round((time.time() - start) * 1000)}
|
|
247
|
+
out = {"ok": code < 500, "code": code, "ms": round((time.time() - start) * 1000), "frame": _frameable(headers)}
|
|
248
|
+
host = urllib.parse.urlsplit(final).netloc
|
|
249
|
+
if host.endswith("vercel.com") and host != urllib.parse.urlsplit(d["url"]).netloc:
|
|
250
|
+
out["login"] = "vercel" # Deployment Protection: needs the bypass secret (--vercel) to open in the frame
|
|
251
|
+
out["frame"] = False
|
|
252
|
+
return out
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def status() -> dict:
|
|
256
|
+
"""{id: {ok, code | error, ms, frame, login?}} for every dashboard, checked in parallel."""
|
|
257
|
+
items = load()
|
|
258
|
+
if not items:
|
|
259
|
+
return {}
|
|
260
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=min(8, len(items))) as pool:
|
|
261
|
+
return {d["id"]: r for d, r in zip(items, pool.map(_probe, items))}
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def main(argv: list[str] | None = None) -> int:
|
|
265
|
+
ap = argparse.ArgumentParser(prog="hivey agent-map dashboard", description=__doc__,
|
|
266
|
+
formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
267
|
+
sub = ap.add_subparsers(dest="cmd", required=True)
|
|
268
|
+
|
|
269
|
+
def login_args(p) -> None:
|
|
270
|
+
p.add_argument("--token", help="login token: the value or an EnvSave opaque key es_… (\"\" removes it)")
|
|
271
|
+
p.add_argument("--token-param", help="the query parameter the dashboard reads it from (default token)")
|
|
272
|
+
p.add_argument("--vercel", action="store_true", help="the token is Vercel's Protection Bypass secret")
|
|
273
|
+
|
|
274
|
+
a = sub.add_parser("add", help="add a dashboard (or update the one with this name or URL)")
|
|
275
|
+
a.add_argument("name")
|
|
276
|
+
a.add_argument("url")
|
|
277
|
+
a.add_argument("--agent", default="", help="the agent that keeps it")
|
|
278
|
+
a.add_argument("--note", default="", help="one line: what it shows")
|
|
279
|
+
login_args(a)
|
|
280
|
+
ls = sub.add_parser("list")
|
|
281
|
+
ls.add_argument("--json", action="store_true")
|
|
282
|
+
ed = sub.add_parser("edit", help="change a dashboard's name, URL, agent, note or token")
|
|
283
|
+
ed.add_argument("key", help="name, id or URL")
|
|
284
|
+
for f in ("name", "url", "agent", "note"):
|
|
285
|
+
ed.add_argument(f"--{f}")
|
|
286
|
+
login_args(ed)
|
|
287
|
+
rm = sub.add_parser("remove")
|
|
288
|
+
rm.add_argument("key", help="name, id or URL")
|
|
289
|
+
args = ap.parse_args(argv)
|
|
290
|
+
try:
|
|
291
|
+
if args.cmd == "add":
|
|
292
|
+
d = add(args.name, args.url, args.agent, args.note, args.token, args.token_param, args.vercel)
|
|
293
|
+
print(f"saved {d['name']} → {d['url']}{' (with login token)' if d['token'] else ''} (fleet page → 🖥 Dashboards)")
|
|
294
|
+
return 0
|
|
295
|
+
if args.cmd == "edit":
|
|
296
|
+
d = edit(args.key, name=args.name, url=args.url, agent=args.agent, note=args.note, token=args.token,
|
|
297
|
+
token_param=args.token_param, vercel=args.vercel)
|
|
298
|
+
if not d:
|
|
299
|
+
print(f"dashboards: no dashboard named {args.key}", file=sys.stderr)
|
|
300
|
+
return 1
|
|
301
|
+
print(f"saved {d['name']} → {d['url']}{' (with login token)' if d['token'] else ''}")
|
|
302
|
+
return 0
|
|
303
|
+
except ValueError as e:
|
|
304
|
+
print(f"dashboards: {e}", file=sys.stderr)
|
|
305
|
+
return 1
|
|
306
|
+
if args.cmd == "list":
|
|
307
|
+
items = public(load())
|
|
308
|
+
if args.json:
|
|
309
|
+
print(json.dumps(items, indent=1))
|
|
310
|
+
else:
|
|
311
|
+
for d in items:
|
|
312
|
+
print(f"{d['name']:<28} {d['url']}" + (f" [{d['agent']}]" if d["agent"] else "")
|
|
313
|
+
+ (f" 🔑 {d['login']}" if d["login"] else ""))
|
|
314
|
+
if not items:
|
|
315
|
+
print("no dashboards yet (fleet page → 🖥 Dashboards → + Add, or `hivey agent-map dashboard add NAME URL`)")
|
|
316
|
+
return 0
|
|
317
|
+
if args.cmd == "remove":
|
|
318
|
+
if remove(args.key):
|
|
319
|
+
print(f"removed {args.key}")
|
|
320
|
+
return 0
|
|
321
|
+
print(f"dashboards: no dashboard named {args.key}", file=sys.stderr)
|
|
322
|
+
return 1
|
|
323
|
+
return 2
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
if __name__ == "__main__":
|
|
327
|
+
sys.exit(main())
|
|
@@ -28,6 +28,8 @@ header{position:sticky;top:0;z-index:20;display:flex;flex-wrap:wrap;align-items:
|
|
|
28
28
|
.pill b{font-variant-numeric:tabular-nums}
|
|
29
29
|
.pill:hover{border-color:#3b4a64}
|
|
30
30
|
.pill.on{background:var(--panel2);border-color:var(--honey);box-shadow:0 0 0 1px var(--honey) inset}
|
|
31
|
+
.filtered{color:var(--honey);font-weight:600}
|
|
32
|
+
.filtered button{margin-left:4px;padding:1px 8px;border-radius:999px;border:1px solid var(--honey);background:transparent;color:var(--honey);cursor:pointer;font:inherit}
|
|
31
33
|
.pill.blocked b{color:var(--block)}.pill.working b{color:var(--work)}.pill.done b{color:var(--done)}.pill.idle b{color:var(--idle)}
|
|
32
34
|
.pill.compact b,.pill.clear b{color:var(--honey)}
|
|
33
35
|
.spacer{flex:1}
|
|
@@ -177,6 +179,57 @@ body.v-jobs .search{visibility:hidden}
|
|
|
177
179
|
#views .jbad.soft{background:var(--honey)}
|
|
178
180
|
.ask.job{border-color:rgba(251,113,133,.5);cursor:pointer}
|
|
179
181
|
#list{display:none;padding:12px 18px 40px}
|
|
182
|
+
/* ---------- dashboards: the list on the left, the one you pick in a frame on the right ---------- */
|
|
183
|
+
#dash{display:none;height:calc(100vh - 58px)}
|
|
184
|
+
#dash.on{display:flex}
|
|
185
|
+
body.v-dash .search{visibility:hidden}
|
|
186
|
+
body.v-dash #inbox{display:none}
|
|
187
|
+
/* the list folds away (☰ brings it back) and ⛶ gives the dashboard the whole window */
|
|
188
|
+
#dash.fold .dside{display:none}
|
|
189
|
+
#dash.max{position:fixed;inset:0;z-index:45;height:100vh!important}
|
|
190
|
+
#dash.max .dside{display:none}
|
|
191
|
+
#dash .dbar .ic{padding:4px 8px;font-size:13px;line-height:1}
|
|
192
|
+
#dash .dside{flex:none;width:290px;border-right:1px solid var(--line);display:flex;flex-direction:column;background:var(--panel)}
|
|
193
|
+
#dash .dside .hd{display:flex;align-items:center;gap:8px;padding:12px 12px 8px}
|
|
194
|
+
#dash .dside .hd h2{margin:0;font-size:15px;flex:1}
|
|
195
|
+
#dash .add{background:var(--honey);color:#1b1405;border:0;border-radius:9px;padding:6px 11px;font-weight:650;font-size:12.5px}
|
|
196
|
+
#dash .dlist{flex:1;overflow-y:auto;padding:4px 8px 10px;display:flex;flex-direction:column;gap:4px}
|
|
197
|
+
#dash .dfoot{padding:9px 12px;border-top:1px solid var(--line);color:var(--muted);font-size:11.5px;line-height:1.4}
|
|
198
|
+
#dash code{background:var(--panel2);padding:1px 5px;border-radius:5px;font-size:11px;word-break:break-all}
|
|
199
|
+
.ditem{display:flex;gap:9px;align-items:center;padding:8px 9px;border-radius:10px;cursor:pointer;border:1px solid transparent}
|
|
200
|
+
.ditem:hover{background:var(--panel2)}
|
|
201
|
+
.ditem.sel{background:var(--panel2);border-color:var(--honey)}
|
|
202
|
+
.ditem .fav{flex:none;width:28px;height:28px;border-radius:7px;background:var(--bg);display:grid;place-items:center;overflow:hidden;font-size:15px}
|
|
203
|
+
.ditem .fav img{width:18px;height:18px}
|
|
204
|
+
.ditem .tx{min-width:0;flex:1}
|
|
205
|
+
.ditem .nm{font-weight:600;font-size:13.5px;display:flex;align-items:center;gap:6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
206
|
+
.ditem .host{color:var(--muted);font-size:11.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
207
|
+
.ditem .dot{width:8px;height:8px;border-radius:50%;background:var(--idle);flex:none}
|
|
208
|
+
.ditem .dot.up{background:var(--done)}.ditem .dot.down{background:var(--block)}.ditem .dot.warn{background:var(--honey)}
|
|
209
|
+
#dash .dmain{flex:1;min-width:0;display:flex;flex-direction:column;background:var(--bg)}
|
|
210
|
+
#dash .dbar{display:flex;align-items:center;gap:8px;padding:8px 12px;border-bottom:1px solid var(--line);min-height:44px}
|
|
211
|
+
#dash .dbar .t{font-weight:650}
|
|
212
|
+
#dash .dbar .m{color:var(--muted);font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1}
|
|
213
|
+
#dash .dbar button{background:var(--panel2);border:1px solid var(--line);border-radius:8px;padding:4px 10px;font-size:12px}
|
|
214
|
+
#dash .dbar button:hover{border-color:var(--honey)}
|
|
215
|
+
#dash .dbar button.arm{border-color:var(--block);color:var(--block)}
|
|
216
|
+
#dash .dview{flex:1;position:relative}
|
|
217
|
+
#dash iframe{position:absolute;inset:0;width:100%;height:100%;border:0;background:#fff}
|
|
218
|
+
#dash .dmsg{position:absolute;inset:0;display:grid;place-items:center;text-align:center;color:var(--muted);padding:30px;background:var(--bg)}
|
|
219
|
+
#dash .dmsg[hidden]{display:none!important}
|
|
220
|
+
#dash .dmsg b{color:var(--text)}
|
|
221
|
+
#dash .dmsg button{margin-top:10px;background:var(--honey);color:#1b1405;border:0;border-radius:9px;padding:7px 14px;font-weight:650}
|
|
222
|
+
.dform{display:grid;grid-template-columns:110px 1fr;gap:9px 12px;align-items:center;padding:18px;margin:18px;border-radius:var(--r);
|
|
223
|
+
background:var(--panel);border:1px solid var(--honey);max-width:660px}
|
|
224
|
+
.dform h3{grid-column:1/-1;margin:0 0 4px;font-size:15px}
|
|
225
|
+
.dform input[type=text],.dform input[type=url],.dform input[type=password]{background:var(--bg);border:1px solid var(--line);border-radius:8px;padding:7px 10px;color:var(--text);font:inherit;outline:none}
|
|
226
|
+
.dform input:focus{border-color:var(--honey)}
|
|
227
|
+
.dform label{color:var(--muted);font-size:12.5px}
|
|
228
|
+
.dform .chk{grid-column:2;display:flex;gap:7px;align-items:center;color:var(--muted);font-size:12.5px}
|
|
229
|
+
.dform .hint{grid-column:2;color:var(--muted);font-size:11.5px;line-height:1.45;margin-top:-4px}
|
|
230
|
+
.dform .btns{grid-column:2;display:flex;gap:8px;margin-top:4px}
|
|
231
|
+
.dform .btns button{border-radius:8px;padding:6px 14px;border:1px solid var(--line);background:var(--panel2)}
|
|
232
|
+
.dform .btns button.primary{background:var(--honey);color:#1b1405;border:0;font-weight:650}
|
|
180
233
|
table{width:100%;border-collapse:collapse;font-size:12.5px}
|
|
181
234
|
th{text-align:left;color:var(--muted);font-weight:600;padding:7px 8px;border-bottom:1px solid var(--line);cursor:pointer;white-space:nowrap;position:sticky;top:57px;background:var(--bg)}
|
|
182
235
|
td{padding:6px 8px;border-bottom:1px solid #1a2130;vertical-align:top}
|
|
@@ -216,6 +269,7 @@ td.j{max-width:420px}
|
|
|
216
269
|
<button data-v="board" title="Cards by what needs you (2)">▦ Board</button>
|
|
217
270
|
<button data-v="list" title="One row per agent, for hundreds (3)">☰ List</button>
|
|
218
271
|
<button data-v="jobs" title="Agent jobs: scheduled and background jobs, their map, spend, logs and sessions (4)">📊 Jobs</button>
|
|
272
|
+
<button data-v="dash" title="Dashboards your agents keep: one place to open them all (5)">🖥 Dashboards</button>
|
|
219
273
|
</div>
|
|
220
274
|
<button class="iconbtn" id="music" title="Background music on/off (m)">🔇</button>
|
|
221
275
|
<button class="iconbtn" id="refresh" title="Read every terminal and session log again now (r)">⟳</button>
|
|
@@ -268,6 +322,7 @@ td.j{max-width:420px}
|
|
|
268
322
|
</section>
|
|
269
323
|
<section id="board"></section>
|
|
270
324
|
<section id="list"></section>
|
|
325
|
+
<section id="dash"></section>
|
|
271
326
|
<section id="jobs"><div id="jobhealth"></div><iframe id="jobsframe" title="Agent jobs"></iframe></section>
|
|
272
327
|
</main>
|
|
273
328
|
<aside id="drawer"></aside>
|
|
@@ -25,12 +25,12 @@ let data = null, agents = [], selected = null;
|
|
|
25
25
|
// settings saved before the rename (the page was the agent office) carry over
|
|
26
26
|
const ui = JSON.parse(localStorage.getItem('hv-fleet-ship') || localStorage.getItem('hv-' + 'off' + 'ice-ship') || '{}');
|
|
27
27
|
ui.view ||= 'fleet';
|
|
28
|
-
const VIEWS = ['fleet', 'board', 'list', 'jobs'];
|
|
28
|
+
const VIEWS = ['fleet', 'board', 'list', 'jobs', 'dash'];
|
|
29
29
|
let health = null, healthAt = 0; // failing scheduled jobs (pollHealth)
|
|
30
30
|
{ 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
|
|
31
|
-
ui.filter
|
|
31
|
+
ui.filter = null; // a status filter lasts until reload: a reload always shows every agent
|
|
32
32
|
if (ui.toon === undefined) ui.toon = false;
|
|
33
|
-
const save = () => localStorage.setItem('hv-fleet-ship', JSON.stringify({ view: ui.view,
|
|
33
|
+
const save = () => localStorage.setItem('hv-fleet-ship', JSON.stringify({ view: ui.view, toon: ui.toon, music: ui.music, ships: ui.ships, space: ui.space, track: ui.track }));
|
|
34
34
|
// ship positions also live on the fleet server, so every browser opens the fleet where you left it
|
|
35
35
|
const saveShips = () => { save(); fetch('/hv-fleet-settings', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ ships: ui.ships || {} }) }).catch(() => {}); };
|
|
36
36
|
|
|
@@ -211,9 +211,13 @@ function tickSub() {
|
|
|
211
211
|
const at = iso => iso ? new Date(iso).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' }) : '?';
|
|
212
212
|
const full = data.full_at && data.full_at !== data.generated
|
|
213
213
|
? ` · <span title="Last pass that re-summarized every agent whose terminal changed">summaries ${at(data.full_at)} (${ago(data.full_at)})</span>` : '';
|
|
214
|
-
|
|
214
|
+
const shown = agents.filter(visible).length;
|
|
215
|
+
const only = shown < n ? `<span class="filtered">showing ${shown} of ${n}${ui.filter ? ` (${ui.filter})` : ''} <button id="showall" title="Clear the filter and the search">show all</button></span> · ` : '';
|
|
216
|
+
$('#sub').innerHTML = only + `${n} agent${n === 1 ? '' : 's'} · <span title="Last time every terminal and session log was read">updated ${at(data.generated)} (${ago(data.generated)})</span>${full} · ` +
|
|
215
217
|
(refreshing ? '<span class="spin">⟳</span> reading terminals…' : every === 'reload' ? 'updates when you reload or press ⟳' : next > 0 ? `next ${at(new Date(Date.now() + next * 1000).toISOString())} (in ${mm}:${String(ss).padStart(2, '0')})` : 'refreshing soon') +
|
|
216
218
|
(data.error ? ` · <span class="err" title="${esc(data.error)}">summaries from the recap (model call failed)</span>` : '');
|
|
219
|
+
const all = $('#showall');
|
|
220
|
+
if (all) all.onclick = () => { ui.filter = null; $('#q').value = ''; save(); renderAll(); };
|
|
217
221
|
}
|
|
218
222
|
function renderInbox() {
|
|
219
223
|
const blocked = agents.filter(a => a.status === 'blocked' && !a.asleep);
|
|
@@ -942,6 +946,7 @@ function renderAll() {
|
|
|
942
946
|
$('#board').style.display = ui.view === 'board' ? 'block' : 'none';
|
|
943
947
|
$('#list').style.display = ui.view === 'list' ? 'block' : 'none';
|
|
944
948
|
showJobs();
|
|
949
|
+
showDash();
|
|
945
950
|
if (ui.view === 'fleet') { fleet.build(agents.filter(visible), data.sessions); fleet.resize(); }
|
|
946
951
|
if (ui.view === 'board') renderBoard();
|
|
947
952
|
if (ui.view === 'list') renderList();
|
|
@@ -962,6 +967,166 @@ function showJobs() {
|
|
|
962
967
|
}
|
|
963
968
|
fitJobs();
|
|
964
969
|
}
|
|
970
|
+
// 🖥 Dashboards: the dashboards your agents keep, listed on the left; the one you pick shows in a frame on the
|
|
971
|
+
// right. One list on the fleet server (fleet-settings.json), so every browser sees it; agents add theirs from
|
|
972
|
+
// the shell with `hivey agent-map dashboard add NAME URL` (hivey-dashboards skill). A dashboard with a login
|
|
973
|
+
// token opens through /hv-dashboard-open, which adds the token: the page itself never sees tokens.
|
|
974
|
+
let dashes = null, dashStatus = {}, dashForm = null, dashArm = false, dashAt = 0, dashBuilt = false;
|
|
975
|
+
function showDash() {
|
|
976
|
+
const on = ui.view === 'dash';
|
|
977
|
+
document.body.classList.toggle('v-dash', on);
|
|
978
|
+
$('#dash').classList.toggle('on', on);
|
|
979
|
+
if (!on) { $('#dash').classList.remove('max'); return; }
|
|
980
|
+
renderDash();
|
|
981
|
+
if (Date.now() - dashAt > 20000) loadDash();
|
|
982
|
+
}
|
|
983
|
+
async function loadDash() { // the list may have changed from the terminal; then which ones answer
|
|
984
|
+
dashAt = Date.now();
|
|
985
|
+
try { const j = await post('/hv-fleet-settings', {}); if (Array.isArray(j.dashboards)) dashes = j.dashboards; } catch { }
|
|
986
|
+
renderDash();
|
|
987
|
+
try {
|
|
988
|
+
const r = await fetch('/hv-dashboard-status', { cache: 'no-store' });
|
|
989
|
+
if (r.ok) { dashStatus = (await r.json()).status || {}; renderDash(); }
|
|
990
|
+
} catch { }
|
|
991
|
+
}
|
|
992
|
+
async function saveDash(list, msg, select) {
|
|
993
|
+
try {
|
|
994
|
+
const j = await post('/hv-fleet-settings', { dashboards: list });
|
|
995
|
+
if (!Array.isArray(j.dashboards)) throw new Error('old server');
|
|
996
|
+
dashes = j.dashboards; dashForm = null; dashArm = false;
|
|
997
|
+
if (select === 'last' && dashes.length) select = dashes[dashes.length - 1].id;
|
|
998
|
+
if (select !== undefined) { ui.dash = select; saveDashSel(); }
|
|
999
|
+
if (msg) toast(msg);
|
|
1000
|
+
$('#dframe').dataset.src = ''; // the URL or token may have changed: load it again
|
|
1001
|
+
renderDash(); loadDash();
|
|
1002
|
+
} catch { toast('Could not save: the fleet server is not answering (or is too old: reload after hivey update)'); }
|
|
1003
|
+
}
|
|
1004
|
+
const saveDashSel = () => localStorage.setItem('hv-fleet-dash', ui.dash || '');
|
|
1005
|
+
ui.dash = localStorage.getItem('hv-fleet-dash') || '';
|
|
1006
|
+
function dashHost(u) { try { return new URL(u).host; } catch { return u; } }
|
|
1007
|
+
const dashOpenUrl = d => d.login ? '/hv-dashboard-open?id=' + encodeURIComponent(d.id) : d.url;
|
|
1008
|
+
function buildDash() {
|
|
1009
|
+
$('#dash').innerHTML = `<div class="dside"><div class="hd"><h2>🖥 Dashboards</h2><button class="add" id="dadd" title="Add a dashboard">+ Add</button></div>
|
|
1010
|
+
<div class="dlist" id="dlist"></div>
|
|
1011
|
+
<div class="dfoot">Agents add theirs: <code>hivey agent-map dashboard add NAME URL</code>, or ask any agent “add this dashboard to the agent fleet”.</div></div>
|
|
1012
|
+
<div class="dmain"><div class="dbar" id="dbar"></div><div class="dview"><iframe id="dframe" title="Dashboard" referrerpolicy="no-referrer"></iframe><div class="dmsg" id="dmsg" hidden></div></div></div>`;
|
|
1013
|
+
$('#dadd').onclick = () => { $('#dmsg').innerHTML = ''; dashForm = { name: '', url: '', agent: '', note: '', token: '', vercel: false }; dashArm = false; renderDash(); $('#dmsg input')?.focus(); };
|
|
1014
|
+
$('#dlist').onclick = e => {
|
|
1015
|
+
const it = e.target.closest('.ditem');
|
|
1016
|
+
if (!it) return;
|
|
1017
|
+
ui.dash = it.dataset.id; saveDashSel(); dashForm = null; dashArm = false; renderDash();
|
|
1018
|
+
};
|
|
1019
|
+
dashBuilt = true;
|
|
1020
|
+
$('#dash').classList.toggle('fold', localStorage.getItem('hv-fleet-dash-fold') === '1');
|
|
1021
|
+
}
|
|
1022
|
+
// the frame fills the window below the header; the list can fold away; ⛶ covers the whole window (Esc leaves)
|
|
1023
|
+
function fitDash() {
|
|
1024
|
+
const box = $('#dash');
|
|
1025
|
+
if (ui.view !== 'dash' || !box || box.classList.contains('max')) return;
|
|
1026
|
+
box.style.height = Math.max(360, innerHeight - (box.getBoundingClientRect().top + scrollY)) + 'px';
|
|
1027
|
+
}
|
|
1028
|
+
addEventListener('resize', fitDash);
|
|
1029
|
+
function foldDash(on) { $('#dash').classList.toggle('fold', on); localStorage.setItem('hv-fleet-dash-fold', on ? '1' : '0'); renderDash(); }
|
|
1030
|
+
function maxDash(on) { $('#dash').classList.toggle('max', on); if (!on) fitDash(); renderDash(); }
|
|
1031
|
+
document.addEventListener('keydown', e => { if (e.key === 'Escape' && $('#dash')?.classList.contains('max')) maxDash(false); });
|
|
1032
|
+
function dashFormHtml(f) {
|
|
1033
|
+
const saved = f.id && f.login;
|
|
1034
|
+
return `<form class="dform" id="dform"><h3>${f.id ? 'Edit ' + esc(f.name) : 'Add a dashboard'}</h3>
|
|
1035
|
+
<label>Name</label><input type="text" name="name" value="${esc(f.name)}" placeholder="Trading dashboard" required>
|
|
1036
|
+
<label>URL</label><input type="url" name="url" value="${esc(f.url)}" placeholder="https://…" required>
|
|
1037
|
+
<label>Agent</label><input type="text" name="agent" value="${esc(f.agent)}" placeholder="the agent that keeps it (optional)">
|
|
1038
|
+
<label>Note</label><input type="text" name="note" value="${esc(f.note)}" placeholder="what it shows (optional)">
|
|
1039
|
+
<label>Login token</label><input type="password" name="token" value="${esc(f.token || '')}" autocomplete="off"
|
|
1040
|
+
placeholder="${saved ? (f.login === 'envsave' ? 'EnvSave key saved: leave empty to keep it' : 'token saved: leave empty to keep it') : 'optional: a token or an EnvSave key es_…'}">
|
|
1041
|
+
<div class="hint">Opening the dashboard adds it to the URL, so a dashboard that takes a token logs you in by itself.
|
|
1042
|
+
An EnvSave key (<code>es_…</code>) keeps the token in your vault. Saved on this Mac only, never shown again.</div>
|
|
1043
|
+
${saved ? `<label class="chk"><input type="checkbox" name="drop"> remove the saved token</label>` : ''}
|
|
1044
|
+
<label class="chk"><input type="checkbox" name="vercel" ${f.token_param === 'x-vercel-protection-bypass' || f.vercel ? 'checked' : ''}>
|
|
1045
|
+
behind Vercel's login: the token is its Protection Bypass secret</label>
|
|
1046
|
+
<label>Token parameter</label><input type="text" name="token_param" value="${esc(f.token_param && f.token_param !== 'x-vercel-protection-bypass' ? f.token_param : '')}" placeholder="token (the URL parameter the dashboard reads)">
|
|
1047
|
+
<div class="btns"><button class="primary" type="submit">${f.id ? 'Save' : 'Add dashboard'}</button><button type="button" id="dcancel">Cancel</button></div></form>`;
|
|
1048
|
+
}
|
|
1049
|
+
function renderDash() {
|
|
1050
|
+
if (ui.view !== 'dash') return;
|
|
1051
|
+
if (!dashBuilt) buildDash();
|
|
1052
|
+
requestAnimationFrame(fitDash);
|
|
1053
|
+
const folded = $('#dash').classList.contains('fold'), maxed = $('#dash').classList.contains('max');
|
|
1054
|
+
const sideBtns = `<button class="ic" id="dfold" title="${folded || maxed ? 'Show the dashboard list' : 'Hide the list: the dashboard gets the full width'}">${folded || maxed ? '☰' : '⟨'}</button>`;
|
|
1055
|
+
const list = dashes || [];
|
|
1056
|
+
if (!list.find(d => d.id === ui.dash) && list.length) ui.dash = list[0].id;
|
|
1057
|
+
const cur = list.find(d => d.id === ui.dash);
|
|
1058
|
+
// the list on the left
|
|
1059
|
+
$('#dlist').innerHTML = dashes === null ? '<div class="meta" style="padding:8px">loading…</div>'
|
|
1060
|
+
: !list.length ? '<div class="meta" style="padding:8px">No dashboards yet. Press <b>+ Add</b>.</div>'
|
|
1061
|
+
: list.map(d => {
|
|
1062
|
+
const s = dashStatus[d.id], cls = !s ? '' : !s.ok ? 'down' : s.login === 'vercel' && !d.login ? 'warn' : 'up';
|
|
1063
|
+
const tip = !s ? 'checking…' : !s.ok ? `not answering: ${s.error || s.code}` : `up · ${s.code} · ${s.ms} ms`;
|
|
1064
|
+
let origin = ''; try { origin = new URL(d.url).origin; } catch { }
|
|
1065
|
+
return `<div class="ditem ${d.id === ui.dash && !(dashForm && !dashForm.id) ? 'sel' : ''}" data-id="${esc(d.id)}" title="${esc(d.note || d.url)}">
|
|
1066
|
+
<div class="fav">${origin ? `<img src="${esc(origin)}/favicon.ico" alt="" onerror="this.replaceWith('🖥')">` : '🖥'}</div>
|
|
1067
|
+
<div class="tx"><div class="nm"><span class="dot ${cls}" title="${esc(tip)}"></span>${esc(d.name)}${d.login ? ' <span title="opens with its login token">🔑</span>' : ''}</div>
|
|
1068
|
+
<div class="host">${esc(d.agent ? '🤖 ' + d.agent + ' · ' : '')}${esc(dashHost(d.url))}</div></div></div>`;
|
|
1069
|
+
}).join('');
|
|
1070
|
+
// the bar and the frame on the right
|
|
1071
|
+
const bar = $('#dbar'), frame = $('#dframe'), msg = $('#dmsg');
|
|
1072
|
+
if (dashForm) {
|
|
1073
|
+
bar.innerHTML = sideBtns + `<span class="t">${dashForm.id ? 'Edit dashboard' : 'New dashboard'}</span>`;
|
|
1074
|
+
wireDashBar(folded, maxed);
|
|
1075
|
+
if (!msg.querySelector('#dform')) { msg.innerHTML = dashFormHtml(dashForm); wireDashForm(list); }
|
|
1076
|
+
msg.hidden = false; msg.style.display = 'block'; msg.style.overflow = 'auto';
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
msg.style.display = ''; msg.style.overflow = '';
|
|
1080
|
+
if (msg.querySelector('#dform')) msg.innerHTML = '';
|
|
1081
|
+
if (!cur) { bar.innerHTML = sideBtns; wireDashBar(folded, maxed); msg.hidden = false; msg.innerHTML = dashes === null ? '' : '<div><b>No dashboards yet</b><br>Add the dashboards your agents keep, and open them all from here.<br><button id="dfirst">+ Add a dashboard</button></div>';
|
|
1082
|
+
$('#dfirst')?.addEventListener('click', () => $('#dadd').click()); frame.removeAttribute('src'); frame.dataset.src = ''; return; }
|
|
1083
|
+
const s = dashStatus[cur.id];
|
|
1084
|
+
bar.innerHTML = sideBtns + `<span class="t">${esc(cur.name)}</span><span class="m">${esc(cur.note || dashHost(cur.url))}</span>
|
|
1085
|
+
<button id="dreload" title="Load it again">⟳</button><button class="ic" id="dmax" title="${maxed ? 'Back to the fleet page (Esc)' : 'Full window: the dashboard covers the whole page (Esc to leave)'}">${maxed ? '✕' : '⛶'}</button><button id="dtab" title="Open in a new browser tab">Open in tab ↗</button>
|
|
1086
|
+
<button id="dedit">Edit</button><button id="ddel" class="${dashArm ? 'arm' : ''}">${dashArm ? 'Remove?' : 'Remove'}</button>`;
|
|
1087
|
+
wireDashBar(folded, maxed);
|
|
1088
|
+
$('#dmax').onclick = () => maxDash(!maxed);
|
|
1089
|
+
$('#dreload').onclick = () => { frame.dataset.src = ''; renderDash(); };
|
|
1090
|
+
$('#dtab').onclick = () => window.open(dashOpenUrl(cur), '_blank', 'noopener');
|
|
1091
|
+
$('#dedit').onclick = () => { dashForm = { ...cur }; renderDash(); };
|
|
1092
|
+
$('#ddel').onclick = () => { if (!dashArm) { dashArm = true; renderDash(); return; } saveDash(list.filter(x => x.id !== cur.id), `Removed ${cur.name}`); };
|
|
1093
|
+
const blocked = s && s.ok && s.frame === false;
|
|
1094
|
+
if (blocked) { // the site refuses to be shown inside another page (or Vercel's login does)
|
|
1095
|
+
msg.hidden = false;
|
|
1096
|
+
msg.innerHTML = `<div><b>${esc(cur.name)} can't be shown inside the fleet page</b><br>${s.login === 'vercel' && !cur.login
|
|
1097
|
+
? 'It is behind Vercel\'s login. Edit it and add its <b>Protection Bypass for Automation</b> secret as the login token (tick “behind Vercel\'s login”); then it opens right here, logged in.'
|
|
1098
|
+
: 'The site does not allow being framed by other pages.'}<br><button id="dtab2">Open in a new tab ↗</button></div>`;
|
|
1099
|
+
$('#dtab2').onclick = () => window.open(dashOpenUrl(cur), '_blank', 'noopener');
|
|
1100
|
+
frame.removeAttribute('src'); frame.dataset.src = '';
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
msg.hidden = true;
|
|
1104
|
+
const src = dashOpenUrl(cur);
|
|
1105
|
+
if (frame.dataset.src !== src + '#' + cur.id) { frame.dataset.src = src + '#' + cur.id; frame.src = src; }
|
|
1106
|
+
}
|
|
1107
|
+
function wireDashBar(folded, maxed) {
|
|
1108
|
+
$('#dfold').onclick = () => { if (maxed) { $('#dash').classList.remove('max'); foldDash(false); } else foldDash(!folded); };
|
|
1109
|
+
}
|
|
1110
|
+
function wireDashForm(list) {
|
|
1111
|
+
const f = $('#dform');
|
|
1112
|
+
$('#dcancel').onclick = () => { dashForm = null; $('#dmsg').innerHTML = ''; renderDash(); };
|
|
1113
|
+
f.oninput = () => { const v = Object.fromEntries(new FormData(f)); Object.assign(dashForm, v, { vercel: !!v.vercel }); };
|
|
1114
|
+
f.onsubmit = e => {
|
|
1115
|
+
e.preventDefault();
|
|
1116
|
+
const v = Object.fromEntries(new FormData(f));
|
|
1117
|
+
let url = v.url.trim();
|
|
1118
|
+
if (!/^https?:\/\//i.test(url)) url = 'https://' + url;
|
|
1119
|
+
try { new URL(url); } catch { toast('That URL does not look right'); return; }
|
|
1120
|
+
const entry = { name: v.name.trim(), url, agent: v.agent.trim(), note: v.note.trim(),
|
|
1121
|
+
token_param: v.vercel ? 'x-vercel-protection-bypass' : v.token_param.trim() };
|
|
1122
|
+
if (v.token.trim()) entry.token = v.token.trim(); // no "token" key: the server keeps the saved one
|
|
1123
|
+
else if (v.drop) entry.token = '';
|
|
1124
|
+
const id = dashForm.id;
|
|
1125
|
+
const next = id ? list.map(d => d.id === id ? { id, ...entry } : d) : [...list, entry];
|
|
1126
|
+
$('#dmsg').innerHTML = '';
|
|
1127
|
+
saveDash(next, id ? `Saved ${entry.name}` : `Added ${entry.name}`, id || 'last');
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
965
1130
|
// scheduled jobs that failed (non-zero exit) or need a check, live from the page server: a count on the
|
|
966
1131
|
// Jobs tab, a chip in the top strip and a banner over the jobs pages (the nightly report is a day old)
|
|
967
1132
|
async function pollHealth() {
|
|
@@ -1103,7 +1268,7 @@ addEventListener('keydown', e => {
|
|
|
1103
1268
|
if (e.target.matches('input')) { if (e.key === 'Escape') { e.target.value = ''; e.target.blur(); renderAll(); } return; }
|
|
1104
1269
|
if (e.key === '/') { e.preventDefault(); $('#q').focus(); }
|
|
1105
1270
|
else if (e.key === 'Escape') closeDrawer();
|
|
1106
|
-
else if (e.key >= '1' && e.key <= '
|
|
1271
|
+
else if (e.key >= '1' && e.key <= '5') { ui.view = VIEWS[+e.key - 1]; save(); renderAll(); }
|
|
1107
1272
|
else if (e.key === 'r') refreshNow();
|
|
1108
1273
|
else if (e.key === 'f') fleet.fit();
|
|
1109
1274
|
else if (e.key === 't') toggleStyle();
|
|
@@ -1129,6 +1294,7 @@ $('#space').onchange = e => {
|
|
|
1129
1294
|
};
|
|
1130
1295
|
post('/hv-fleet-refresh', { load: true }).then(j => {
|
|
1131
1296
|
showEvery(j.every);
|
|
1297
|
+
if (Array.isArray(j.dashboards)) { dashes = j.dashboards; renderDash(); }
|
|
1132
1298
|
if (j.space && j.space !== String(ui.space || 'random')) { // the server's choice wins (set in another browser)
|
|
1133
1299
|
ui.space = j.space; save(); $('#space').value = j.space;
|
|
1134
1300
|
if (j.space !== 'random') fleet.setSpace(j.space);
|
|
@@ -11,6 +11,11 @@ trigger them:
|
|
|
11
11
|
GET /hv-job-health scheduled jobs whose latest run failed (non-zero exit) or needs a check (not
|
|
12
12
|
loaded, missed its run, errors in its log), from a jobs-only scan (~0.1 s, no
|
|
13
13
|
model), with each one's error lines and log tail: the Jobs tab's warnings
|
|
14
|
+
GET /hv-dashboard-status is each dashboard on the fleet page's 🖥 Dashboards tab up: {id: {ok, code | error,
|
|
15
|
+
ms, frame}}, checked in parallel from this Mac (dashboards.py; the list itself is in
|
|
16
|
+
fleet-settings.json, POST /hv-fleet-settings {"dashboards": [...]} replaces it; the
|
|
17
|
+
page never sees tokens, so an entry sent back without "token" keeps its saved one)
|
|
18
|
+
GET /hv-dashboard-open?id=<id> a redirect to that dashboard with its login token added (the frame's src)
|
|
14
19
|
POST /hv-refresh `agent_map.py refresh` (free: no model)
|
|
15
20
|
GET /fleet/ the agent fleet page (files in reports/fleet/; old /fleet/ links redirect here)
|
|
16
21
|
POST /hv-fleet-refresh `fleet.py run` in the background (the agent fleet, /fleet/)
|
|
@@ -59,7 +64,7 @@ IDLE_SECONDS = 2 * 3600
|
|
|
59
64
|
PING = "/hv-ping"
|
|
60
65
|
LEGACY_PAGE = "/office" # the fleet page's address before it was renamed; redirected to /fleet/
|
|
61
66
|
MARK = b"hivey-agent-map"
|
|
62
|
-
VERSION = b"fleet-
|
|
67
|
+
VERSION = b"fleet-18" # bump when the server gains actions, so `ensure` replaces an older one
|
|
63
68
|
FLEET_EVERY = 300 # seconds between full fleet refreshes (every terminal re-summarized) while its page is open
|
|
64
69
|
FLEET_LIVE = 60 # seconds between live passes (status, context, screen; only changed statuses summarized)
|
|
65
70
|
FLEET_WATCHED = 600 # the page counts as open for this long after its last poll
|
|
@@ -82,6 +87,11 @@ def fleet_settings() -> dict:
|
|
|
82
87
|
return {}
|
|
83
88
|
|
|
84
89
|
|
|
90
|
+
def dashboards_public() -> list:
|
|
91
|
+
import dashboards
|
|
92
|
+
return dashboards.public(dashboards.load())
|
|
93
|
+
|
|
94
|
+
|
|
85
95
|
def clean_ships(ships: object) -> dict:
|
|
86
96
|
"""{session: {x, z}} where you dragged each ship on the fleet page (bad entries dropped)."""
|
|
87
97
|
out = {}
|
|
@@ -513,6 +523,10 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
|
|
513
523
|
return self.jobs()
|
|
514
524
|
if path == "/hv-job-health":
|
|
515
525
|
return self.job_health()
|
|
526
|
+
if path == "/hv-dashboard-status":
|
|
527
|
+
return self.dashboard_status()
|
|
528
|
+
if path == "/hv-dashboard-open":
|
|
529
|
+
return self.dashboard_open(query)
|
|
516
530
|
return super().do_GET()
|
|
517
531
|
|
|
518
532
|
def job_health(self) -> None:
|
|
@@ -539,6 +553,36 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
|
|
539
553
|
"tail": (j.get("tail") or [])[-15:]})
|
|
540
554
|
return self.answer(200, json.dumps(out).encode())
|
|
541
555
|
|
|
556
|
+
def dashboard_status(self) -> None:
|
|
557
|
+
"""Which of the saved dashboards answer right now (the dots on the Dashboards tab)."""
|
|
558
|
+
port = self.server.server_address[1]
|
|
559
|
+
if self.headers.get("Host") not in (f"127.0.0.1:{port}", f"localhost:{port}"):
|
|
560
|
+
return self.answer(403, b'{"ok":false,"error":"local pages only"}')
|
|
561
|
+
import dashboards
|
|
562
|
+
return self.answer(200, json.dumps({"ok": True, "status": dashboards.status()}).encode())
|
|
563
|
+
|
|
564
|
+
def dashboard_open(self, query: str) -> None:
|
|
565
|
+
"""The frame (or new tab) for one dashboard: a redirect to its URL with its token, for this page only."""
|
|
566
|
+
port = self.server.server_address[1]
|
|
567
|
+
if self.headers.get("Host") not in (f"127.0.0.1:{port}", f"localhost:{port}") or \
|
|
568
|
+
self.headers.get("Sec-Fetch-Site", "same-origin") not in ("same-origin", "none"):
|
|
569
|
+
return self.answer(403, b"only the fleet page can open its dashboards", "text/plain")
|
|
570
|
+
import dashboards
|
|
571
|
+
d = dashboards.find(urllib.parse.parse_qs(query).get("id", [""])[0])
|
|
572
|
+
if not d:
|
|
573
|
+
return self.answer(404, b"no such dashboard", "text/plain")
|
|
574
|
+
try:
|
|
575
|
+
url = dashboards.open_url(d)
|
|
576
|
+
except (RuntimeError, OSError, subprocess.SubprocessError) as e:
|
|
577
|
+
return self.answer(500, f"cannot read the login token: {e}".encode(), "text/plain; charset=utf-8")
|
|
578
|
+
self.send_response(302)
|
|
579
|
+
self.send_header("Location", url)
|
|
580
|
+
self.send_header("Cache-Control", "no-store")
|
|
581
|
+
self.send_header("Referrer-Policy", "no-referrer")
|
|
582
|
+
self.send_header("Content-Length", "0")
|
|
583
|
+
self.end_headers()
|
|
584
|
+
return None
|
|
585
|
+
|
|
542
586
|
def jobs(self) -> None:
|
|
543
587
|
"""The fleet page's Jobs tab: the latest agent jobs page, or the first report being built."""
|
|
544
588
|
import report
|
|
@@ -573,7 +617,7 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
|
|
573
617
|
return self.answer(403, b'{"ok":false,"error":"only the agent map pages can do this"}')
|
|
574
618
|
if self.path in ("/hv-fleet-refresh", "/hv-fleet-settings"):
|
|
575
619
|
try:
|
|
576
|
-
length = min(int(self.headers.get("Content-Length") or 0),
|
|
620
|
+
length = min(int(self.headers.get("Content-Length") or 0), 262144) # the dashboards list
|
|
577
621
|
req = json.loads(self.rfile.read(length) or b"{}")
|
|
578
622
|
req = req if isinstance(req, dict) else {}
|
|
579
623
|
except ValueError:
|
|
@@ -594,9 +638,13 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
|
|
594
638
|
cur["track"] = str(req["track"])
|
|
595
639
|
if "ships" in req: # the ship positions you dragged on the fleet page
|
|
596
640
|
cur["ships"] = clean_ships(req["ships"])
|
|
597
|
-
|
|
641
|
+
import dashboards
|
|
642
|
+
if "dashboards" in req: # the Dashboards tab's list, replaced whole (bad entries dropped, tokens kept)
|
|
643
|
+
cur["dashboards"] = dashboards.clean(req["dashboards"], dashboards.clean(cur.get("dashboards")))
|
|
644
|
+
dashboards.write(cur) # owner-only: it can hold dashboard tokens
|
|
598
645
|
return self.answer(200, json.dumps({"ok": True, "every": fleet_every(), "space": cur.get("space"), "track": cur.get("track"),
|
|
599
|
-
"ships": cur.get("ships", {})
|
|
646
|
+
"ships": cur.get("ships", {}),
|
|
647
|
+
"dashboards": dashboards.public(dashboards.clean(cur.get("dashboards")))}).encode())
|
|
600
648
|
every = fleet_every()
|
|
601
649
|
# a page load: a quick pass when updating every minute, a full one otherwise; ⟳: always full
|
|
602
650
|
quick = bool(req.get("quick")) or (bool(req.get("load")) and every == "minute")
|
|
@@ -606,7 +654,8 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
|
|
606
654
|
start_fleet_refresh(quick=quick)
|
|
607
655
|
return self.answer(200, json.dumps({"ok": True, "started": True, "every": every,
|
|
608
656
|
"space": fleet_settings().get("space"), "track": fleet_settings().get("track"),
|
|
609
|
-
"ships": clean_ships(fleet_settings().get("ships"))
|
|
657
|
+
"ships": clean_ships(fleet_settings().get("ships")),
|
|
658
|
+
"dashboards": dashboards_public()}).encode())
|
|
610
659
|
if self.path == "/hv-fleet-action":
|
|
611
660
|
try:
|
|
612
661
|
length = min(int(self.headers.get("Content-Length") or 0), 4096)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hivey-dashboards
|
|
3
|
+
description: >
|
|
4
|
+
Add, list, edit and remove the dashboards shown on the hivey agent fleet page's 🖥 Dashboards
|
|
5
|
+
tab: one place to open every dashboard your agents keep (Vercel sites, local servers, Baserow
|
|
6
|
+
views, Grafana, anything with a URL). Use whenever the user says "add this dashboard to the
|
|
7
|
+
agent fleet", "register my dashboard", "remove/rename that dashboard", "which dashboards do I
|
|
8
|
+
have", "add a login token to that dashboard", or gives a dashboard URL to keep track of; and,
|
|
9
|
+
without being asked, right after you
|
|
10
|
+
build or deploy a dashboard, report page or web view for an agent, so it shows up in the fleet.
|
|
11
|
+
Works from any agent hivey runs (Claude Code, Codex, Grok, Antigravity).
|
|
12
|
+
allowed-tools:
|
|
13
|
+
- Bash
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
> Local additions: if `EXTRA_SKILL.md` exists in this skill's folder, read it too and follow it.
|
|
17
|
+
> It holds this machine's own additions; hivey updates never touch it, so put local changes
|
|
18
|
+
> there, never here.
|
|
19
|
+
|
|
20
|
+
# hivey dashboards
|
|
21
|
+
|
|
22
|
+
The fleet page (hivey menu → agent fleet, or `hivey agent-map fleet`) has a **🖥 Dashboards** tab: the
|
|
23
|
+
dashboards listed on the left with a live up/down dot, and the one you pick loaded in a frame on the right. The same list is
|
|
24
|
+
edited from the web page (**+ Add dashboard**, Edit, Remove) and from the shell, so this skill and the
|
|
25
|
+
page always agree. It lives in `~/.hivey/agent-map/fleet-settings.json` under `"dashboards"`.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
hivey agent-map dashboard list # name, URL, agent (--json for the fields)
|
|
29
|
+
hivey agent-map dashboard add "Trading dashboard" https://trading.example.app \
|
|
30
|
+
--agent trading-strategies --note "paper accounts, trades and job status"
|
|
31
|
+
hivey agent-map dashboard edit "Trading dashboard" --name "Paper trading" --url https://new.example.app
|
|
32
|
+
hivey agent-map dashboard remove "Paper trading" # by name, id or URL
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
- `add` with a name or URL already in the list updates that entry instead of adding a twin.
|
|
36
|
+
- URLs must be `http://` or `https://` (local servers like `http://localhost:3000` are fine).
|
|
37
|
+
- `--agent` is the agent that keeps the dashboard (its folder name, e.g. `trading-strategies`);
|
|
38
|
+
leave it out for the user's own. `--note` is one short line on what it shows.
|
|
39
|
+
- If `hivey` is not on PATH, run the script directly:
|
|
40
|
+
`python3 -I ~/.claude/skills/hivey-agent-map/scripts/dashboards.py add …` (same arguments).
|
|
41
|
+
|
|
42
|
+
## How to do it
|
|
43
|
+
|
|
44
|
+
1. **Get the URL.** When the user names a project but not its URL, find it: the deployed URL (e.g.
|
|
45
|
+
`vercel project ls` in that folder, a `README.md`, `.vercel/project.json`) or the local dev
|
|
46
|
+
address. Prefer the stable production URL over a per-deploy preview URL.
|
|
47
|
+
2. **Check the list first** (`dashboard list`) so you edit the existing card instead of adding a
|
|
48
|
+
duplicate under a new name.
|
|
49
|
+
3. **Run the command**, then tell the user the card is on the fleet page's 🖥 Dashboards tab
|
|
50
|
+
(an open page shows it the next time the tab opens, or after a reload).
|
|
51
|
+
4. **Removing:** confirm which one when the name is ambiguous; `remove` deletes only the card,
|
|
52
|
+
never the dashboard itself.
|
|
53
|
+
|
|
54
|
+
## Logins (tokens)
|
|
55
|
+
|
|
56
|
+
The page lists dashboards on the left and shows the picked one in a frame on the right. A private
|
|
57
|
+
dashboard can open logged in with a token:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
hivey agent-map dashboard edit "X post review" --token es_… --token-param key # ?key=<token>
|
|
61
|
+
hivey agent-map dashboard edit "Trading dashboard" --token es_… --vercel # Vercel Deployment Protection
|
|
62
|
+
hivey agent-map dashboard edit "X post review" --token "" # remove the token
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- Opening the dashboard goes through the local fleet server, which adds the token to the URL as a
|
|
66
|
+
query parameter (`--token-param`, default `token`). The dashboard has to accept a token that way.
|
|
67
|
+
- **Use an EnvSave opaque key (`es_…`) for the token**, never the raw value: it stays in the
|
|
68
|
+
user's vault and is read with `envsave get` when the dashboard opens. A raw token works, but
|
|
69
|
+
it lands in the owner-only settings file and in your shell history. Never ask for a token in
|
|
70
|
+
chat; ask the user for the `es_` key, or tell them to paste the token in the page's form
|
|
71
|
+
(Edit → Login token), which no agent sees.
|
|
72
|
+
- **Sites behind Vercel's login** (a Vercel project with Deployment Protection) refuse to load in
|
|
73
|
+
the frame; the page says so. Their "Protection Bypass for Automation" secret (Vercel project →
|
|
74
|
+
Settings → Deployment Protection) with `--vercel` opens them in the frame, logged in.
|
|
75
|
+
- Sites that forbid framing (X-Frame-Options / frame-ancestors) show an **Open in tab** button;
|
|
76
|
+
the browser's own saved login then applies.
|
|
77
|
+
- Never put a token in the name, the note or the URL itself.
|