herdr-orchestra 6.48.0 → 6.48.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,36 @@
2
2
 
3
3
  All notable changes. Versions follow [semantic versioning](https://semver.org).
4
4
 
5
+ ## [6.48.1] - 2026-12-02
6
+
7
+ `orch board` gets a TOKENS part: one row per agent (the lead, each coder, the reviewer) with what it read (in, and the cached part of that) and what it wrote (out), counted live. Before, a job's tokens showed only after the job ended. Now the job an agent is running counts too, read from the agent's own log from the job's start to now, so the numbers move after each reply the tool writes. The board looks again every 10 seconds while a job runs. Each coder that is on a milestone also shows that milestone's role and the skills the plan gave it.
8
+
9
+ Example:
10
+ ```
11
+ AGENTS
12
+ ● codex-1 codex M2 · building
13
+ role: senior frontend engineer
14
+ skills: frontend-developer (codex can't see its folder), ghost-skill (not in this repo)
15
+
16
+ TOKENS read live from each agent's own log
17
+ in cached out
18
+ ◆ lead-1 codex 50k 30k 4k
19
+ ● codex-1 codex 100k 76k 7k M2 now 44k
20
+ ○ rev-1 codex 8k 6k 1k
21
+ ○ oc-1 opencode n/a: orch can't read opencode's logs yet
22
+ total 158k 112k 12k
23
+ ```
24
+
25
+ Which agents can show live numbers: Claude Code, Codex and Pi save the token count after every reply, so they show live. Antigravity (agy) is read the same way, but it has not yet been checked on a real machine whether agy writes its log while it works or only at the end. OpenCode logs are not read yet, so OpenCode agents show "n/a" with that reason, never a guessed number.
26
+
27
+ ### Added
28
+ - `orch board`: TOKENS part (in, cached, out per agent; "Mn now" for the running job; total), "+Nk now" on a building milestone, and a role and skills line under each busy coder. A skill the coder's tool can't see, or that is not in the repo, is marked.
29
+ - `orch view`: "Tokens per agent (live)" in the Time and tokens card, the total includes running jobs, and each busy coder shows its role and skills. The page gets a fresh copy every 10 seconds while a job runs.
30
+ - `orch status --json`: `agent_tokens`, plus `step_role` and `skills` on busy coders.
31
+
32
+ ### Changed
33
+ - The board and the view read the logs themselves (read only). A log is read again only when its size or change time changed. The lead reads no new text and gets no new wake-ups.
34
+
5
35
  ## [6.48.0] - 2026-12-02
6
36
 
7
37
  The lead now follows a repository's own delivery standard. When `AGENTS.md` points to one (a doc, a checklist, a skill or a link that says what every change must deliver), the lead reads it while planning, writes the requirements that apply to this change into the plan, makes sure every coder's brief spells them out as plain instructions (so a coder that does not have that doc or skill can still follow them), and checks each one at the end. A repository whose `AGENTS.md` names no delivery standard gets exactly the same plan and run as before.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 6.48.0
1
+ 6.48.1
Binary file
package/bin/orch CHANGED
@@ -2475,8 +2475,31 @@ TOKEN_GLOBS = {"claude": "*/*.jsonl", "codex": "**/rollout-*.jsonl*", "pi": "*/*
2475
2475
  "agy": "*/.system_generated/logs/transcript_full.jsonl"}
2476
2476
 
2477
2477
 
2478
+ _TOK_TEXT = {}
2479
+
2480
+
2478
2481
  def _tok_text(path):
2482
+ """A log's text. The live board reads the same logs every few seconds: a file that has not changed since the last
2483
+ read is not read again (kept by size and change time, the last few files only)."""
2479
2484
  p = str(path)
2485
+ try:
2486
+ s = os.stat(p)
2487
+ sig = (s.st_mtime_ns, s.st_size)
2488
+ except OSError:
2489
+ sig = None
2490
+ hit = _TOK_TEXT.get(p)
2491
+ if sig and hit and hit[0] == sig:
2492
+ return hit[1]
2493
+ text = _tok_text_read(p)
2494
+ if sig:
2495
+ _TOK_TEXT.pop(p, None)
2496
+ _TOK_TEXT[p] = (sig, text)
2497
+ while len(_TOK_TEXT) > 12:
2498
+ _TOK_TEXT.pop(next(iter(_TOK_TEXT)))
2499
+ return text
2500
+
2501
+
2502
+ def _tok_text_read(p):
2480
2503
  if p.endswith(".zst"):
2481
2504
  if not shutil.which("zstd"):
2482
2505
  raise TokenNA("the log is compressed (.zst) and the `zstd` tool is not installed")
@@ -2912,6 +2935,148 @@ def token_lines(acct):
2912
2935
  return out
2913
2936
 
2914
2937
 
2938
+ # ---- live tokens per agent, for the board and the browser view (6.48.1). The board process reads the logs, never
2939
+ # the lead: a running job's tokens are its log from the job's start to now, so they move after each reply the tool
2940
+ # writes. Read only, and a log is read again only when it changed.
2941
+ _LIVE_FIND, _LIVE_MISS, _LIVE_WIN = {}, {}, {}
2942
+
2943
+
2944
+ def _tok_sig(kind, path):
2945
+ files = [Path(path)]
2946
+ if kind == "claude":
2947
+ files += sorted((Path(path).with_suffix("") / "subagents").glob("*.jsonl"))
2948
+ sig = []
2949
+ for f in files:
2950
+ with contextlib.suppress(OSError):
2951
+ s = f.stat()
2952
+ sig.append((str(f), s.st_mtime_ns, s.st_size))
2953
+ return tuple(sig)
2954
+
2955
+
2956
+ def token_live(st, agent, kind, marker, start, end=None):
2957
+ """One job's tokens up to now (end None: still running) or up to its end: {"in", "cached", "out"}, {"na": why},
2958
+ or None (no reply in the tool's log yet)."""
2959
+ if not kind:
2960
+ return {"na": "orch does not know which tool this agent runs"}
2961
+ if kind not in TOKEN_KINDS:
2962
+ return {"na": f"orch can't read {kind}'s logs yet"}
2963
+ if not marker:
2964
+ return {"na": "no job prompt to find the log by"}
2965
+ path = _LIVE_FIND.get((kind, marker))
2966
+ if not path or not Path(path).exists():
2967
+ if time.time() - _LIVE_MISS.get((kind, marker), 0) < 10: # not there 10s ago: don't search every redraw
2968
+ return None
2969
+ path = token_log_find(kind, marker, start, (st.get("token_logs") or {}).get(agent) or [])
2970
+ if not path:
2971
+ _LIVE_MISS[(kind, marker)] = time.time()
2972
+ return None
2973
+ _LIVE_FIND[(kind, marker)] = path
2974
+ key, sig = (kind, path, start, end), _tok_sig(kind, path)
2975
+ hit = _LIVE_WIN.get(key)
2976
+ if hit and hit[0] == sig:
2977
+ return hit[1]
2978
+ try:
2979
+ acc = token_window(kind, path, start, end + 1 if end else float("inf"))
2980
+ r = {"in": acc["in"], "cached": acc["cached"], "out": acc["out"]} if acc["replies"] else None
2981
+ except TokenNA as e:
2982
+ r = {"na": str(e)}
2983
+ _LIVE_WIN[key] = (sig, r)
2984
+ if len(_LIVE_WIN) > 200:
2985
+ _LIVE_WIN.pop(next(iter(_LIVE_WIN)))
2986
+ return r
2987
+
2988
+
2989
+ def agent_tokens(st):
2990
+ """Tokens per agent (lead, each coder, the reviewer): every finished job plus the one it runs now, read live.
2991
+ [{name, role, kind, in, cached, out, known, jobs, na: [why], task: running milestone, now: its tokens so far}]"""
2992
+ rows, t_now = {}, now()
2993
+
2994
+ def row(name, role, kind):
2995
+ if name not in rows:
2996
+ rows[name] = {"name": name, "role": role, "kind": kind, "in": 0, "cached": 0, "out": 0, "known": 0,
2997
+ "jobs": 0, "na": [], "task": None, "now": None}
2998
+ return rows[name]
2999
+
3000
+ def add(r, u):
3001
+ r["jobs"] += 1
3002
+ if "na" in u:
3003
+ r["na"].append(u["na"])
3004
+ return
3005
+ r["known"] += 1
3006
+ for k in ("in", "cached", "out"):
3007
+ r[k] += int(u.get(k) or 0)
3008
+ ld, run = st.get("lead") or {}, st.get("run") or {}
3009
+ if ld.get("name"):
3010
+ r = row(ld["name"], "lead", ld.get("kind"))
3011
+ if run.get("started"):
3012
+ u = token_live(st, ld["name"], ld.get("kind"), f"in the run on {st.get('branch')} need the lead",
3013
+ run["started"], run.get("ended"))
3014
+ saved = run.get("lead_tokens")
3015
+ if (u is None or "na" in u) and isinstance(saved, dict) and "na" not in saved:
3016
+ u = saved
3017
+ add(r, u or {"na": "orch has not woken the lead in this run yet"})
3018
+ for n, w in st.get("workers", {}).items():
3019
+ row(n, "coder", w.get("kind"))
3020
+ if st.get("reviewer"):
3021
+ row(st["reviewer"], "reviewer", (st.get("reviewer_info") or {}).get("kind"))
3022
+ for tid in st.get("order", []):
3023
+ t = st["tasks"].get(tid) or {}
3024
+ for a in t.get("attempts") or []:
3025
+ if not isinstance(a, dict) or not a.get("agent") or not (a.get("tok_marker") or a.get("tokens")):
3026
+ continue
3027
+ r = row(a["agent"], "reviewer" if a.get("kind") == "reviewer" else "coder",
3028
+ a.get("tok_kind") or agent_kind_of(st, a["agent"]))
3029
+ u = a.get("tokens")
3030
+ if u is None: # finished a moment ago: orch saves it after a short wait
3031
+ u = token_live(st, a["agent"], r["kind"], a["tok_marker"], a.get("start", 0), a.get("end", t_now))
3032
+ if u is None:
3033
+ if t_now - a.get("end", t_now) < TOKEN_GIVE_UP_S:
3034
+ continue
3035
+ u = {"na": f"no {r['kind']} log has this job's prompt"}
3036
+ add(r, u if isinstance(u, dict) else {"na": "not read"})
3037
+ w = t.get("wait") or {}
3038
+ if w.get("agent") and w.get("prompt") and t.get("status") in ACTIVE:
3039
+ r = row(w["agent"], "reviewer" if w.get("kind") == "reviewer" else "coder", agent_kind_of(st, w["agent"]))
3040
+ u = token_live(st, w["agent"], r["kind"], token_marker(w["prompt"]), w.get("started", w.get("since", 0)))
3041
+ r["task"], r["now"] = tid, u or {"in": 0, "cached": 0, "out": 0}
3042
+ if u:
3043
+ add(r, u)
3044
+ return list(rows.values())
3045
+
3046
+
3047
+ def agent_steps(st):
3048
+ """For each coder on a milestone now: the milestone's role and the skills the plan gave it, each with a note when
3049
+ the coder's tool can't see that skill's folder. {agent: {"task", "role", "skills": [{"name", "note"}]}}"""
3050
+ busy = {}
3051
+ for n, w in st.get("workers", {}).items():
3052
+ if w.get("task"):
3053
+ busy[n] = (w["task"], w.get("kind"))
3054
+ if not busy:
3055
+ return {}
3056
+ try:
3057
+ secs, _ = plan_sections()
3058
+ except OSError:
3059
+ secs = {}
3060
+ reg = registry(required=False) or {}
3061
+ try:
3062
+ skills = project_skills(ROOT, reg)
3063
+ except OSError:
3064
+ skills = []
3065
+ names = {s["name"] for s in skills}
3066
+ out = {}
3067
+ for n, (tid, kind) in busy.items():
3068
+ t = st["tasks"].get(tid) or {}
3069
+ want = plan_skills(secs[tid]) if tid in secs else []
3070
+ v = reg.get(kind) if kind else None
3071
+ sees = ({s["name"] for s in agent_project_view(ROOT, kind, v, skills)["skills"]}
3072
+ if v and v.get("project_skills_reads") else None)
3073
+ out[n] = {"task": tid, "role": t.get("role") or "",
3074
+ "skills": [{"name": w_, "note": "not in this repo" if w_ not in names else
3075
+ f"{kind} can't see its folder" if sees is not None and w_ not in sees else ""}
3076
+ for w_ in want]}
3077
+ return out
3078
+
3079
+
2915
3080
  def finding_axis(f):
2916
3081
  """Which of the reviewer's two questions a finding answers: "spec" (built what was asked?) or "rules" (follows
2917
3082
  the repo's written rules?); None for a review written before 6.6.0 that does not say."""
@@ -9600,6 +9765,18 @@ def view_model(st=None, recent=40):
9600
9765
  agents.append({"name": st["reviewer"], "role": "reviewer", "kind": ri.get("kind"), "model": ri.get("model"),
9601
9766
  "tier": ri.get("tier"), "task": busy, "state": "reviewing" if busy else
9602
9767
  "compacting" if ri.get("compacting") else "free"})
9768
+ try:
9769
+ steps = agent_steps(st)
9770
+ except Exception: # a broken plan or registry never stops the board
9771
+ steps = {}
9772
+ for a in agents:
9773
+ sp = steps.get(a["name"])
9774
+ if sp and sp["task"] == a.get("task"):
9775
+ a["step_role"], a["skills"] = sp["role"], sp["skills"]
9776
+ try:
9777
+ atok = agent_tokens(st)
9778
+ except Exception:
9779
+ atok = []
9603
9780
  groups = [m["group"] for m in ms]
9604
9781
  run = st.get("run") or {}
9605
9782
  return {
@@ -9620,7 +9797,7 @@ def view_model(st=None, recent=40):
9620
9797
  "cached": tacct["lead"]["cached"], "out": tacct["lead"]["out"]}},
9621
9798
  "usage": {"total": _usage_sum([u for v in by_model.values() for u in v]),
9622
9799
  "by_model": {k: _usage_sum(v) for k, v in by_model.items()}},
9623
- "milestones": ms, "agents": agents,
9800
+ "milestones": ms, "agents": agents, "agent_tokens": atok,
9624
9801
  "lead": ({"name": st["lead"]["name"], "unread": len(unread_events(st)),
9625
9802
  "open": len([e for e in st.get("lead_events", []) if event_open(st, e)])} if st.get("lead") else None),
9626
9803
  "recent": view_events(recent)[::-1],
@@ -9726,13 +9903,15 @@ def serve_view(port, lan, token, opened):
9726
9903
  self.send_header("Content-Type", "text/event-stream")
9727
9904
  self.send_header("Cache-Control", "no-store")
9728
9905
  self.end_headers()
9729
- last, beat = None, time.time()
9906
+ last, beat, running = None, time.time(), False
9730
9907
  try:
9731
9908
  while True:
9732
9909
  k = _view_snapshot_key()
9733
- if k != last:
9910
+ if k != last or running and time.time() - beat > 10: # live tokens: again every 10s
9734
9911
  last = k
9735
- self.wfile.write(f"event: state\ndata: {json.dumps(view_model())}\n\n".encode())
9912
+ vm_ = view_model()
9913
+ running = any(r.get("task") for r in vm_.get("agent_tokens") or [])
9914
+ self.wfile.write(f"event: state\ndata: {json.dumps(vm_)}\n\n".encode())
9736
9915
  self.wfile.flush()
9737
9916
  beat = time.time()
9738
9917
  elif time.time() - beat > 15:
@@ -10530,7 +10709,11 @@ def render_board(vm, width=100, color=True, sel=None, note=""):
10530
10709
  + (" · " + c("r", f"{cn['needs_you']} needs you") if cn["needs_you"] else "")
10531
10710
  + c("d", f" · {_fmt_min(vm['time']['driven_s'])} so far"
10532
10711
  + (f" of ~{_fmt_min(vm['time']['estimate_s'])}" if vm["time"].get("estimate_s") else ""))]
10533
- tk = vm.get("tokens") or {}
10712
+ tk = dict(vm.get("tokens") or {})
10713
+ at = vm.get("agent_tokens") or []
10714
+ if any(r["known"] for r in at): # the live count: finished jobs and the jobs running now
10715
+ tk["total"] = sum(r["in"] + r["out"] for r in at)
10716
+ tk["partial"] = any(r["na"] for r in at)
10534
10717
  if tk.get("total") or tk.get("lead"):
10535
10718
  ld = tk.get("lead") or {}
10536
10719
  out.append(c("d", f"tokens {_tk(tk.get('total'))}{'+' if tk.get('partial') else ''} so far"
@@ -10541,6 +10724,7 @@ def render_board(vm, width=100, color=True, sel=None, note=""):
10541
10724
  out += notes
10542
10725
  out += ["", c("d", "MILESTONES")]
10543
10726
  ms = {m["id"]: m for m in vm["milestones"]}
10727
+ live_now = {r["task"]: r.get("now") for r in at if r.get("task")}
10544
10728
  rows = board_rows(vm)
10545
10729
  picked = rows[sel] if sel is not None and sel < len(rows) else None
10546
10730
  name_w = max(18, min(34, width - 52))
@@ -10555,6 +10739,9 @@ def render_board(vm, width=100, color=True, sel=None, note=""):
10555
10739
  if mt:
10556
10740
  extra += (" " if extra else "") + (f"{_tk(mt['total'])}{'+' if mt['partial'] else ''} tok"
10557
10741
  if mt["total"] else "tokens n/a")
10742
+ nw = live_now.get(m["id"])
10743
+ if nw and "na" not in nw:
10744
+ extra += (" " if extra else "") + f"+{_tk(nw['in'] + nw['out'])} now"
10558
10745
  if g == "waiting" and m["deps"]:
10559
10746
  word = "waits for " + ",".join(d for d in m["deps"] if ms.get(d, {}).get("group") != "landed") \
10560
10747
  if any(ms.get(d, {}).get("group") != "landed" for d in m["deps"]) else "ready"
@@ -10578,16 +10765,62 @@ def render_board(vm, width=100, color=True, sel=None, note=""):
10578
10765
  out.append(f"{mark}{c(col, '◆' if a['role'] == 'lead' else '●' if busy else '○')} "
10579
10766
  f"{a['name']:<12} {str(a.get('kind') or ''):<8} {str(a.get('tier') or ''):<7} "
10580
10767
  + c(col if busy else "d", (f"{a['task']} · " if a.get("task") else "") + a["state"]))
10768
+ if a.get("step_role") or a.get("skills"):
10769
+ sk = ", ".join(x["name"] + (f" ({x['note']})" if x.get("note") else "") for x in a.get("skills") or [])
10770
+ if a.get("step_role"):
10771
+ out.append(c("d", " role: ") + cut(a["step_role"], width - 11))
10772
+ out.append(c("d", " skills: ") + (cut(sk, width - 13) if sk else c("d", "none for this step")))
10773
+ if at:
10774
+ out += ["", c("d", "TOKENS") + c("d", " read live from each agent's own log"),
10775
+ c("d", f" {'':<12} {'':<8} {'in':>7} {'cached':>8} {'out':>7}")]
10776
+ for r in at:
10777
+ col = "a" if r["role"] == "lead" else "p" if r["role"] == "reviewer" else "b"
10778
+ mark = c(col, "◆" if r["role"] == "lead" else "●" if r.get("task") else "○")
10779
+ head = f"{mark} {r['name']:<12} {str(r.get('kind') or ''):<8} "
10780
+ if r.get("kind") and r["kind"] not in TOKEN_KINDS:
10781
+ out.append(head + c("d", f"n/a: orch can't read {r['kind']}'s logs yet"))
10782
+ continue
10783
+ if not r["known"] and r["na"]:
10784
+ out.append(head + c("d", cut(f"n/a: {r['na'][0]}", width - 25)))
10785
+ continue
10786
+ if not r["known"] and not r.get("task"):
10787
+ out.append(head + c("d", "no jobs yet"))
10788
+ continue
10789
+ tnote = []
10790
+ if r.get("task"):
10791
+ nw = r.get("now") or {}
10792
+ tnote.append(f"{r['task']} now {_tk(nw.get('in', 0) + nw.get('out', 0))}" if "na" not in nw else
10793
+ f"{r['task']} now n/a")
10794
+ if r["na"]:
10795
+ tnote.append(f"+ {len(r['na'])} job(s) n/a")
10796
+ out.append(head + f"{_tk(r['in']):>7} {_tk(r['cached']):>8} {_tk(r['out']):>7}"
10797
+ + (c("d", " " + " · ".join(tnote)) if tnote else ""))
10798
+ tot_in, tot_out = sum(r["in"] for r in at), sum(r["out"] for r in at)
10799
+ out.append(c("B", f" {'total':<21} {_tk(tot_in):>7} {_tk(sum(r['cached'] for r in at)):>8} {_tk(tot_out):>7}")
10800
+ + (c("d", " + some jobs n/a") if any(r["na"] for r in at) else ""))
10581
10801
  if vm.get("recent"):
10582
10802
  out += ["", c("d", "LAST EVENTS")]
10583
10803
  for e in vm["recent"][:6]:
10584
10804
  out.append(c("d", time.strftime("%H:%M", time.localtime(e["ts"] or 0))) + f" {e['task']} {e['from']} → {e['to']}"
10585
10805
  + (c("d", f" {cut(e.get('why') or '', 50)}") if e.get("why") else ""))
10586
- if note:
10587
- out += ["", c("a", note)]
10588
- out += ["", c("d", "[↑↓] pick [enter] a milestone's changed files / jump to an agent [f] changed files "
10589
- "[w] web view [q] close")]
10590
- return out
10806
+ foot = (["", c("a", note)] if note else []) + ["", c("d", "[↑↓] pick [enter] a milestone's changed files / jump "
10807
+ "to an agent [f] changed files [w] web view [q] close")]
10808
+ return BoardLines(out + foot, foot=len(foot))
10809
+
10810
+
10811
+ class BoardLines(list):
10812
+ """The board's lines; `foot` = how many at the end (the note and the keys) must stay on a short screen."""
10813
+ def __init__(self, lines, foot=0):
10814
+ super().__init__(lines)
10815
+ self.foot = foot
10816
+
10817
+
10818
+ def fit_screen(lines, height):
10819
+ """The lines that fit the screen: on a short one the middle is cut, never the note and the keys at the end."""
10820
+ foot = getattr(lines, "foot", 0)
10821
+ if len(lines) <= height or not foot or height <= foot + 2:
10822
+ return list(lines[:height])
10823
+ return list(lines[:height - foot - 1]) + ["…"] + list(lines[-foot:])
10591
10824
 
10592
10825
 
10593
10826
  def board_tree(vm):
@@ -10850,7 +11083,8 @@ def cmd_board(args):
10850
11083
  while True:
10851
11084
  k = _view_snapshot_key()
10852
11085
  live = screen != "run" and ch is not None and ch["kind"] == "live"
10853
- if k != last or time.time() - fetched > (2 if live else 30): # a coder's unsaved files: look every 2s
11086
+ running = any(r.get("task") for r in vm.get("agent_tokens") or []) # live tokens: look every 10s
11087
+ if k != last or time.time() - fetched > (2 if live else 10 if running else 30): # unsaved files: 2s
10854
11088
  last, need = k, True
10855
11089
  if need or redraw:
10856
11090
  size = shutil.get_terminal_size((100, 40))
@@ -10876,7 +11110,7 @@ def cmd_board(args):
10876
11110
  need = redraw = False
10877
11111
  lines = board_error_lines(e, "this run" if screen == "run" else f"{mid}'s changes",
10878
11112
  "[q] close" if screen == "run" else "[q] back")
10879
- sys.stdout.write("\x1b[H\x1b[2J" + "\n".join(lines[:size.lines]))
11113
+ sys.stdout.write("\x1b[H\x1b[2J" + "\n".join(fit_screen(lines, size.lines)))
10880
11114
  sys.stdout.flush()
10881
11115
  r, _, _ = select.select([sys.stdin], [], [], 0.5)
10882
11116
  if not r:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-orchestra",
3
- "version": "6.48.0",
3
+ "version": "6.48.1",
4
4
  "description": "Orchestrate AI coding agents (Claude Code, Codex, OpenCode, Amp, Pi) as one team: a lead plans, coders build, a reviewer checks, you get one PR. Runs in Herdr panes, or in one Pi window with subagents.",
5
5
  "license": "MIT",
6
6
  "bin": {
package/view/index.html CHANGED
@@ -255,7 +255,8 @@ function agents(v) {
255
255
  const col = a.role === "lead" ? "#e5a93b" : !a.task ? "#626979" : a.role === "reviewer" ? "#b392f0" : "#7aa2f7";
256
256
  return `<div class="ag"><i class="dot" style="background:${col}"></i><span class="n">${esc(a.name)}</span>
257
257
  <span class="w" style="color:${col}">${esc(a.task ? a.task + " · " + a.state : a.state)}</span>
258
- <span class="k">${esc([a.role, a.kind, a.model, a.tier].filter(Boolean).join(" · "))}</span></div>`;
258
+ <span class="k">${esc([a.role, a.kind, a.model, a.tier].filter(Boolean).join(" · "))}</span>${a.step_role || a.skills ? `
259
+ <span class="k">${esc([a.step_role ? "role: " + a.step_role : "", "skills: " + ((a.skills || []).map((x) => x.name + (x.note ? " (" + x.note + ")" : "")).join(", ") || "none for this step")].filter(Boolean).join(" · "))}</span>` : ""}</div>`;
259
260
  }).join("") || `<div class="muted">No agents in this run.</div>`;
260
261
  }
261
262
 
@@ -351,9 +352,13 @@ function cost(v) {
351
352
  }).join("");
352
353
  const T = v.tokens || {}, L = T.lead;
353
354
  const lead = L ? `<tr><td class="muted">lead (whole run)</td><td>${L.total != null ? tk(L.total) + " tok" : "tokens n/a (" + esc(L.na) + ")"}</td></tr>` : "";
355
+ const AT = v.agent_tokens || [], readable = ["claude", "codex", "pi", "agy"];
356
+ const arow = (r) => `<tr><td class="muted" style="white-space:nowrap">${esc(r.name)} <span class="faint">${esc(r.role)}</span></td><td>${r.kind && !readable.includes(r.kind) ? "n/a (orch can't read " + esc(r.kind) + "'s logs yet)" : !r.known && r.na.length ? "n/a (" + esc(r.na[0]) + ")" : !r.known && !r.task ? "no jobs yet" : "in " + tk(r.in) + " (" + tk(r.cached) + " cached) · out " + tk(r.out) + (r.task && r.now && r.now.na == null ? " · " + esc(r.task) + " now " + tk(r.now.in + r.now.out) : "") + (r.na.length ? " · " + r.na.length + " job(s) n/a" : "")}</td></tr>`;
357
+ const liveTot = AT.some((r) => r.known) ? AT.reduce((n, r) => n + r.in + r.out, 0) : 0; // running jobs included
358
+ const agTok = AT.length ? `<div class="h" style="margin:10px 0 4px">Tokens per agent (live)</div><table>${AT.map(arow).join("")}</table>` : "";
354
359
  $("cost").innerHTML = `<div class="card"><div class="h" style="margin-bottom:6px">Time and tokens</div>
355
360
  <div style="margin-bottom:8px">${mins(so)} so far${est ? ` of ~${mins(est)} planned` : ""}</div>
356
- <table>${rows}${lead}<tr><td><b>Total tokens</b></td><td><b>${T.total ? tk(T.total) + (T.partial ? "+" : "") : "none yet"}</b></td></tr></table>
361
+ <table>${rows}${lead}<tr><td><b>Total tokens</b></td><td><b>${liveTot ? tk(liveTot) + (AT.some((r) => r.na.length) ? "+" : "") : T.total ? tk(T.total) + (T.partial ? "+" : "") : "none yet"}</b></td></tr></table>${agTok}
357
362
  <div class="faint" style="font-size:11px;margin-top:6px">Read from each agent's own log. In = what it read (cached = its own chat read again, much cheaper), out = what it wrote. + = some jobs not available.</div></div>`;
358
363
  }
359
364