hum-cli 0.2.70__py3-none-any.whl → 0.2.71__py3-none-any.whl
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.
- hum/__init__.py +1 -1
- hum/auth.py +40 -4
- hum/cli.py +8 -6
- hum/client.py +3 -4
- hum/core.py +32 -13
- hum/runtime/config.py +80 -0
- hum/tui/cli.mjs +17 -15
- {hum_cli-0.2.70.dist-info → hum_cli-0.2.71.dist-info}/METADATA +1 -1
- {hum_cli-0.2.70.dist-info → hum_cli-0.2.71.dist-info}/RECORD +12 -12
- {hum_cli-0.2.70.dist-info → hum_cli-0.2.71.dist-info}/WHEEL +0 -0
- {hum_cli-0.2.70.dist-info → hum_cli-0.2.71.dist-info}/entry_points.txt +0 -0
- {hum_cli-0.2.70.dist-info → hum_cli-0.2.71.dist-info}/licenses/LICENSE +0 -0
hum/__init__.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""Hum — an agent harness built as an RL environment that humans can drive."""
|
|
2
|
-
__version__ = "0.2.
|
|
2
|
+
__version__ = "0.2.71"
|
hum/auth.py
CHANGED
|
@@ -39,7 +39,7 @@ def accounts_url(auth_url: str | None) -> str:
|
|
|
39
39
|
# what the server hands out is a cache stamped with the host that issued it, never used against another
|
|
40
40
|
# what is the server's word for this process alone, never written down: the gateway is asked at the call
|
|
41
41
|
# (hum.runtime.gateway), so a file from before a move cannot send a call to the gateway the person left
|
|
42
|
-
UNSAVED = ("stale", "gateway")
|
|
42
|
+
UNSAVED = ("stale", "stale_kind", "gateway")
|
|
43
43
|
ISSUED = ("api_base", "mcp", "plugins", "search_url", "routes", "models", "org", "project")
|
|
44
44
|
|
|
45
45
|
# Which client is asking, on every request to the deployment. The deployment keeps a floor of its own and answers
|
|
@@ -114,6 +114,11 @@ class Credentials:
|
|
|
114
114
|
org: dict[str, Any] | None = None # the organization this account is in, as the server names it
|
|
115
115
|
project: dict[str, Any] | None = None # the project the repository the refresh named is bound to, if any
|
|
116
116
|
stale: str | None = None # why the last refresh did not reach the server; never written to disk
|
|
117
|
+
# what kind of failure that was, which decides what the person is told: "unreachable" (the network, a timeout,
|
|
118
|
+
# the server erring or busy: nothing for the person to do, the last answer stands), "signin" (refused: hum
|
|
119
|
+
# login), "old" (this build is below the deployment's floor: hum update) or "other"; never written to disk
|
|
120
|
+
stale_kind: str | None = None
|
|
121
|
+
refreshed_at: float | None = None # when the server last answered a refresh (epoch seconds): the cache's age
|
|
117
122
|
|
|
118
123
|
@property
|
|
119
124
|
def logged_in(self) -> bool:
|
|
@@ -336,10 +341,12 @@ def refresh(c: Credentials | None = None, timeout: float = 3.0, client: Any = No
|
|
|
336
341
|
query = {"params": {"remote": remote}} if remote else {}
|
|
337
342
|
r = http.get(f"{c.auth_url}/me", headers=headers(c.access_token), **query)
|
|
338
343
|
if too_old(r):
|
|
339
|
-
c.stale = "this build is older than the deployment allows; run `hum update`"
|
|
344
|
+
c.stale, c.stale_kind = "this build is older than the deployment allows; run `hum update`", "old"
|
|
340
345
|
return c
|
|
341
346
|
if r.status_code != 200:
|
|
342
347
|
c.stale = f"HTTP {r.status_code}"
|
|
348
|
+
c.stale_kind = ("signin" if r.status_code in (401, 403)
|
|
349
|
+
else "unreachable" if r.status_code in (408, 429) or r.status_code >= 500 else "other")
|
|
343
350
|
return c
|
|
344
351
|
d = r.json()
|
|
345
352
|
m = d.get("model") or {}
|
|
@@ -357,17 +364,46 @@ def refresh(c: Credentials | None = None, timeout: float = 3.0, client: Any = No
|
|
|
357
364
|
c.org = dict(d["org"]) if isinstance(d.get("org"), dict) else None
|
|
358
365
|
c.project = dict(d["project"]) if isinstance(d.get("project"), dict) else None
|
|
359
366
|
c.issued_by = c.auth_url
|
|
360
|
-
c.stale = None
|
|
367
|
+
c.stale = c.stale_kind = None
|
|
368
|
+
c.refreshed_at = time.time()
|
|
361
369
|
if from_environment() is None:
|
|
362
370
|
save(c) # a hosted session's credentials are its environment: nothing of the job's goes on disk
|
|
363
371
|
except httpx.HTTPError as e:
|
|
364
372
|
c.stale = type(e).__name__.replace("Error", " error").lower() or "unreachable"
|
|
373
|
+
c.stale_kind = "unreachable"
|
|
365
374
|
except Exception as e: # not the network but this machine (an OpenSSL its policy refuses): its own words
|
|
366
|
-
c.stale = f"{type(e).__name__}: {e}"
|
|
375
|
+
c.stale, c.stale_kind = f"{type(e).__name__}: {e}", "other"
|
|
367
376
|
note("refresh_failed", c.stale, "refresh")
|
|
368
377
|
return c
|
|
369
378
|
|
|
370
379
|
|
|
380
|
+
def stale_line(c: Credentials, now: float | None = None) -> tuple[bool, str]:
|
|
381
|
+
"""What the person is told when a refresh did not land, and whether it is a warning. Only what the person can
|
|
382
|
+
act on is a warning, with the one step that mends it; a server that did not answer is a note: the last answer
|
|
383
|
+
stands, its age is said, and the next start asks again. A timeout is never mended by updating or signing in."""
|
|
384
|
+
host = urlsplit(c.auth_url).hostname or c.auth_url
|
|
385
|
+
if c.stale_kind == "old":
|
|
386
|
+
return True, f"{host}: {c.stale}"
|
|
387
|
+
if c.stale_kind == "signin":
|
|
388
|
+
return True, f"{host} refused your sign-in ({c.stale}) — run `hum login`"
|
|
389
|
+
if c.stale_kind == "unreachable":
|
|
390
|
+
age = f"from {ago(c.refreshed_at, now)}" if c.refreshed_at else "from your last sign-in"
|
|
391
|
+
chosen = "" if c.auth_url.rstrip("/") == BUILD_AUTH_URL and "HUM_AUTH_URL" not in os.environ \
|
|
392
|
+
else f" · {way_back(c.auth_url)}"
|
|
393
|
+
return False, f"{host} did not answer ({c.stale}) — using your model list and tool servers {age}{chosen}"
|
|
394
|
+
return True, f"{host}: {c.stale} — model list and tool servers not refreshed ({way_back(c.auth_url)})"
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
def ago(t: float, now: float | None = None) -> str:
|
|
398
|
+
"""How long ago, in the one unit a person reads at a glance."""
|
|
399
|
+
s = max(0.0, (now if now is not None else time.time()) - t)
|
|
400
|
+
for unit, n in (("day", 86400), ("hour", 3600), ("minute", 60)):
|
|
401
|
+
if s >= n:
|
|
402
|
+
k = int(s // n)
|
|
403
|
+
return f"{k} {unit}{'s' if k != 1 else ''} ago"
|
|
404
|
+
return "just now"
|
|
405
|
+
|
|
406
|
+
|
|
371
407
|
def logout(client: Any = None, timeout: float = 5.0) -> str:
|
|
372
408
|
"""Forget the sign-in here AND revoke the token on the server. The local forget
|
|
373
409
|
always happens. Returns what the server said: "revoked", "unreachable", "refused"
|
hum/cli.py
CHANGED
|
@@ -786,13 +786,14 @@ def cmd_listen(ui: UI, cwd: Path, *, capacity: int, name: str | None, list_only:
|
|
|
786
786
|
|
|
787
787
|
|
|
788
788
|
def cmd_model(ui: UI, name: str | None) -> None:
|
|
789
|
-
|
|
789
|
+
from hum.runtime.config import keep
|
|
790
790
|
if name:
|
|
791
|
-
|
|
792
|
-
auth.save(c)
|
|
791
|
+
keep("name", None if name in ("default", "-") else name)
|
|
793
792
|
cfg = load_config()
|
|
794
|
-
|
|
795
|
-
|
|
793
|
+
source = {"HUM_MODEL": " (HUM_MODEL in your environment)", "server": " (the deployment's default)"}
|
|
794
|
+
ui.info(f"model: {cfg.model}" + source.get(cfg.model_from, "")
|
|
795
|
+
+ (f" via {cfg.api_base}" if cfg.api_base
|
|
796
|
+
else " (no host: `hum login`, or [model] api_base in config.toml)"))
|
|
796
797
|
|
|
797
798
|
|
|
798
799
|
def cmd_credits(ui: UI, code: str | None) -> int:
|
|
@@ -1533,7 +1534,8 @@ def _main(argv: list[str]) -> int:
|
|
|
1533
1534
|
# first and asks the server afterwards: nobody waits on the answer
|
|
1534
1535
|
c = auth.load() if a.cmd == "core" else auth.refresh()
|
|
1535
1536
|
if c is not None and c.logged_in and c.stale:
|
|
1536
|
-
|
|
1537
|
+
warning, line = auth.stale_line(c)
|
|
1538
|
+
(ui.warn if warning else ui.info)(line)
|
|
1537
1539
|
cfg = load_config()
|
|
1538
1540
|
if cfg.api_key is None and cfg.api_base is None and "/" in cfg.model and provider_of(cfg.model) in PROVIDER_ENV:
|
|
1539
1541
|
if (a.cmd in ("chat",
|
hum/client.py
CHANGED
|
@@ -51,7 +51,7 @@ from hum.runtime import team as teams
|
|
|
51
51
|
from hum.runtime import trust as repo_trust
|
|
52
52
|
from hum.runtime.agent_files import discover_agents, shell_name
|
|
53
53
|
from hum.runtime.ask import Asker
|
|
54
|
-
from hum.runtime.config import Config, MCPConfig, budget_usd, repository_servers
|
|
54
|
+
from hum.runtime.config import Config, MCPConfig, budget_usd, kept, repository_servers
|
|
55
55
|
from hum.runtime.constraints import Constraints
|
|
56
56
|
from hum.runtime.decision import DecisionReview
|
|
57
57
|
from hum.runtime.grader import PredicateGrader, mcp_grader
|
|
@@ -846,8 +846,7 @@ class Client:
|
|
|
846
846
|
"""What /model offers: every route the deployment gives this person (and the model in use, when it
|
|
847
847
|
is not one of them), each with the server's note; which one is in use, and which
|
|
848
848
|
is the default for new sessions (the person's choice, else the deployment's)."""
|
|
849
|
-
|
|
850
|
-
default = c.model or c.default_model
|
|
849
|
+
default = kept("name") or auth.load().default_model
|
|
851
850
|
by_name = {str(m.get("name")): m for m in self.cfg.models}
|
|
852
851
|
names = list(self.cfg.routes)
|
|
853
852
|
if self.cfg.model not in names:
|
|
@@ -872,7 +871,7 @@ class Client:
|
|
|
872
871
|
def effort_choices(self) -> list[dict[str, Any]]:
|
|
873
872
|
"""What /reasoning offers: every level, which one is in force (the deployment's default when
|
|
874
873
|
nothing was chosen), and which is the person's own default for new sessions."""
|
|
875
|
-
saved =
|
|
874
|
+
saved = kept("reasoning_effort")
|
|
876
875
|
current = self.cfg.reasoning_effort or DEFAULT_EFFORT
|
|
877
876
|
return [{"level": e, "current": e == current, "default": e == saved} for e in EFFORTS]
|
|
878
877
|
|
hum/core.py
CHANGED
|
@@ -107,7 +107,7 @@ Front-end → core (commands)
|
|
|
107
107
|
{"cmd": "credits"} → info: the person's credits on the deployment; opens the page that adds more
|
|
108
108
|
|
|
109
109
|
Core → front-end (events); every event has "type"
|
|
110
|
-
hello {model, agents_model, user, cwd, tools, mcp, comms, version, byo, budget, compact_at, gate, images,
|
|
110
|
+
hello {model, model_from, agents_model, user, cwd, tools, mcp, comms, version, byo, budget, compact_at, gate, images,
|
|
111
111
|
run_id, session, instruction, goal, state, busy, phase, needs, needs_count, status_detail, questions}
|
|
112
112
|
state: new | idle | busy | waiting | paused
|
|
113
113
|
needs: what the session wants from a person: question | decision |
|
|
@@ -226,6 +226,7 @@ from hum.runtime import team as teams
|
|
|
226
226
|
from hum.runtime import uploads as uploadsmod
|
|
227
227
|
from hum.runtime.background import Background
|
|
228
228
|
from hum.runtime.config import Config, remote_mounts
|
|
229
|
+
from hum.runtime.config import keep as keep_choice
|
|
229
230
|
from hum.runtime.hooks import Outcome
|
|
230
231
|
from hum.runtime.llm import ProviderError, describe_partial_call, error_text
|
|
231
232
|
from hum.runtime.models import Node, ToolResult, questions_of
|
|
@@ -237,6 +238,11 @@ from hum.stream import Streamer
|
|
|
237
238
|
from hum.transport import MODES, InProcess, Reader, Socket, Writer
|
|
238
239
|
from hum.ui import UI
|
|
239
240
|
|
|
241
|
+
# the refresh at start runs after the surface is up, so its bound is how long to wait for an answer, not how long the
|
|
242
|
+
# person waits: generous, and a server that did not answer is asked again before anything is said
|
|
243
|
+
REFRESH_TIMEOUT_S = 10.0
|
|
244
|
+
REFRESH_RETRY_S = (2.0, 8.0)
|
|
245
|
+
|
|
240
246
|
# an idle session with nobody attached: the core leaves (hum resume comes back to the record)
|
|
241
247
|
IDLE_EXIT_S = float(os.environ.get("HUM_IDLE_EXIT_S") or 3600)
|
|
242
248
|
EMPTY_EXIT_S = float(os.environ.get("HUM_EMPTY_EXIT_S") or 60) # no session at all, nobody attached: sooner
|
|
@@ -950,14 +956,19 @@ class Core:
|
|
|
950
956
|
latest is pushed to the surfaces; the rest stands until the next start."""
|
|
951
957
|
try:
|
|
952
958
|
remote = await self._workspace_remote()
|
|
953
|
-
c = await asyncio.to_thread(auth.refresh, remote=remote)
|
|
959
|
+
c = await asyncio.to_thread(auth.refresh, timeout=REFRESH_TIMEOUT_S, remote=remote)
|
|
960
|
+
for wait in REFRESH_RETRY_S: # nobody waits on this: a slow or busy server is asked again, not reported
|
|
961
|
+
if c is None or c.stale_kind != "unreachable":
|
|
962
|
+
break
|
|
963
|
+
await asyncio.sleep(wait)
|
|
964
|
+
c = await asyncio.to_thread(auth.refresh, timeout=REFRESH_TIMEOUT_S, remote=remote)
|
|
954
965
|
except Exception: # nothing here is worth a line: the last answer stands
|
|
955
966
|
return
|
|
956
967
|
if c is None or not c.logged_in:
|
|
957
968
|
return
|
|
958
969
|
if c.stale:
|
|
959
|
-
|
|
960
|
-
|
|
970
|
+
warning, line = auth.stale_line(c)
|
|
971
|
+
(self.ui.warn if warning else self.ui.info)(line)
|
|
961
972
|
return
|
|
962
973
|
self.cfg.latest_version, self.cfg.release_notes_url = c.latest_version, c.release_notes_url
|
|
963
974
|
self.cfg.routes = list(c.routes)
|
|
@@ -1047,7 +1058,8 @@ class Core:
|
|
|
1047
1058
|
every attached surface when the session under them changes — coming back to a session
|
|
1048
1059
|
is the same act whether it was still running or was read from the record."""
|
|
1049
1060
|
needs, opens = self.wanted()
|
|
1050
|
-
self.wire.send("hello", to=to, model=self.cfg.model,
|
|
1061
|
+
self.wire.send("hello", to=to, model=self.cfg.model, model_from=self.cfg.model_from,
|
|
1062
|
+
agents_model=self.cfg.agents_model, routes=self.cfg.routes,
|
|
1051
1063
|
user=self.cfg.user, cwd=str(self.cwd), tools=self.tool_names,
|
|
1052
1064
|
mcp=self.client.mounts, mounting=self.client.still_mounting, comms=self._comms_wire(),
|
|
1053
1065
|
version=__version__, latest_version=self.cfg.latest_version,
|
|
@@ -1676,15 +1688,25 @@ class Core:
|
|
|
1676
1688
|
self.ui.info("\n".join(f"{p['call_id']} {p['name']}" + (f" task {p['task_id']}" if p.get("task_id") else "")
|
|
1677
1689
|
+ f" {p['elapsed_s']:.0f}s" for p in out) if out else "no calls are out")
|
|
1678
1690
|
|
|
1691
|
+
def _keep(self, key: str, value: str) -> str:
|
|
1692
|
+
"""Keep a choice for new sessions (config.toml [model]) and say so; and when something the person set
|
|
1693
|
+
wins over it at the next start, name that too, so the next banner is never a surprise."""
|
|
1694
|
+
try:
|
|
1695
|
+
if keep_choice(key, value) is None:
|
|
1696
|
+
return "" # a hosted session: the job's machine keeps nothing
|
|
1697
|
+
except (OSError, ValueError) as e:
|
|
1698
|
+
return f" · not kept for new sessions: {e}"
|
|
1699
|
+
env = "HUM_MODEL" if key == "name" else "HUM_REASONING_EFFORT"
|
|
1700
|
+
if os.environ.get(env):
|
|
1701
|
+
return f" · kept for new sessions, but {env}={os.environ[env]} in your environment wins"
|
|
1702
|
+
return " · the default for new sessions"
|
|
1703
|
+
|
|
1679
1704
|
async def _cmd_model(self, cmd: dict[str, Any], w: Writer | None) -> None:
|
|
1680
1705
|
name = str(cmd.get("name", "")).strip()
|
|
1681
1706
|
if name:
|
|
1682
1707
|
text = self.client.switch_model(name, self.session, self.runner)
|
|
1683
1708
|
if cmd.get("default"):
|
|
1684
|
-
|
|
1685
|
-
c.model = name
|
|
1686
|
-
auth.save(c)
|
|
1687
|
-
text += " · the default for new sessions"
|
|
1709
|
+
text += self._keep("name", name)
|
|
1688
1710
|
self.ui.info(text)
|
|
1689
1711
|
else:
|
|
1690
1712
|
self.wire.send("models", items=self.client.model_choices(), via=self.cfg.api_base)
|
|
@@ -1720,10 +1742,7 @@ class Core:
|
|
|
1720
1742
|
self.ui.warn(f"{e.message} — {e.hint}")
|
|
1721
1743
|
return
|
|
1722
1744
|
if cmd.get("default"):
|
|
1723
|
-
|
|
1724
|
-
c.reasoning_effort = level
|
|
1725
|
-
auth.save(c)
|
|
1726
|
-
text += " · the default for new sessions"
|
|
1745
|
+
text += self._keep("reasoning_effort", level)
|
|
1727
1746
|
self.ui.info(text)
|
|
1728
1747
|
else:
|
|
1729
1748
|
self.wire.send("reasoning", items=self.client.effort_choices())
|
hum/runtime/config.py
CHANGED
|
@@ -122,6 +122,9 @@ class Config:
|
|
|
122
122
|
sandbox_allow_hosts: list[str] = field(default_factory=list) # [sandbox] allow_hosts, while network is off
|
|
123
123
|
sandbox_writable: list[str] = field(default_factory=list) # [sandbox] writable
|
|
124
124
|
sandbox_env_pass: list[str] = field(default_factory=list) # [sandbox] env_pass: names the model's commands keep
|
|
125
|
+
# where the model came from: "HUM_MODEL", "yours" (the person's kept choice), "server" (the deployment's default)
|
|
126
|
+
# or "build"; the banner names an override, so a kept choice that does not apply is never a surprise
|
|
127
|
+
model_from: str = "build"
|
|
125
128
|
routes: list[str] = field(default_factory=list) # model names the deployment offers (from sign-in / refresh)
|
|
126
129
|
models: list[dict[str, Any]] = field(default_factory=list) # per route: note, list price and context, for /model
|
|
127
130
|
# [model] context_window: the model's own context, when we serve nothing about it
|
|
@@ -285,7 +288,11 @@ def load(path: Path | None = None) -> Config:
|
|
|
285
288
|
m, pol, ui = d.get("model", {}), d.get("policy", {}), d.get("ui", {})
|
|
286
289
|
cred = _credentials()
|
|
287
290
|
key_env = m.get("api_key_env") or "HUM_API_KEY"
|
|
291
|
+
# the person's kept choice is [model] name in this file (what /model and `hum model` write); a credentials file an
|
|
292
|
+
# older build wrote still carries it until the next choice moves it here
|
|
288
293
|
model = _env("HUM_MODEL") or m.get("name") or cred.get("model") or cred.get("default_model") or Config.model
|
|
294
|
+
model_from = ("HUM_MODEL" if _env("HUM_MODEL") else "yours" if (m.get("name") or cred.get("model"))
|
|
295
|
+
else "server" if cred.get("default_model") else "build")
|
|
289
296
|
agent = None
|
|
290
297
|
if _env("HUM_AGENT"):
|
|
291
298
|
# a hosted session bound to an agent (the channel's, or a program's): the file by path or name
|
|
@@ -317,6 +324,7 @@ def load(path: Path | None = None) -> Config:
|
|
|
317
324
|
compact_at_tokens=(int(pol["compact_at_tokens"]) if pol.get("compact_at_tokens") not in (None, "") else None),
|
|
318
325
|
show_reasoning=bool(ui.get("reasoning", True)),
|
|
319
326
|
)
|
|
327
|
+
cfg.model_from = model_from
|
|
320
328
|
cfg.budget_usd = _budget(pol.get("budget_usd"), "[policy] budget_usd")
|
|
321
329
|
cfg.mcp_callback_url = str(_env("HUM_MCP_CALLBACK_URL") or d.get("mcp_callback_url") or "").strip()
|
|
322
330
|
if m.get("context_window") not in (None, ""):
|
|
@@ -359,6 +367,78 @@ def load(path: Path | None = None) -> Config:
|
|
|
359
367
|
return cfg
|
|
360
368
|
|
|
361
369
|
|
|
370
|
+
CHOICES = ("name", "reasoning_effort") # what the person keeps for new sessions, in [model]
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
def kept(key: str) -> str | None:
|
|
374
|
+
"""The person's kept choice for new sessions: ``name`` (the model) or ``reasoning_effort``, as [model] in
|
|
375
|
+
~/.hum/config.toml says, else as a credentials file an older build wrote it."""
|
|
376
|
+
assert key in CHOICES
|
|
377
|
+
p = person_config()
|
|
378
|
+
with _suppress():
|
|
379
|
+
m = tomllib.loads(p.read_text(encoding="utf-8")).get("model", {}) if p.is_file() else {}
|
|
380
|
+
if m.get(key):
|
|
381
|
+
return str(m[key])
|
|
382
|
+
legacy = _credentials().get("model" if key == "name" else key)
|
|
383
|
+
return str(legacy) if legacy else None
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
def keep(key: str, value: str | None, path: Path | None = None) -> Path | None:
|
|
387
|
+
"""Keep a choice for new sessions as [model] ``key`` in the person's config.toml, leaving every other line
|
|
388
|
+
where it was (None forgets it: the deployment's default stands again). Settings live with settings, not with
|
|
389
|
+
the sign-in: the credentials file holds who the person is. A hosted session keeps nothing: its machine is the
|
|
390
|
+
job's. Returns the file written, or None when nothing was."""
|
|
391
|
+
assert key in CHOICES
|
|
392
|
+
from hum import auth
|
|
393
|
+
if auth.from_environment() is not None:
|
|
394
|
+
return None
|
|
395
|
+
p = path or person_config()
|
|
396
|
+
text = p.read_text(encoding="utf-8") if p.is_file() else ""
|
|
397
|
+
try:
|
|
398
|
+
tomllib.loads(text) if text.strip() else {}
|
|
399
|
+
except ValueError as e:
|
|
400
|
+
raise ValueError(f"{p} is not valid TOML: {e}") from e
|
|
401
|
+
lines = text.splitlines(keepends=True)
|
|
402
|
+
head = next((i for i, ln in enumerate(lines) if ln.split("#", 1)[0].strip() == "[model]"), None)
|
|
403
|
+
entry = f"{key} = {json.dumps(value)}\n" if value is not None else None
|
|
404
|
+
if head is None:
|
|
405
|
+
if entry is not None:
|
|
406
|
+
pad = "" if not text or text.endswith("\n\n") else ("\n" if text.endswith("\n") else "\n\n")
|
|
407
|
+
lines.append(f"{pad}[model]\n{entry}")
|
|
408
|
+
else:
|
|
409
|
+
end = next((i for i in range(head + 1, len(lines)) if lines[i].lstrip().startswith("[")), len(lines))
|
|
410
|
+
at = next((i for i in range(head + 1, end) if _names_key(lines[i], key)), None)
|
|
411
|
+
if at is not None:
|
|
412
|
+
lines[at:at + 1] = [entry] if entry is not None else []
|
|
413
|
+
elif entry is not None:
|
|
414
|
+
lines.insert(head + 1, entry)
|
|
415
|
+
out = "".join(lines)
|
|
416
|
+
if tomllib.loads(out).get("model", {}).get(key) != value:
|
|
417
|
+
raise ValueError(f"{p}: could not keep [model] {key} (the file declares [model] in a form this edit does "
|
|
418
|
+
f"not follow); set it by hand")
|
|
419
|
+
if out != text:
|
|
420
|
+
p.parent.mkdir(parents=True, exist_ok=True)
|
|
421
|
+
p.write_text(out, encoding="utf-8")
|
|
422
|
+
c = auth.load() # an older build kept it with the sign-in: from here on the config is the one place
|
|
423
|
+
legacy = "model" if key == "name" else key
|
|
424
|
+
if getattr(c, legacy) is not None and auth.path().exists():
|
|
425
|
+
setattr(c, legacy, None)
|
|
426
|
+
auth.save(c)
|
|
427
|
+
return p
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
def _names_key(line: str, key: str) -> bool:
|
|
431
|
+
try:
|
|
432
|
+
return key in tomllib.loads(line)
|
|
433
|
+
except ValueError:
|
|
434
|
+
return False
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
def _suppress():
|
|
438
|
+
import contextlib
|
|
439
|
+
return contextlib.suppress(OSError, ValueError)
|
|
440
|
+
|
|
441
|
+
|
|
362
442
|
def _block_end(lines: list[str], start: int) -> int:
|
|
363
443
|
"""Where one ``[[mcp]]`` table ends: the next table header that is not one of its own
|
|
364
444
|
(``[mcp.headers]`` belongs to the table above it)."""
|
hum/tui/cli.mjs
CHANGED
|
@@ -90407,7 +90407,7 @@ var init_install = __esm({
|
|
|
90407
90407
|
"src/install.js"() {
|
|
90408
90408
|
init_define_HUM_CORE_SUBS();
|
|
90409
90409
|
win = process.platform === "win32";
|
|
90410
|
-
MINE = true ? "0.2.
|
|
90410
|
+
MINE = true ? "0.2.71" : "";
|
|
90411
90411
|
npmFix = (version = "") => `npm i -g @metaphi-ai/hum@${version || "latest"} --foreground-scripts`;
|
|
90412
90412
|
NPM_FIX = npmFix("latest");
|
|
90413
90413
|
humHome = (env3 = process.env) => env3.HUM_HOME || path.join(os3.homedir(), ".hum");
|
|
@@ -90762,10 +90762,10 @@ function clientEnv() {
|
|
|
90762
90762
|
platform: process.platform,
|
|
90763
90763
|
arch: process.arch,
|
|
90764
90764
|
terminal: process.env.TERM_PROGRAM || (process.env.WT_SESSION ? "Windows Terminal" : process.env.TERM || ""),
|
|
90765
|
-
tui: true ? "0.2.
|
|
90765
|
+
tui: true ? "0.2.71" : ""
|
|
90766
90766
|
};
|
|
90767
90767
|
}
|
|
90768
|
-
function startFailure(failures, { npm = /^(node|bun)(\.exe)?$/i.test(String(process.execPath).split(/[\\/]/).pop()), platform: platform2 = process.platform, version = true ? "0.2.
|
|
90768
|
+
function startFailure(failures, { npm = /^(node|bun)(\.exe)?$/i.test(String(process.execPath).split(/[\\/]/).pop()), platform: platform2 = process.platform, version = true ? "0.2.71" : "" } = {}) {
|
|
90769
90769
|
const refused = failures.find((f) => f.error && f.error.code !== "ENOENT");
|
|
90770
90770
|
const fix = npm ? npmFix(version) : updateCommand({ kind: "native" }, platform2);
|
|
90771
90771
|
if (!refused) {
|
|
@@ -91972,7 +91972,8 @@ function bannerLines(ev, homeRel2 = (p) => p, mine = "") {
|
|
|
91972
91972
|
const drift = mine && ev.version && mine !== ev.version ? ` \xB7 you installed ${mine}` : "";
|
|
91973
91973
|
const where = `${homeRel2(ev.cwd || "")}${ev.workspace ? ` \xB7 ${ev.workspace}` : ""}`;
|
|
91974
91974
|
const agents = ev.agents_model ? ` \xB7 agents on ${ev.agents_model}` : "";
|
|
91975
|
-
|
|
91975
|
+
const from = ev.model_from === "HUM_MODEL" ? " (HUM_MODEL)" : "";
|
|
91976
|
+
return [`hum ${ev.version || ""}`.trim() + drift + state, `${ev.model || ""}${from}${agents}${ev.user ? ` \xB7 ${ev.user}` : ""}`, where];
|
|
91976
91977
|
}
|
|
91977
91978
|
|
|
91978
91979
|
// src/app.jsx
|
|
@@ -92280,7 +92281,7 @@ var after = (ms, fn) => {
|
|
|
92280
92281
|
|
|
92281
92282
|
// src/app.jsx
|
|
92282
92283
|
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
|
|
92283
|
-
var MINE2 = true ? "0.2.
|
|
92284
|
+
var MINE2 = true ? "0.2.71" : "";
|
|
92284
92285
|
var fmtDur = (s) => s < 60 ? `${Math.max(1, Math.round(s))}s` : `${Math.floor(s / 60)}m ${Math.round(s % 60)}s`;
|
|
92285
92286
|
var plural = (n, w) => `${n} ${w}${n === 1 ? "" : "s"}`;
|
|
92286
92287
|
var shortSession = (name) => (name || "").replace(/\.jsonl$/, "");
|
|
@@ -93870,16 +93871,17 @@ ${r.content}`).join("\n\n") };
|
|
|
93870
93871
|
}
|
|
93871
93872
|
if (picker && picker.kind === "model") {
|
|
93872
93873
|
const it = picker.items[picker.index];
|
|
93873
|
-
const pick = () => {
|
|
93874
|
+
const pick = (keep) => {
|
|
93874
93875
|
setPicker(null);
|
|
93875
|
-
if (it.current) return;
|
|
93876
|
+
if (it.current && !(keep && !it.default)) return;
|
|
93876
93877
|
modelRef.current = it.name;
|
|
93877
|
-
core2.send({ cmd: "model", name: it.name });
|
|
93878
|
+
core2.send(keep ? { cmd: "model", name: it.name, default: true } : { cmd: "model", name: it.name });
|
|
93878
93879
|
};
|
|
93879
93880
|
if (key.upArrow) setPicker((p) => ({ ...p, index: (p.index + p.items.length - 1) % p.items.length }));
|
|
93880
93881
|
else if (key.downArrow || key.tab) setPicker((p) => ({ ...p, index: (p.index + 1) % p.items.length }));
|
|
93881
93882
|
else if (key.escape) setPicker(null);
|
|
93882
|
-
else if (key.return) pick();
|
|
93883
|
+
else if (key.return) pick(true);
|
|
93884
|
+
else if (input === "s" && !value.trim()) pick(false);
|
|
93883
93885
|
else if (/^[1-9]$/.test(input) && Number(input) <= picker.items.length) setPicker((p) => ({ ...p, index: Number(input) - 1 }));
|
|
93884
93886
|
return;
|
|
93885
93887
|
}
|
|
@@ -94050,11 +94052,11 @@ ${r.content}`).join("\n\n") };
|
|
|
94050
94052
|
case "/model":
|
|
94051
94053
|
if (arg) {
|
|
94052
94054
|
modelRef.current = arg;
|
|
94053
|
-
core2.send({ cmd: "model", name: arg });
|
|
94055
|
+
core2.send({ cmd: "model", name: arg, default: true });
|
|
94054
94056
|
} else core2.send({ cmd: "model" });
|
|
94055
94057
|
break;
|
|
94056
94058
|
case "/reasoning":
|
|
94057
|
-
if (arg) core2.send({ cmd: "reasoning", level: arg });
|
|
94059
|
+
if (arg) core2.send({ cmd: "reasoning", level: arg, default: true });
|
|
94058
94060
|
else core2.send({ cmd: "reasoning" });
|
|
94059
94061
|
break;
|
|
94060
94062
|
case "/diff":
|
|
@@ -94686,9 +94688,9 @@ ${r.content}`).join("\n\n") };
|
|
|
94686
94688
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text2, { dimColor: true, children: "Switch models. Served via Metaphi AI." }),
|
|
94687
94689
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text2, { children: " " }),
|
|
94688
94690
|
(() => {
|
|
94689
|
-
const nameW = Math.max(...picker.items.map((m) => m.name.length + (m.current ? 2 : 0)));
|
|
94691
|
+
const nameW = Math.max(...picker.items.map((m) => m.name.length + (m.current ? 2 : 0) + (m.default ? 10 : 0)));
|
|
94690
94692
|
return picker.items.map((m, i) => {
|
|
94691
|
-
const label = `${i + 1}. ${m.name}${m.current ? " \u2713" : ""}`.padEnd(nameW + 4);
|
|
94693
|
+
const label = `${i + 1}. ${m.name}${m.current ? " \u2713" : ""}${m.default ? " \xB7 default" : ""}`.padEnd(nameW + 4);
|
|
94692
94694
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box2, { children: [
|
|
94693
94695
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text2, { color: ACCENT, children: i === picker.index ? "\u276F " : " " }),
|
|
94694
94696
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text2, { color: m.current ? "green" : void 0, bold: i === picker.index, children: label }),
|
|
@@ -94700,7 +94702,7 @@ ${r.content}`).join("\n\n") };
|
|
|
94700
94702
|
});
|
|
94701
94703
|
})(),
|
|
94702
94704
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text2, { children: " " }),
|
|
94703
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text2, { dimColor: true, children: "Enter to switch \xB7 Esc to cancel" })
|
|
94705
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text2, { dimColor: true, children: "Enter to switch \xB7 s for this session only \xB7 Esc to cancel" })
|
|
94704
94706
|
] }),
|
|
94705
94707
|
picker && picker.kind === "reasoning" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box2, { flexDirection: "column", paddingX: 1, marginTop: 1, children: [
|
|
94706
94708
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text2, { color: ACCENT, bold: true, children: "Reasoning" }),
|
|
@@ -95063,7 +95065,7 @@ async function sendPending({
|
|
|
95063
95065
|
await init_theme();
|
|
95064
95066
|
var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
|
|
95065
95067
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
95066
|
-
var MINE3 = true ? "0.2.
|
|
95068
|
+
var MINE3 = true ? "0.2.71" : "0.0.0";
|
|
95067
95069
|
var layout = installLayout();
|
|
95068
95070
|
function completeInstall() {
|
|
95069
95071
|
if (layout.kind !== "npm" || !needsInstall(MINE3)) return;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
hum/__init__.py,sha256=
|
|
2
|
-
hum/auth.py,sha256=
|
|
1
|
+
hum/__init__.py,sha256=lCoJ4aGJrlWMHpRQcrU4l71LbeXclXqBYOSTBvhh9Ao,104
|
|
2
|
+
hum/auth.py,sha256=JWaNIaEdQM6Px9RJ0MImb_dgcW1wbXPkra-mNKYOtQ8,21171
|
|
3
3
|
hum/catalog.py,sha256=6INNvyhwu69UZV80Ri9pGRc6H2eRzSsqkW08vSfMhAU,5290
|
|
4
|
-
hum/cli.py,sha256=
|
|
5
|
-
hum/client.py,sha256=
|
|
6
|
-
hum/core.py,sha256=
|
|
4
|
+
hum/cli.py,sha256=G9m88KBd8Pa95mXEXJgX9PdDn4DJcw09sOb2PurI4vk,81508
|
|
5
|
+
hum/client.py,sha256=GUjOoN_uInzGxfJJqmIDW-Z4LFAVPHt8EkOk8f39SwU,83778
|
|
6
|
+
hum/core.py,sha256=8rZ9Lny92dpvc8fwVawzHxVB-3y685A5ggbklWzRUR8,176517
|
|
7
7
|
hum/errors.py,sha256=xnhAU0A-662IYa4kMI0zbtYfcpo24uRRAPY87BYLHs4,4858
|
|
8
8
|
hum/gitcred.py,sha256=vCynyn5ZewYJZa1vx73jQNy7KCdDjx_ppiIWegSH4wM,3698
|
|
9
9
|
hum/jsonui.py,sha256=5zlJn2n99qbz8xvGsfkhSI9Vkb0bBqzUz-vlBG6HD_8,5688
|
|
@@ -36,7 +36,7 @@ hum/runtime/ask.py,sha256=SgpoVuknFnDEIEc2S9u54ueAQOA8hhQZyxsQmmAsiIw,24084
|
|
|
36
36
|
hum/runtime/background.py,sha256=qUvtQ0x09KClO-K3gMx-IkiGfOX9fY7Naytx-Z8PL18,20850
|
|
37
37
|
hum/runtime/channel.py,sha256=bZNaFg7yAt9pgtKLcU4Rah9k3ngMYWiRxClZARBMyJo,4378
|
|
38
38
|
hum/runtime/comms.py,sha256=p03TUazJ75VpNpjLEVeDr-aKyR15n9tmAQCXhMPEKcQ,13653
|
|
39
|
-
hum/runtime/config.py,sha256=
|
|
39
|
+
hum/runtime/config.py,sha256=CP20bH1DP4EcbKBUNfTalhTSPtxuoQMdhLZ_8Qfk0hI,29562
|
|
40
40
|
hum/runtime/constraints.py,sha256=9WW-Y6W4dNIcKDdtVfxbLBCNYBb4SR18jycOCpf5gPs,6404
|
|
41
41
|
hum/runtime/decision.py,sha256=rUx1ibu5BfwmZkfyfOs1_9fRnOrVCZUk7zytLvarPpA,7876
|
|
42
42
|
hum/runtime/dm.py,sha256=79LUVsGa7Z-wgQumGbLRmQoAbnMgC9jBJz483OaZjHs,7929
|
|
@@ -118,10 +118,10 @@ hum/skills/artifact-design/references/reports.md,sha256=5MSv7JGYJHobHXfgAclt_xsf
|
|
|
118
118
|
hum/skills/consult-human/SKILL.md,sha256=5rMKwC5C9L4nn-ifTjQGXl9hsYbeqOCHNl0IEog_T-E,6867
|
|
119
119
|
hum/skills/consult-human/references/examples.md,sha256=hAdTOiJHlv27dTraEyPz0BILqx_8gZj0FPO43b2OMvw,3490
|
|
120
120
|
hum/skills/consult-human/references/hypotheses.md,sha256=a3Hj3_zdxZZS7-bpxXGu2AEgaOV5Q31iVc2VHJ2yjxQ,3263
|
|
121
|
-
hum/tui/cli.mjs,sha256=
|
|
121
|
+
hum/tui/cli.mjs,sha256=T5MyYs4KI0AIVir0SUY5Ckbjhj4HRTsc5Gs_rB2HyVI,4257857
|
|
122
122
|
humboldt/__init__.py,sha256=EcK3Ou8qg9DLaYCtm5t2EcU-C8xZxP8yxfGBiQkuW-M,236
|
|
123
|
-
hum_cli-0.2.
|
|
124
|
-
hum_cli-0.2.
|
|
125
|
-
hum_cli-0.2.
|
|
126
|
-
hum_cli-0.2.
|
|
127
|
-
hum_cli-0.2.
|
|
123
|
+
hum_cli-0.2.71.dist-info/METADATA,sha256=dsNFoJx35ROkoByv1Du_n4kegTWkIj1tMTrS2AxsRq8,1684
|
|
124
|
+
hum_cli-0.2.71.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
125
|
+
hum_cli-0.2.71.dist-info/entry_points.txt,sha256=L-JBWR79zdIsMdTN5K_PSI4HeJ4kwmo1Bm5oc3lVi5A,104
|
|
126
|
+
hum_cli-0.2.71.dist-info/licenses/LICENSE,sha256=-_Jjy2-XAujWZirw6S-ORP1kLKeVuuG8piFwhYLtt8E,742
|
|
127
|
+
hum_cli-0.2.71.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|