@hivey/cli 0.9.81 → 0.9.83
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-map/scripts/dashboards.py +31 -5
- package/repo/skills/hivey-agent-map/scripts/fleet/fleet.js +14 -9
- package/repo/skills/hivey-agent-map/scripts/serve.py +8 -2
- package/repo/skills/hivey-dashboards/SKILL.md +8 -1
|
Binary file
|
package/package.json
CHANGED
|
@@ -20,16 +20,19 @@ Logins: a dashboard can carry a token. Opening it (GET /hv-dashboard-open?id=…
|
|
|
20
20
|
the token added as a query parameter (`token_param`, default `token`), so a dashboard with token login
|
|
21
21
|
(the hivey-dashboards skill's references/token-login.md) logs you in by itself. The token is a literal value,
|
|
22
22
|
an EnvSave opaque key (`es_…`, read with `envsave get` when the dashboard opens; no Touch ID), or `default`:
|
|
23
|
-
your default dashboard token (one EnvSave key, `dashboard_token` in the settings file
|
|
24
|
-
dashboards, so changing it updates every one.
|
|
23
|
+
your default dashboard token (one EnvSave key, `dashboard_token` in the settings file, else the one built in
|
|
24
|
+
for your user in USER_TOKENS) that opens all your dashboards, so changing it updates every one. A new
|
|
25
|
+
dashboard uses it unless you say it needs no login (`--no-token`). Tokens are never sent to the page's list.
|
|
25
26
|
Python standard library only.
|
|
26
27
|
"""
|
|
27
28
|
from __future__ import annotations
|
|
28
29
|
|
|
29
30
|
import argparse
|
|
30
31
|
import concurrent.futures
|
|
32
|
+
import getpass
|
|
31
33
|
import json
|
|
32
34
|
import os
|
|
35
|
+
import pwd
|
|
33
36
|
import re
|
|
34
37
|
import shutil
|
|
35
38
|
import subprocess
|
|
@@ -46,6 +49,13 @@ LIMITS = {"name": 80, "url": 2000, "agent": 80, "note": 300}
|
|
|
46
49
|
DEFAULT = "default" # the token value meaning "my default dashboard token"
|
|
47
50
|
PARAM = re.compile(r"^[A-Za-z0-9_.-]{1,64}$")
|
|
48
51
|
FIELDS = ("name", "url", "agent", "note", "token", "token_param")
|
|
52
|
+
# Each known user's default dashboard token (their DASHBOARD_TOKEN_<USER> EnvSave key), used until they save
|
|
53
|
+
# their own (`dashboard token es_…`, or the Edit form). Matched on the Mac login and full name. Anyone else
|
|
54
|
+
# types theirs once in the form, and it is saved for next time.
|
|
55
|
+
USER_TOKENS = (
|
|
56
|
+
(("jcsancho", "jose"), "es_AN_xOxHk9IU6KbcaRxXEndz0xHcHj0NKIRnb79Iq2QV7Hr6f"),
|
|
57
|
+
(("alyssa",), "es_8AC8PzeSobAcZMD1PV6gnZwo7bezsQkiQoswZu7BZqbgecKb"),
|
|
58
|
+
)
|
|
49
59
|
|
|
50
60
|
|
|
51
61
|
def _settings() -> dict:
|
|
@@ -152,7 +162,7 @@ def add(name: str, url: str, agent: str = "", note: str = "", token: str | None
|
|
|
152
162
|
items[i] = {**d, **ch, "id": d["id"]}
|
|
153
163
|
break
|
|
154
164
|
else:
|
|
155
|
-
items.append(ch)
|
|
165
|
+
items.append({"token": DEFAULT, **ch}) # a new dashboard logs in with your default token unless told not to
|
|
156
166
|
saved = save(items)
|
|
157
167
|
return next(d for d in saved if d["url"] == url or d["name"] == name)
|
|
158
168
|
|
|
@@ -177,9 +187,21 @@ def remove(key: str) -> bool:
|
|
|
177
187
|
return True
|
|
178
188
|
|
|
179
189
|
|
|
190
|
+
def builtin_token() -> str:
|
|
191
|
+
"""The default dashboard token built in for this Mac's user (USER_TOKENS), "" for anyone else."""
|
|
192
|
+
try:
|
|
193
|
+
user = getpass.getuser()
|
|
194
|
+
who = f"{user} {pwd.getpwnam(user).pw_gecos}".lower()
|
|
195
|
+
except (KeyError, OSError):
|
|
196
|
+
who = os.environ.get("USER", "").lower()
|
|
197
|
+
words = set(re.findall(r"[a-z0-9]+", who))
|
|
198
|
+
return next((tok for names, tok in USER_TOKENS if any(n in words for n in names)), "")
|
|
199
|
+
|
|
200
|
+
|
|
180
201
|
def default_token() -> str:
|
|
181
|
-
"""Your default dashboard token: an EnvSave key (es_…) or a
|
|
182
|
-
|
|
202
|
+
"""Your default dashboard token: the one you saved, else your built-in one; an EnvSave key (es_…) or a
|
|
203
|
+
value, "" when there is none."""
|
|
204
|
+
return str(_settings().get("dashboard_token") or "").strip() or builtin_token()
|
|
183
205
|
|
|
184
206
|
|
|
185
207
|
def set_default_token(token: str) -> None:
|
|
@@ -283,6 +305,8 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
283
305
|
p.add_argument("--token", help="login token: default (your default dashboard token), an EnvSave key es_… "
|
|
284
306
|
"or a value (\"\" removes it)")
|
|
285
307
|
p.add_argument("--token-param", help="the query parameter the dashboard reads it from (default token)")
|
|
308
|
+
p.add_argument("--no-token", dest="token", action="store_const", const="",
|
|
309
|
+
help="it needs no login token (a new dashboard uses your default token otherwise)")
|
|
286
310
|
|
|
287
311
|
a = sub.add_parser("add", help="add a dashboard (or update the one with this name or URL)")
|
|
288
312
|
a.add_argument("name")
|
|
@@ -307,7 +331,9 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
307
331
|
if args.clear or args.value:
|
|
308
332
|
set_default_token("" if args.clear else args.value)
|
|
309
333
|
cur = default_token()
|
|
334
|
+
built = cur and not str(_settings().get("dashboard_token") or "").strip()
|
|
310
335
|
print(f"default dashboard token: {cur[:8] + '…' if cur.startswith('es_') else ('set (a raw value)' if cur else 'none')}"
|
|
336
|
+
+ (" (built in for this user)" if built else "")
|
|
311
337
|
+ ("" if cur else " (set it: hivey agent-map dashboard token es_…)"))
|
|
312
338
|
return 0
|
|
313
339
|
try:
|
|
@@ -1031,8 +1031,9 @@ function foldDash(on) { $('#dash').classList.toggle('fold', on); localStorage.se
|
|
|
1031
1031
|
function maxDash(on) { $('#dash').classList.toggle('max', on); if (!on) fitDash(); renderDash(); }
|
|
1032
1032
|
document.addEventListener('keydown', e => { if (e.key === 'Escape' && $('#dash')?.classList.contains('max')) maxDash(false); });
|
|
1033
1033
|
function dashFormHtml(f) {
|
|
1034
|
-
// Login:
|
|
1035
|
-
const
|
|
1034
|
+
// Login: on by default; your default dashboard token (one EnvSave key that opens all your dashboards) or a token for this one
|
|
1035
|
+
const use = f.uselogin !== undefined ? f.uselogin : f.id ? !!f.login : true;
|
|
1036
|
+
const mode = f.mode || (f.login && f.login !== 'default' ? 'own' : 'default');
|
|
1036
1037
|
const saved = f.id && f.login && f.login !== 'default';
|
|
1037
1038
|
return `<form class="dform" id="dform"><h3>${f.id ? 'Edit ' + esc(f.name) : 'Add a dashboard'}</h3>
|
|
1038
1039
|
<label>Name</label><input type="text" name="name" value="${esc(f.name)}" placeholder="Trading dashboard" required>
|
|
@@ -1040,11 +1041,12 @@ function dashFormHtml(f) {
|
|
|
1040
1041
|
<label>Agent</label><input type="text" name="agent" value="${esc(f.agent)}" placeholder="the agent that keeps it (optional)">
|
|
1041
1042
|
<label>Note</label><input type="text" name="note" value="${esc(f.note)}" placeholder="what it shows (optional)">
|
|
1042
1043
|
<label>Login</label><span class="chk" style="grid-column:auto;flex-wrap:wrap;gap:12px">
|
|
1043
|
-
<label class="chk" style="grid-column:auto"><input type="
|
|
1044
|
-
|
|
1045
|
-
<label class="chk" style="grid-column:auto"><input type="radio" name="mode" value="own" ${mode === 'own' ? 'checked' : ''}> a token for this one</label
|
|
1046
|
-
${mode === 'default'
|
|
1047
|
-
|
|
1044
|
+
<label class="chk" style="grid-column:auto" title="Untick for a dashboard that opens without a token"><input type="checkbox" name="uselogin" ${use ? 'checked' : ''}> login token</label>
|
|
1045
|
+
${use ? `<label class="chk" style="grid-column:auto"><input type="radio" name="mode" value="default" ${mode === 'default' ? 'checked' : ''}> my dashboard token</label>
|
|
1046
|
+
<label class="chk" style="grid-column:auto"><input type="radio" name="mode" value="own" ${mode === 'own' ? 'checked' : ''}> a token for this one</label>` : ''}</span>
|
|
1047
|
+
${use && mode === 'default' ? `<label>Your token</label><input type="password" name="deftoken" value="${esc(f.deftoken || '')}" autocomplete="off"
|
|
1048
|
+
placeholder="${dashDefault ? 'saved: leave empty to keep it, or type a new EnvSave key es_…' : 'EnvSave key es_… (saved once, used by all your dashboards)'}" ${dashDefault ? '' : 'required'}>` : ''}
|
|
1049
|
+
${use && mode === 'own' ? `<label>Token</label><input type="password" name="token" value="${esc(f.token || '')}" autocomplete="off"
|
|
1048
1050
|
placeholder="${saved ? 'token saved: leave empty to keep it' : 'an EnvSave key es_… or the token'}" ${saved ? '' : 'required'}>
|
|
1049
1051
|
<label>Parameter</label><input type="text" name="token_param" value="${esc(f.token_param || '')}" placeholder="token (the URL parameter the dashboard reads)">` : ''}
|
|
1050
1052
|
<div class="hint">Opening the dashboard adds the token to its URL (<code>?token=…</code>), so a dashboard with token login logs you in by
|
|
@@ -1102,6 +1104,8 @@ function renderDash() {
|
|
|
1102
1104
|
msg.hidden = false;
|
|
1103
1105
|
msg.innerHTML = `<div><b>${esc(cur.name)} can't be shown inside the fleet page</b><br>${s.elsewhere
|
|
1104
1106
|
? `It sends you to <b>${esc(s.elsewhere)}</b> first, a login page that refuses frames. Turn that hosting login off (for a Vercel project: Settings → Deployment Protection) and give the dashboard token login instead (hivey-dashboards skill).`
|
|
1107
|
+
: /(^|\.)claude\.(ai|site)$/i.test(dashHost(cur.url))
|
|
1108
|
+
? 'claude.ai artifacts can\'t be shown inside another page. Open it in a new tab instead.'
|
|
1105
1109
|
: 'The site does not allow being shown inside other pages (X-Frame-Options or frame-ancestors).'}<br><button id="dtab2">Open in a new tab ↗</button></div>`;
|
|
1106
1110
|
$('#dtab2').onclick = () => window.open(dashOpenUrl(cur), '_blank', 'noopener');
|
|
1107
1111
|
frame.removeAttribute('src'); frame.dataset.src = '';
|
|
@@ -1118,7 +1122,8 @@ function wireDashForm(list) {
|
|
|
1118
1122
|
const f = $('#dform');
|
|
1119
1123
|
$('#dcancel').onclick = () => { dashForm = null; $('#dmsg').innerHTML = ''; renderDash(); };
|
|
1120
1124
|
f.oninput = () => Object.assign(dashForm, Object.fromEntries(new FormData(f)));
|
|
1121
|
-
|
|
1125
|
+
const redraw = () => { Object.assign(dashForm, Object.fromEntries(new FormData(f)), { uselogin: f.uselogin.checked }); $('#dmsg').innerHTML = ''; renderDash(); };
|
|
1126
|
+
f.querySelectorAll('input[name=mode], input[name=uselogin]').forEach(r => r.onchange = redraw);
|
|
1122
1127
|
f.onsubmit = e => {
|
|
1123
1128
|
e.preventDefault();
|
|
1124
1129
|
const v = Object.fromEntries(new FormData(f));
|
|
@@ -1126,7 +1131,7 @@ function wireDashForm(list) {
|
|
|
1126
1131
|
if (!/^https?:\/\//i.test(url)) url = 'https://' + url;
|
|
1127
1132
|
try { new URL(url); } catch { toast('That URL does not look right'); return; }
|
|
1128
1133
|
const entry = { name: v.name.trim(), url, agent: v.agent.trim(), note: v.note.trim(), token_param: (v.token_param || '').trim() };
|
|
1129
|
-
if (
|
|
1134
|
+
if (!f.uselogin.checked) entry.token = '';
|
|
1130
1135
|
else if (v.mode === 'default') entry.token = 'default';
|
|
1131
1136
|
else if ((v.token || '').trim()) entry.token = v.token.trim(); // no "token" key: the server keeps the saved one
|
|
1132
1137
|
else if (dashForm.login === 'default' || !dashForm.login) { toast('Type the token for this dashboard'); return; }
|
|
@@ -93,6 +93,12 @@ def dashboards_public() -> list:
|
|
|
93
93
|
return dashboards.public(dashboards.load())
|
|
94
94
|
|
|
95
95
|
|
|
96
|
+
def has_default_token() -> bool:
|
|
97
|
+
"""Is there a default dashboard token (saved, or built in for this user)?"""
|
|
98
|
+
import dashboards
|
|
99
|
+
return bool(dashboards.default_token())
|
|
100
|
+
|
|
101
|
+
|
|
96
102
|
def clean_ships(ships: object) -> dict:
|
|
97
103
|
"""{session: {x, z}} where you dragged each ship on the fleet page (bad entries dropped)."""
|
|
98
104
|
out = {}
|
|
@@ -658,7 +664,7 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
|
|
658
664
|
return self.answer(200, json.dumps({"ok": True, "every": fleet_every(), "space": cur.get("space"), "track": cur.get("track"),
|
|
659
665
|
"ships": cur.get("ships", {}),
|
|
660
666
|
"dashboards": dashboards.public(dashboards.clean(cur.get("dashboards"))),
|
|
661
|
-
"default_token": bool(
|
|
667
|
+
"default_token": bool(dashboards.default_token())}).encode())
|
|
662
668
|
every = fleet_every()
|
|
663
669
|
# a page load: a quick pass when updating every minute, a full one otherwise; ⟳: always full
|
|
664
670
|
quick = bool(req.get("quick")) or (bool(req.get("load")) and every == "minute")
|
|
@@ -670,7 +676,7 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
|
|
670
676
|
"space": fleet_settings().get("space"), "track": fleet_settings().get("track"),
|
|
671
677
|
"ships": clean_ships(fleet_settings().get("ships")),
|
|
672
678
|
"dashboards": dashboards_public(),
|
|
673
|
-
"default_token":
|
|
679
|
+
"default_token": has_default_token()}).encode())
|
|
674
680
|
if self.path == "/hv-fleet-action":
|
|
675
681
|
try:
|
|
676
682
|
length = min(int(self.headers.get("Content-Length") or 0), 4096)
|
|
@@ -27,7 +27,10 @@ shell, so this skill and the page always agree.
|
|
|
27
27
|
## How the login works
|
|
28
28
|
|
|
29
29
|
Each user has one **dashboard token** (EnvSave key `DASHBOARD_TOKEN_<USER>`, 32+ characters) that opens
|
|
30
|
-
all their dashboards. hivey
|
|
30
|
+
all their dashboards. hivey keeps it as the *default dashboard token*: Jose's and Alyssa's keys are built in
|
|
31
|
+
(`USER_TOKENS` in `dashboards.py`, matched on the Mac user), anyone else types theirs once in the form and it
|
|
32
|
+
is saved for next time; either can be changed later in a dashboard's Edit form or with `dashboard token es_…`.
|
|
33
|
+
A new dashboard logs in with it by default; untick "login token" (or `--no-token`) for one that needs none; a dashboard registered with
|
|
31
34
|
`--token default` opens as `https://<site>/?token=<it>`, and the site trades the token for its own session
|
|
32
35
|
cookie. No hosting login (no Vercel Deployment Protection): it refuses frames, and the token login protects
|
|
33
36
|
the site instead. Tokens never reach the page; the local fleet server adds them when a dashboard opens.
|
|
@@ -55,6 +58,7 @@ hivey agent-map dashboard add "Trading dashboard" https://trading.example.app \
|
|
|
55
58
|
--agent trading-strategies --note "paper accounts, trades and job status" --token default
|
|
56
59
|
hivey agent-map dashboard edit "Trading dashboard" --name "Paper trading" --url https://new.example.app
|
|
57
60
|
hivey agent-map dashboard edit "Trading dashboard" --token default # or es_… for its own token, "" for none
|
|
61
|
+
hivey agent-map dashboard add "Status page" https://status.example.app --no-token # opens without a login
|
|
58
62
|
hivey agent-map dashboard remove "Paper trading" # by name, id or URL; removes the card only
|
|
59
63
|
hivey agent-map dashboard token # is a default dashboard token set?
|
|
60
64
|
hivey agent-map dashboard token es_… # set it (the user's DASHBOARD_TOKEN_<USER> key)
|
|
@@ -80,3 +84,6 @@ hivey agent-map dashboard token es_… # set it (the user's DASHBO
|
|
|
80
84
|
The page says why. "Sends you to another site": a hosting login wall (turn it off and use the token login);
|
|
81
85
|
"does not allow being shown inside other pages": remove `X-Frame-Options` / `frame-ancestors` from the
|
|
82
86
|
site. A red dot means the site did not answer, or its token could not be read.
|
|
87
|
+
claude.ai artifact links (`claude.ai/artifact/…`, `claude.ai/public/artifacts/…`, `/embed` too) can never
|
|
88
|
+
show in the frame (claude.ai sends `frame-ancestors 'self'`). Registering them is fine: the page says so and
|
|
89
|
+
its "Open in a new tab" button opens them.
|