herdr-orchestra 6.48.3 → 6.48.4

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,20 @@
2
2
 
3
3
  All notable changes. Versions follow [semantic versioning](https://semver.org).
4
4
 
5
+ ## [6.48.4] - 2026-12-03
6
+
7
+ The board's Tokens tab has a new **fresh** column: in minus cached, the part the agent read new. A coder can show "10.8M in" and look very costly, but most of that is its own chat read again from the cache, which costs much less. Fresh shows the part that really costs. It is in each agent's row, the total row, the top line (`tokens 257k so far · fresh 57k`), the agent details (total, now and each milestone) and the browser view's tokens per agent. The numbers are the ones the board already reads from each agent's own log, so no agent spends a single extra token. A tool whose log gives no cached number shows fresh as "n/a", and the total fresh then reads "at least" (`57k+`).
8
+
9
+ Example (Tokens tab):
10
+ ```
11
+ in cached fresh out
12
+ ◆ lead-1 (lead) codex 50k 30k 20k 4k
13
+ ○ claude-1 (coder) claude 36k 32k 4k 3k
14
+ ○ agy-3 (coder) agy 4k 0 n/a 300
15
+ total 90k 62k 24k+ 7k
16
+ fresh = in minus cached: what the agent read new. Cached is its own chat read again, much cheaper.
17
+ ```
18
+
5
19
  ## [6.48.3] - 2026-12-02
6
20
 
7
21
  `orch board` can now show one agent in detail. On the Agents tab or the Tokens tab, pick an agent with up/down and press Enter. You see its tool, model, role, skills and what it does right now; its tokens (in, cached, out) in total, for the job it runs now, and for each milestone it worked on; its milestones with the time it spent on each; and its pane. Esc or Backspace goes back to the list. The numbers come from the same agent logs the board already reads, so no agent spends a single extra token. Where a tool keeps no counts (OpenCode, an old agy), it says "n/a" and why, never a guess.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 6.48.3
1
+ 6.48.4
Binary file
package/bin/orch CHANGED
@@ -2652,6 +2652,16 @@ def token_log_find(kind, marker, since, known=()):
2652
2652
  return None
2653
2653
 
2654
2654
 
2655
+ def _nc(u):
2656
+ return {"nocache": True} if u.get("nocache") else {}
2657
+
2658
+
2659
+ def _fresh(u):
2660
+ """Fresh = in minus cached: what the agent read new (the cached part is its own chat read again, much cheaper).
2661
+ None when the tool's log gives no cached number."""
2662
+ return None if u.get("nocache") else max(0, int(u.get("in") or 0) - int(u.get("cached") or 0))
2663
+
2664
+
2655
2665
  def _tok_add(acc, ts, start, end, inp, cached, out):
2656
2666
  if ts is None or ts < start or ts > end:
2657
2667
  return
@@ -2666,7 +2676,7 @@ def token_window(kind, path, start, end):
2666
2676
  Raises TokenNA when the log has no token counts at all."""
2667
2677
  acc = {"in": 0, "cached": 0, "out": 0, "replies": 0}
2668
2678
  text = _tok_text(path)
2669
- seen_counts = False
2679
+ seen_counts = seen_cache = False
2670
2680
  if kind == "claude":
2671
2681
  files = [text] + [_tok_text(s) for s in sorted((Path(path).with_suffix("") / "subagents").glob("*.jsonl"))]
2672
2682
  for tx in files:
@@ -2677,6 +2687,7 @@ def token_window(kind, path, start, end):
2677
2687
  if d.get("type") != "assistant" or not isinstance(u, dict):
2678
2688
  continue
2679
2689
  seen_counts = True
2690
+ seen_cache |= "cache_read_input_tokens" in u
2680
2691
  key = (m.get("id"), d.get("requestId")) if m.get("id") else d.get("uuid") or id(d)
2681
2692
  ts = _tok_ts(d.get("timestamp"))
2682
2693
  row = (int(u.get("input_tokens") or 0) + int(u.get("cache_creation_input_tokens") or 0)
@@ -2696,6 +2707,7 @@ def token_window(kind, path, start, end):
2696
2707
  if not isinstance(tot, dict):
2697
2708
  continue
2698
2709
  seen_counts = True
2710
+ seen_cache |= "cached_input_tokens" in tot
2699
2711
  ts = _tok_ts(d.get("timestamp"))
2700
2712
  if ts is None:
2701
2713
  continue
@@ -2719,6 +2731,7 @@ def token_window(kind, path, start, end):
2719
2731
  if not isinstance(u, dict) or d.get("type") == "message" and m.get("role") != "assistant":
2720
2732
  continue
2721
2733
  seen_counts = True
2734
+ seen_cache |= "cacheRead" in u
2722
2735
  _tok_add(acc, _tok_ts(d.get("timestamp")) or _tok_ts(m.get("timestamp")), start, end,
2723
2736
  int(u.get("input") or 0) + int(u.get("cacheRead") or 0) + int(u.get("cacheWrite") or 0),
2724
2737
  u.get("cacheRead"), u.get("output"))
@@ -2730,6 +2743,7 @@ def token_window(kind, path, start, end):
2730
2743
  if not any(k in d for k in ("input_tokens", "output_tokens")):
2731
2744
  continue
2732
2745
  seen_counts = True
2746
+ seen_cache |= "cache_read_tokens" in d
2733
2747
  _tok_add(acc, _tok_ts(d.get("created_at")), start, end,
2734
2748
  int(d.get("input_tokens") or 0) + int(d.get("cache_read_tokens") or 0),
2735
2749
  d.get("cache_read_tokens"), d.get("output_tokens"))
@@ -2739,6 +2753,8 @@ def token_window(kind, path, start, end):
2739
2753
  raise TokenNA(f"orch can't read {kind}'s logs")
2740
2754
  if not seen_counts:
2741
2755
  raise TokenNA(f"{kind}'s log has no token counts")
2756
+ if not seen_cache:
2757
+ acc["nocache"] = True # the log gives no cached number: "fresh" (in minus cached) shows n/a
2742
2758
  return acc
2743
2759
 
2744
2760
 
@@ -2779,7 +2795,7 @@ def token_measure(st, agent, kind, marker, start, end, cap=None):
2779
2795
  logs[agent] = (known + [path])[-6:]
2780
2796
  if not acc["replies"]:
2781
2797
  return None if now() - end < TOKEN_GIVE_UP_S else {"na": "no replies in the log during this job"}
2782
- return {"in": acc["in"], "cached": acc["cached"], "out": acc["out"], "log": kind}
2798
+ return {"in": acc["in"], "cached": acc["cached"], "out": acc["out"], "log": kind, **_nc(acc)}
2783
2799
 
2784
2800
 
2785
2801
  def token_fill(st, force=False):
@@ -2878,6 +2894,7 @@ def _tok_merge(rows):
2878
2894
  acc["na"].append((u or {}).get("na") if isinstance(u, dict) else "not read yet")
2879
2895
  continue
2880
2896
  acc["known"] += 1
2897
+ acc.update(_nc(u))
2881
2898
  for k in ("in", "cached", "out"):
2882
2899
  acc[k] += int(u.get(k) or 0)
2883
2900
  return acc
@@ -2942,6 +2959,11 @@ def _tk(n):
2942
2959
  return f"{n / 1e6:.1f}M" if n >= 1_000_000 else f"{round(n / 1000)}k" if n >= 1000 else str(n)
2943
2960
 
2944
2961
 
2962
+ def _tkf(u):
2963
+ f = _fresh(u)
2964
+ return "n/a" if f is None else _tk(f)
2965
+
2966
+
2945
2967
  def _tok_cell(u, who=""):
2946
2968
  if not u:
2947
2969
  return "-"
@@ -3021,7 +3043,7 @@ def token_live(st, agent, kind, marker, start, end=None):
3021
3043
  return hit[1]
3022
3044
  try:
3023
3045
  acc = token_window(kind, path, start, end + 1 if end else float("inf"))
3024
- r = {"in": acc["in"], "cached": acc["cached"], "out": acc["out"]} if acc["replies"] else None
3046
+ r = {"in": acc["in"], "cached": acc["cached"], "out": acc["out"], **_nc(acc)} if acc["replies"] else None
3025
3047
  except TokenNA as e:
3026
3048
  r = {"na": str(e)}
3027
3049
  _LIVE_WIN[key] = (sig, r)
@@ -3050,6 +3072,7 @@ def agent_tokens(st):
3050
3072
  x["na"].append(u["na"])
3051
3073
  continue
3052
3074
  x["known"] += 1
3075
+ x.update(_nc(u))
3053
3076
  for k in ("in", "cached", "out"):
3054
3077
  x[k] += int(u.get(k) or 0)
3055
3078
  ld, run = st.get("lead") or {}, st.get("run") or {}
@@ -10784,7 +10807,11 @@ def render_board(vm, width=100, color=True, sel=None, note="", tab=None):
10784
10807
  tk["partial"] = any(r["na"] for r in at)
10785
10808
  if tk.get("total") or tk.get("lead"):
10786
10809
  ld = tk.get("lead") or {}
10787
- out.append(c("d", f"tokens {_tk(tk.get('total'))}{'+' if tk.get('partial') else ''} so far"
10810
+ kn = [r for r in at if r["known"]]
10811
+ fr = ("" if not kn else " · fresh n/a" if all(r.get("nocache") for r in kn) else
10812
+ f" · fresh {_tk(sum(_fresh(r) or 0 for r in kn))}"
10813
+ f"{'+' if tk.get('partial') or any(r.get('nocache') for r in kn) else ''}")
10814
+ out.append(c("d", f"tokens {_tk(tk.get('total'))}{'+' if tk.get('partial') else ''} so far{fr}"
10788
10815
  + (f" · lead {_tk(ld['total'])}" if ld.get("total") else
10789
10816
  " · lead: not available" if ld.get("na") else "")))
10790
10817
  if vm.get("all_done"):
@@ -10850,7 +10877,7 @@ def render_board(vm, width=100, color=True, sel=None, note="", tab=None):
10850
10877
  pk = " " if tab == "t" and sel is not None else "" # picking a row: a column for the › mark
10851
10878
  out.extend(([c("d", "TOKENS") + c("d", " read live from each agent's own log")] if tab is None else
10852
10879
  [c("d", "read live from each agent's own log")])
10853
- + [c("d", f"{pk} {'':<{nw_}} {'':<8} {'in':>7} {'cached':>8} {'out':>7}")])
10880
+ + [c("d", f"{pk} {'':<{nw_}} {'':<8} {'in':>7} {'cached':>8} {'fresh':>7} {'out':>7}")])
10854
10881
  for i, r in enumerate(at):
10855
10882
  col = "a" if r["role"] == "lead" else "p" if r["role"] == "reviewer" else "b"
10856
10883
  mark = (("›" if picked == ("t", i) else " ") if pk else "") \
@@ -10872,12 +10899,17 @@ def render_board(vm, width=100, color=True, sel=None, note="", tab=None):
10872
10899
  f"{r['task']} now n/a")
10873
10900
  if r["na"]:
10874
10901
  tnote.append(f"+ {len(r['na'])} job(s) n/a")
10875
- out.append(head + f"{_tk(r['in']):>7} {_tk(r['cached']):>8} {_tk(r['out']):>7}"
10902
+ out.append(head + f"{_tk(r['in']):>7} {_tk(r['cached']):>8} {_tkf(r):>7} {_tk(r['out']):>7}"
10876
10903
  + (c("d", " " + " · ".join(tnote)) if tnote else ""))
10877
10904
  tot_in, tot_out = sum(r["in"] for r in at), sum(r["out"] for r in at)
10878
- out.append(c("B", f"{pk} {'total':<{nw_ + 9}} {_tk(tot_in):>7} {_tk(sum(r['cached'] for r in at)):>8} {_tk(tot_out):>7}")
10905
+ kn = [r for r in at if r["known"]]
10906
+ tfr = "n/a" if kn and all(r.get("nocache") for r in kn) else \
10907
+ _tk(sum(_fresh(r) or 0 for r in kn)) + ("+" if any(r.get("nocache") for r in kn) else "")
10908
+ out.append(c("B", f"{pk} {'total':<{nw_ + 9}} {_tk(tot_in):>7} {_tk(sum(r['cached'] for r in at)):>8} {tfr:>7} {_tk(tot_out):>7}")
10879
10909
  + (c("d", " + some jobs n/a") if any(r["na"] for r in at) else ""))
10880
10910
  if tab == "t":
10911
+ out.append(c("d", "fresh = in minus cached: what the agent read new. Cached is its own chat read again, "
10912
+ "much cheaper."))
10881
10913
  per = [f"{m['id']} " + (f"{_tk(m['tokens']['total'])}{'+' if m['tokens']['partial'] else ''}"
10882
10914
  if m.get("tokens") and m["tokens"]["total"] else "–") for m in vm["milestones"]]
10883
10915
  if per:
@@ -11014,8 +11046,8 @@ def render_agent(vm, name, width=100, color=True, note=""):
11014
11046
  rows.append(("pane", (a.get("label") or name) + (f" (herdr pane {a['pane']})" if a.get("pane") else "")))
11015
11047
  out += [c("d", f" {k + ':':<11}") + cut(str(v), width - 14) for k, v in rows]
11016
11048
 
11017
- out += ["", c("d", "TOKENS") + c("d", " read live from its own log")]
11018
- nums = lambda u: f"{_tk(u['in']):>7} {_tk(u['cached']):>8} {_tk(u['out']):>7}"
11049
+ out += ["", c("d", "TOKENS") + c("d", " read live from its own log · fresh = in minus cached (read new)")]
11050
+ nums = lambda u: f"{_tk(u['in']):>7} {_tk(u['cached']):>8} {_tkf(u):>7} {_tk(u['out']):>7}"
11019
11051
  if not kind:
11020
11052
  out.append(" n/a: orch does not know which tool this agent runs")
11021
11053
  elif kind not in TOKEN_KINDS:
@@ -11023,7 +11055,7 @@ def render_agent(vm, name, width=100, color=True, note=""):
11023
11055
  elif not r or (not r["jobs"] and not r.get("task")):
11024
11056
  out.append(c("d", " no jobs yet"))
11025
11057
  else:
11026
- out.append(c("d", f" {'':<16} {'in':>7} {'cached':>8} {'out':>7}"))
11058
+ out.append(c("d", f" {'':<16} {'in':>7} {'cached':>8} {'fresh':>7} {'out':>7}"))
11027
11059
  tot = "whole run" if role == "lead" else "total"
11028
11060
  out.append(f" {tot:<16} " + (nums(r) if r["known"] else c("d", cut(f"n/a: {r['na'][0]}", width - 20)) if r["na"]
11029
11061
  else nums(r)) + (c("d", f" + {len(r['na'])} job(s) n/a") if r["known"] and r["na"] else ""))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-orchestra",
3
- "version": "6.48.3",
3
+ "version": "6.48.4",
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
@@ -353,13 +353,13 @@ function cost(v) {
353
353
  const T = v.tokens || {}, L = T.lead;
354
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
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>`;
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, " + (r.nocache ? "n/a" : tk(r.in - r.cached)) + " fresh) · 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
357
  const liveTot = AT.some((r) => r.known) ? AT.reduce((n, r) => n + r.in + r.out, 0) : 0; // running jobs included
358
358
  const agTok = AT.length ? `<div class="h" style="margin:10px 0 4px">Tokens per agent (live)</div><table>${AT.map(arow).join("")}</table>` : "";
359
359
  $("cost").innerHTML = `<div class="card"><div class="h" style="margin-bottom:6px">Time and tokens</div>
360
360
  <div style="margin-bottom:8px">${mins(so)} so far${est ? ` of ~${mins(est)} planned` : ""}</div>
361
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}
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>`;
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; fresh = in minus cached, what it read new), out = what it wrote. + = some jobs not available.</div></div>`;
363
363
  }
364
364
 
365
365
  function timeline(v) {