tryharness 0.7.72 → 0.7.75

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.
Files changed (51) hide show
  1. package/assets/opencode-plugin.js +70 -3
  2. package/assets/pi-extension.ts +7 -1
  3. package/cli.mjs +2 -2
  4. package/lib/asks.mjs +2 -0
  5. package/lib/boardCommands.mjs +9 -1
  6. package/lib/boardProtocol.json +23 -19
  7. package/lib/bridge.mjs +2 -0
  8. package/lib/capabilityCheck.mjs +86 -0
  9. package/lib/computerAddress.mjs +6 -14
  10. package/lib/coordinator.mjs +220 -35
  11. package/lib/daemon.mjs +160 -126
  12. package/lib/dispatchContract.json +1 -31
  13. package/lib/dispatchTools.js +8 -39
  14. package/lib/dispatches.mjs +27 -285
  15. package/lib/goalCommands.mjs +7 -3
  16. package/lib/herdr.mjs +159 -0
  17. package/lib/hookDialects.mjs +36 -2
  18. package/lib/jobAnswers.mjs +3 -0
  19. package/lib/kanban.mjs +256 -0
  20. package/lib/library.mjs +83 -7
  21. package/lib/localAgentAsk.mjs +20 -29
  22. package/lib/localStack.mjs +19 -3
  23. package/lib/machineRoutes.mjs +1 -5
  24. package/lib/manager.mjs +254 -0
  25. package/lib/mcp-stdio.mjs +72 -46
  26. package/lib/moves.mjs +365 -0
  27. package/lib/nudge.mjs +18 -3
  28. package/lib/ownMachines.mjs +43 -6
  29. package/lib/places.mjs +29 -2
  30. package/lib/runAuthority.mjs +2 -14
  31. package/lib/runBrief.mjs +14 -1
  32. package/lib/runWorker.mjs +4 -10
  33. package/lib/runner.mjs +1 -49
  34. package/lib/sessionControl.mjs +65 -1
  35. package/lib/steerHook.mjs +124 -0
  36. package/lib/steerQueue.mjs +176 -0
  37. package/lib/store.mjs +20 -29
  38. package/lib/subagentSteering.mjs +363 -0
  39. package/lib/subagents.mjs +138 -29
  40. package/lib/swarm.mjs +16 -6
  41. package/lib/taskCommands.mjs +0 -62
  42. package/lib/threadActions.mjs +4 -2
  43. package/lib/threadBriefs.mjs +9 -3
  44. package/lib/threadRuns.mjs +13 -0
  45. package/npm-shrinkwrap.json +14 -14
  46. package/package.json +4 -4
  47. package/release.json +48 -44
  48. package/lib/comfyExecution.mjs +0 -545
  49. package/lib/promptDecider.mjs +0 -471
  50. package/lib/promptFlow.mjs +0 -597
  51. package/lib/promptScopes.mjs +0 -670
package/lib/runner.mjs CHANGED
@@ -22,9 +22,8 @@ const issueCapability = (task) => {
22
22
  capabilities.set(token, {
23
23
  id: task.runId,
24
24
  agent: task.agent,
25
- restricted: task.restricted === true || Boolean(task.dispatchScope),
25
+ restricted: task.restricted === true,
26
26
  review: task.readOnly === true,
27
- dispatchScope: task.dispatchScope ?? null,
28
27
  // Work another person asked for (runWorker.mjs ownSettingsOnly), and the folder it works in: such a run reaches
29
28
  // none of the person's private things beyond that folder (runAuthority.mjs privateReach).
30
29
  forAnotherPerson: task.ownSettingsOnly === true,
@@ -492,53 +491,6 @@ const codexReview = (task, executable, home = os.homedir(), write = false) => {
492
491
  export const READ_ONLY_AGENTS = new Set(["claude-code", "codex"]);
493
492
 
494
493
  export function agentInvocation(task, { executable = null } = {}) {
495
- if (task.dispatchScope) {
496
- if (task.agent !== "claude-code")
497
- throw new Error(
498
- "No mediated workspace executor is registered for this agent"
499
- );
500
- const mcp = {
501
- mcpServers: {
502
- harness: {
503
- command: process.execPath,
504
- args: [
505
- fileURLToPath(new URL("./mcp-stdio.mjs", import.meta.url)),
506
- "--agent",
507
- "claude-code",
508
- "--restricted",
509
- "--scope",
510
- task.dispatchScope,
511
- ],
512
- },
513
- },
514
- };
515
- return {
516
- command: "claude",
517
- args: [
518
- "-p",
519
- task.brief,
520
- "--output-format",
521
- "stream-json",
522
- "--verbose",
523
- ...modelFlags(task),
524
- "--tools",
525
- "",
526
- "--bare",
527
- "--restricted",
528
- "--allowedTools",
529
- "mcp__harness__dispatch_work mcp__harness__scope_workspace",
530
- "--permission-mode",
531
- "dontAsk",
532
- "--strict-mcp-config",
533
- "--mcp-config",
534
- JSON.stringify(mcp),
535
- "--setting-sources",
536
- "",
537
- "--settings",
538
- JSON.stringify({ disableAllHooks: true }),
539
- ],
540
- };
541
- }
542
494
  if (task.agent === "claude-code") {
543
495
  return {
544
496
  command: "claude",
@@ -46,6 +46,12 @@ import {
46
46
  terminalSessions,
47
47
  } from "./places.mjs";
48
48
  import { resumeInNeovim, showInNeovim } from "./neovim.mjs";
49
+ import {
50
+ herdrInstalled,
51
+ herdrRunning,
52
+ resumeInHerdr,
53
+ showInHerdr,
54
+ } from "./herdr.mjs";
49
55
  import { detectAgentApps, detectMcpClients } from "./adapters.mjs";
50
56
  import { resolveCommand } from "./commands.mjs";
51
57
  import { handedToT3, sendToT3, t3Access } from "./t3.mjs";
@@ -58,6 +64,8 @@ export function createSessionControl({
58
64
  activeRuns,
59
65
  // Every value in the person's vault out of what a live read shows (vault.mjs).
60
66
  scrub = (value) => value,
67
+ // A running session's subagents (subagentSteering.mjs ofSession).
68
+ subagentsOf = () => [],
61
69
  }) {
62
70
  const saidKey = (agent, sessionId) => `said:${agent}:${sessionId}`;
63
71
  const said = (agent, sessionId) => {
@@ -504,6 +512,7 @@ export function createSessionControl({
504
512
  if (gone && place.kind === "nvim")
505
513
  return { ...place, app: lastResort().app };
506
514
  if (gone && place.kind === "codex-app") return null;
515
+ if (place.kind === "herdr") return herdrInstalled(place) ? place : null;
507
516
  return place;
508
517
  };
509
518
  const homeOf = (agentId) => {
@@ -564,6 +573,26 @@ export function createSessionControl({
564
573
  one.server && all.findIndex((x) => x.server === one.server) === index
565
574
  );
566
575
  };
576
+ /**
577
+ * What the buddy does once herdr shows a pane: the terminal a herdr client is attached in comes forward on its tab; with
578
+ * none attached, the person's terminal opens herdr itself, which shows the pane focused.
579
+ */
580
+ const herdrShown = (agentId, shown) => {
581
+ if (shown.attach)
582
+ return {
583
+ resume: {
584
+ agent: agentId,
585
+ session: null,
586
+ cwd: null,
587
+ app: lastResort().app,
588
+ within: "herdr",
589
+ },
590
+ };
591
+ const forward = focusTerminal(shown);
592
+ return forward.app
593
+ ? forward
594
+ : { note: `It's up in herdr, which runs outside any app here.` };
595
+ };
567
596
  /** Whether one of Harness's runs is still working in this session: it is not resumed beside it. */
568
597
  const runBusy = (sessionId) =>
569
598
  Boolean(sessionId) &&
@@ -683,6 +712,31 @@ export function createSessionControl({
683
712
  ...(fresh ? { note: freshNote(agentId, name) } : {}),
684
713
  };
685
714
  }
715
+ // In a new tab of the person's herdr, on the folder; when that herdr is not running, wherever else it opens.
716
+ if (place.kind === "herdr") {
717
+ if (!CODING_AGENTS.includes(agentId) || !herdrRunning(place)) return null;
718
+ if (busy) return { opensIn: "herdr", note: busy };
719
+ const fresh = startsFresh(agentId, sessionId);
720
+ if (!act)
721
+ return {
722
+ opensIn: "herdr",
723
+ ...(fresh ? { note: freshNote(agentId, "herdr") } : {}),
724
+ };
725
+ const command =
726
+ sessionId && !fresh
727
+ ? resumeLine(agentId, sessionId)
728
+ : agentCommand(agentId);
729
+ const shown = command
730
+ ? resumeInHerdr(place, command, folder, nameOf(agentId))
731
+ : null;
732
+ if (!shown) return null;
733
+ const opened = herdrShown(agentId, shown);
734
+ return {
735
+ opensIn: "herdr",
736
+ ...opened,
737
+ ...(fresh ? { note: freshNote(agentId, "herdr") } : {}),
738
+ };
739
+ }
686
740
  if (place.kind === "terminal") {
687
741
  if (!CODING_AGENTS.includes(agentId)) return null;
688
742
  if (busy)
@@ -706,6 +760,13 @@ export function createSessionControl({
706
760
  /** A running session, where it runs: its T3 thread, its panel, its editor's window, its terminal pane and tab. */
707
761
  const runningPlan = (live, act) => {
708
762
  const place = placesOf(live.agent)[live.sessionId] ?? null;
763
+ // Its pane in herdr, then the terminal herdr is attached in; before the app up its process tree, which is where
764
+ // herdr's server started (T3 Code's terminal, say), not where the session shows.
765
+ if (place?.kind === "herdr") {
766
+ const shown = act ? showInHerdr(place) : null;
767
+ if (shown) return { opensIn: "herdr", ...herdrShown(live.agent, shown) };
768
+ if (!act) return { opensIn: "herdr" };
769
+ }
709
770
  if (
710
771
  (live.host && /^T3 Code\b/.test(live.host.name)) ||
711
772
  place?.kind === "t3"
@@ -1009,7 +1070,10 @@ export function createSessionControl({
1009
1070
  error: "only the person reads or messages their sessions",
1010
1071
  };
1011
1072
  if (request.command === "board.live") {
1012
- const sessions = liveNow();
1073
+ const sessions = liveNow().map((session) => {
1074
+ const subagents = subagentsOf(session);
1075
+ return subagents.length ? { ...session, subagents } : session;
1076
+ });
1013
1077
  return {
1014
1078
  ok: true,
1015
1079
  sessions,
@@ -0,0 +1,124 @@
1
+ import path from "node:path";
2
+ import {
3
+ REDIRECT_HOLD,
4
+ endSteers,
5
+ steerText,
6
+ takeSteers,
7
+ } from "./steerQueue.mjs";
8
+
9
+ // Claude Code's PreToolUse and SubagentStop hooks: what the person told one of its subagents from Harness, given at that
10
+ // subagent's next tool call (steerQueue.mjs). Claude Code names the subagent a hook fires in (agent_id); the session's
11
+ // own model has none. A note reaches the subagent as it finishes; a new brief or a stop holds its calls until it ends its
12
+ // turn, where the new brief reaches it and a stop lets it return what it has.
13
+ // Setup runs this only when a steer waits (the shell guard in hookDialects.mjs), so it starts nothing otherwise.
14
+
15
+ async function readInput() {
16
+ if (process.stdin.isTTY) return null;
17
+ let text = "";
18
+ process.stdin.setEncoding("utf8");
19
+ await Promise.race([
20
+ new Promise((resolve) => {
21
+ process.stdin.on("data", (chunk) => (text += chunk));
22
+ process.stdin.on("end", resolve);
23
+ process.stdin.on("error", resolve);
24
+ }),
25
+ new Promise((resolve) => setTimeout(resolve, 1_000).unref()),
26
+ ]);
27
+ process.stdin.destroy();
28
+ try {
29
+ return JSON.parse(text);
30
+ } catch {
31
+ return null;
32
+ }
33
+ }
34
+
35
+ /** The hook's answer to Claude Code, or null for none. Exported for tests. */
36
+ export function answer(input, home) {
37
+ const session = input?.session_id;
38
+ // The session's own model hears about its subagents as its turn ends (nudge.mjs --stop), where it reads them as the
39
+ // person's.
40
+ if (!session || !input.agent_id) return null;
41
+ const agent = input.agent_id;
42
+ if (input.hook_event_name === "SubagentStop") {
43
+ const left = endSteers(session, agent, { event: "end" }, home);
44
+ return left.length ? { decision: "block", reason: steerText(left) } : null;
45
+ }
46
+ if (input.hook_event_name !== "PreToolUse") return null;
47
+ // Measured live on Claude Code (Haiku and Sonnet, November 1): words given with a tool call, as added context or as
48
+ // the reason it was refused, were read as text a tool returned and set aside, while a refused call stopped the
49
+ // subagent every time; the same words given as it finished (SubagentStop's block) were taken as the person's and
50
+ // acted on. So a note waits for that moment and costs the subagent nothing meanwhile; a stop or a new brief refuses
51
+ // each call until the subagent ends its turn, where the new brief reaches it.
52
+ const items = takeSteers(
53
+ session,
54
+ agent,
55
+ { tool: input.tool_name ?? null },
56
+ home,
57
+ { keep: true }
58
+ );
59
+ const stopped = items.some((item) => item.kind === "stop");
60
+ const redirected = items.some((item) => item.kind === "redirect");
61
+ if (!stopped && !redirected) return null;
62
+ return {
63
+ hookSpecificOutput: {
64
+ hookEventName: "PreToolUse",
65
+ permissionDecision: "deny",
66
+ permissionDecisionReason: stopped ? steerText(items) : REDIRECT_HOLD,
67
+ },
68
+ };
69
+ }
70
+
71
+ // What a subagent asks permission for, in a line: the command, the file or the address it names.
72
+ const named = (input) =>
73
+ String(
74
+ input?.command ??
75
+ input?.file_path ??
76
+ input?.path ??
77
+ input?.url ??
78
+ input?.pattern ??
79
+ ""
80
+ ).slice(0, 200);
81
+
82
+ /**
83
+ * Claude Code's PermissionRequest hook (--ask): when a subagent's permission dialog opens, Harness hears which subagent
84
+ * and what for, so the person sees it named wherever they are. The dialog itself is left to Claude Code.
85
+ */
86
+ async function tellAsk(input) {
87
+ if (input?.hook_event_name !== "PermissionRequest" || !input.agent_id) return;
88
+ const { daemonRequest } = await import("./control-client.mjs");
89
+ const transcript = input.transcript_path
90
+ ? path.join(
91
+ path.dirname(input.transcript_path),
92
+ String(input.session_id),
93
+ "subagents",
94
+ `agent-${input.agent_id}.jsonl`
95
+ )
96
+ : "";
97
+ await daemonRequest(
98
+ {
99
+ command: "board.subagent.asking",
100
+ agent: "claude-code",
101
+ sessionId: input.session_id,
102
+ agentId: input.agent_id,
103
+ tool: input.tool_name,
104
+ what: named(input.tool_input),
105
+ transcript,
106
+ },
107
+ 1_500
108
+ ).catch(() => null);
109
+ }
110
+
111
+ if (import.meta.url === `file://${process.argv[1]}`) {
112
+ if (process.argv.includes("--ask")) {
113
+ try {
114
+ await tellAsk(await readInput());
115
+ } catch {}
116
+ process.exit(0);
117
+ }
118
+ // Never exit 2: that is Claude Code's "block", and a broken hook must not stop work.
119
+ try {
120
+ const reply = answer(await readInput());
121
+ if (reply) process.stdout.write(JSON.stringify(reply) + "\n");
122
+ } catch {}
123
+ process.exit(0);
124
+ }
@@ -0,0 +1,176 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { harnessHome } from "./paths.mjs";
4
+
5
+ // What the person tells a subagent from Harness, waiting for that subagent's next step. The daemon writes; the hook
6
+ // inside each agent (steerHook.mjs for Claude Code, the OpenCode plugin) takes. A steer is one file under
7
+ // steer/<session>/<agent>/, so taking one is a single rename no two processes both win, and the folder is empty
8
+ // whenever nothing waits: the hook's shell guard checks only that, so a tool call with nothing waiting costs no Node
9
+ // start. `agent` is Claude Code's agent_id for one of its subagents, and PARENT for the session's own model (OpenCode's
10
+ // subagents are sessions of their own, so theirs is PARENT too). A taken steer leaves a receipt, which is how the
11
+ // person's window learns when it landed.
12
+
13
+ export const PARENT = "_";
14
+ const ID = /^[A-Za-z0-9._:-]{1,128}$/;
15
+ const KINDS = new Set(["note", "redirect", "stop", "parent"]);
16
+
17
+ export const steerRoot = (home = harnessHome) => path.join(home, "steer");
18
+ const receiptsRoot = (home) => path.join(home, "steer-receipts");
19
+ const folderOf = (home, session, agent) =>
20
+ path.join(steerRoot(home), session, agent || PARENT);
21
+
22
+ const readItem = (file) => {
23
+ try {
24
+ return JSON.parse(fs.readFileSync(file, "utf8"));
25
+ } catch {
26
+ return null;
27
+ }
28
+ };
29
+ const listed = (folder) => {
30
+ try {
31
+ return fs
32
+ .readdirSync(folder)
33
+ .filter((name) => name.endsWith(".json"))
34
+ .sort();
35
+ } catch {
36
+ return [];
37
+ }
38
+ };
39
+ // Empty folders go, so the shell guard sees nothing waiting.
40
+ function prune(home, session, agent) {
41
+ for (const folder of [
42
+ folderOf(home, session, agent),
43
+ path.join(steerRoot(home), session),
44
+ ])
45
+ try {
46
+ fs.rmdirSync(folder);
47
+ } catch {}
48
+ }
49
+
50
+ /** Leaves a steer for one session's subagent (or its own model, PARENT). Returns the steer as written. */
51
+ export function putSteer(
52
+ { session, agent, kind, text = "", about = null },
53
+ home = harnessHome
54
+ ) {
55
+ if (!ID.test(String(session)) || !ID.test(String(agent || PARENT)))
56
+ throw new Error("a steer needs a plain session and agent id");
57
+ if (!KINDS.has(kind)) throw new Error(`unknown steer kind ${kind}`);
58
+ const at = new Date().toISOString();
59
+ const id = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
60
+ const item = { id, kind, text: String(text), about, at };
61
+ const folder = folderOf(home, session, agent);
62
+ fs.mkdirSync(folder, { recursive: true, mode: 0o700 });
63
+ // Written aside, then renamed in: a hook never reads half a steer.
64
+ const file = path.join(folder, `${id}.json`);
65
+ fs.writeFileSync(`${file}.part`, JSON.stringify(item), { mode: 0o600 });
66
+ fs.renameSync(`${file}.part`, file);
67
+ return item;
68
+ }
69
+
70
+ function receipt(home, item, where) {
71
+ const folder = receiptsRoot(home);
72
+ try {
73
+ fs.mkdirSync(folder, { recursive: true, mode: 0o700 });
74
+ fs.writeFileSync(
75
+ path.join(folder, `${item.id}.json`),
76
+ JSON.stringify({ id: item.id, at: new Date().toISOString(), ...where }),
77
+ { mode: 0o600 }
78
+ );
79
+ } catch {}
80
+ }
81
+
82
+ /**
83
+ * Takes what waits for one session's subagent: every note, redirect and parent note, each once. A stop is not taken:
84
+ * it stays until the subagent ends (endSteers), so every later step is refused too. `where` goes on each receipt
85
+ * (the tool it landed before). With `keep`, nothing but a stop's first landing is marked: the hook only looks.
86
+ */
87
+ export function takeSteers(
88
+ session,
89
+ agent,
90
+ where = {},
91
+ home = harnessHome,
92
+ { keep = false } = {}
93
+ ) {
94
+ if (!ID.test(String(session)) || !ID.test(String(agent || PARENT))) return [];
95
+ const folder = folderOf(home, session, agent);
96
+ const taken = [];
97
+ for (const name of listed(folder)) {
98
+ const file = path.join(folder, name);
99
+ const item = readItem(file);
100
+ if (!item) continue;
101
+ if (item.kind === "stop") {
102
+ if (!item.landed) {
103
+ receipt(home, item, where);
104
+ item.landed = true;
105
+ try {
106
+ fs.writeFileSync(file, JSON.stringify(item), { mode: 0o600 });
107
+ } catch {}
108
+ }
109
+ taken.push(item);
110
+ continue;
111
+ }
112
+ if (keep) {
113
+ taken.push(item);
114
+ continue;
115
+ }
116
+ // The rename is the claim: another hook that lost it moves on.
117
+ try {
118
+ fs.renameSync(file, `${file}.taken`);
119
+ } catch {
120
+ continue;
121
+ }
122
+ fs.rmSync(`${file}.taken`, { force: true });
123
+ receipt(home, item, where);
124
+ taken.push(item);
125
+ }
126
+ prune(home, session, agent);
127
+ return taken;
128
+ }
129
+
130
+ /** A subagent ended: its stop is spent. Returns what still waited besides (notes it never reached), taken. */
131
+ export function endSteers(session, agent, where = {}, home = harnessHome) {
132
+ const left = takeSteers(session, agent, where, home);
133
+ const folder = folderOf(home, session, agent);
134
+ for (const name of listed(folder))
135
+ fs.rmSync(path.join(folder, name), { force: true });
136
+ prune(home, session, agent);
137
+ return left.filter((item) => item.kind !== "stop");
138
+ }
139
+
140
+ /** What waits for one session's subagent, and the receipt of each steer that already landed. For the window. */
141
+ export function steersOf(session, agent, home = harnessHome) {
142
+ if (!ID.test(String(session)) || !ID.test(String(agent || PARENT))) return [];
143
+ return listed(folderOf(home, session, agent))
144
+ .map((name) => readItem(path.join(folderOf(home, session, agent), name)))
145
+ .filter(Boolean);
146
+ }
147
+
148
+ export function receiptOf(id, home = harnessHome) {
149
+ if (!ID.test(String(id))) return null;
150
+ return readItem(path.join(receiptsRoot(home), `${id}.json`));
151
+ }
152
+
153
+ // Said first, so an agent reads the words as the person's own and not as text a tool happened to return: they reach it
154
+ // through a hook the person installed, and Claude Code shows a hook's words beside a tool's result.
155
+ const FROM_PERSON =
156
+ "This is from the user, sent while you work. They watch and steer their coding agents in Harness, which they connected to you.";
157
+
158
+ /** What a Claude Code subagent reads while a new brief for it waits: drop the current course, so the brief reaches it. */
159
+ export const REDIRECT_HOLD = `${FROM_PERSON} They are giving you a new brief. Stop what you are doing and end your turn now, without calling more tools: the new brief reaches you as you finish, and you carry on with it.`;
160
+
161
+ /** The words a subagent (or the agent that started it) reads for what it was told. */
162
+ export function steerText(items) {
163
+ const stop = items.find((item) => item.kind === "stop");
164
+ if (stop)
165
+ return `${FROM_PERSON} They stopped you. Make no more changes and call no more tools. Return now with what you have done so far and what is left undone.`;
166
+ return [
167
+ FROM_PERSON,
168
+ ...items.map((item) =>
169
+ item.kind === "redirect"
170
+ ? `They replaced your brief. Your brief is now:\n\n${item.text}\n\nDrop any step that does not serve it.`
171
+ : item.kind === "parent"
172
+ ? item.text
173
+ : `Their message to you:\n\n${item.text}`
174
+ ),
175
+ ].join("\n\n");
176
+ }
package/lib/store.mjs CHANGED
@@ -444,6 +444,11 @@ export function openStore(file) {
444
444
  "alter table sessions add column parser_version integer not null default 0"
445
445
  );
446
446
  }
447
+ // Rounds recorded before November 1 named the server's decider "harness"; every one was Jev's (the server has
448
+ // decided rounds with Jev since the coordinator began, October 11), so the record says so.
449
+ db.exec(
450
+ "update swarm_rounds set coordinator = 'jev' where coordinator = 'harness'"
451
+ );
447
452
  // Boards written before the lock existed: give every task a holder and a version.
448
453
  const boardColumns = new Set(
449
454
  db.all("pragma table_info(board_tasks)").map((column) => column.name)
@@ -1263,16 +1268,14 @@ export function openStore(file) {
1263
1268
  proposers: row?.proposers_set
1264
1269
  ? JSON.parse(row.proposers)
1265
1270
  : [...PROPOSERS],
1266
- runs_today:
1267
- Number(this.meta(`prompt-quota:${since}:${agent}`) || "0") +
1268
- Number(
1269
- execute(
1270
- "get",
1271
- "select count(*) as n from board_tasks where target_agent = ? and run_authorized_by = 'standing' and run_authorized_at >= ?",
1272
- agent,
1273
- since
1274
- ).n
1275
- ),
1271
+ runs_today: Number(
1272
+ execute(
1273
+ "get",
1274
+ "select count(*) as n from board_tasks where target_agent = ? and run_authorized_by = 'standing' and run_authorized_at >= ?",
1275
+ agent,
1276
+ since
1277
+ ).n
1278
+ ),
1276
1279
  };
1277
1280
  });
1278
1281
  },
@@ -1347,29 +1350,18 @@ export function openStore(file) {
1347
1350
  scopeRef = null,
1348
1351
  expectedScope = null,
1349
1352
  nextScope = null,
1350
- quota = null,
1351
1353
  }) {
1352
1354
  db.exec("begin immediate");
1353
1355
  try {
1354
1356
  const task = this.getTask(id);
1355
1357
  const key = `dispatch-grant:${id}`;
1356
- const rule = quota
1357
- ? this.standing([quota.agent], quota.period)[0]
1358
- : null;
1359
1358
  if (
1360
1359
  this.meta(key) !== expectedGrant ||
1361
1360
  task?.version !== expectedVersion ||
1362
1361
  task.status !== "open" ||
1363
1362
  task.run_authorized_at ||
1364
1363
  (scopeRef &&
1365
- this.meta(`dispatch-scope:${scopeRef}`) !== expectedScope) ||
1366
- (quota &&
1367
- (quota.remaining < 1 ||
1368
- this.meta(quota.key) !== quota.expected ||
1369
- rule.daily_cap !== quota.limit ||
1370
- rule.set_at !== quota.rule_epoch ||
1371
- rule.mode !== quota.rule_mode ||
1372
- rule.runs_today >= rule.daily_cap))
1364
+ this.meta(`dispatch-scope:${scopeRef}`) !== expectedScope)
1373
1365
  ) {
1374
1366
  db.exec("commit");
1375
1367
  return false;
@@ -1389,7 +1381,6 @@ export function openStore(file) {
1389
1381
  }
1390
1382
  this.meta(key, nextGrant);
1391
1383
  if (scopeRef) this.meta(`dispatch-scope:${scopeRef}`, nextScope);
1392
- if (quota) this.meta(quota.key, quota.next);
1393
1384
  db.exec("commit");
1394
1385
  return true;
1395
1386
  } catch (error) {
@@ -2801,8 +2792,8 @@ export function openStore(file) {
2801
2792
  }));
2802
2793
  },
2803
2794
  /**
2804
- * How the coordinator held up, a day at a time, newest first: rounds Harness decided, rounds a backup on this
2805
- * computer decided after Harness could not, rounds decided here on the privacy setting, and rounds no one decided.
2795
+ * How the coordinator held up, a day at a time, newest first: rounds Jev decided on the server, rounds a backup on
2796
+ * this computer decided after Jev could not, rounds decided here on the privacy setting, and rounds no one decided.
2806
2797
  */
2807
2798
  roundHealth(goalId = null, days = 14) {
2808
2799
  const since = new Date(
@@ -2812,9 +2803,9 @@ export function openStore(file) {
2812
2803
  "all",
2813
2804
  `select substr(at, 1, 10) as day,
2814
2805
  count(*) as rounds,
2815
- sum(case when action is not null and coordinator = 'harness' then 1 else 0 end) as harness,
2816
- sum(case when action is not null and coordinator != 'harness' and error is not null then 1 else 0 end) as backup,
2817
- sum(case when action is not null and coordinator != 'harness' and error is null then 1 else 0 end) as local,
2806
+ sum(case when action is not null and coordinator = 'jev' then 1 else 0 end) as jev,
2807
+ sum(case when action is not null and coordinator != 'jev' and error is not null then 1 else 0 end) as backup,
2808
+ sum(case when action is not null and coordinator != 'jev' and error is null then 1 else 0 end) as local,
2818
2809
  sum(case when action is null then 1 else 0 end) as undecided
2819
2810
  from swarm_rounds where at >= ? and (? is null or goal_id = ?)
2820
2811
  group by day order by day desc`,
@@ -2824,7 +2815,7 @@ export function openStore(file) {
2824
2815
  ).map((row) => ({
2825
2816
  day: row.day,
2826
2817
  rounds: Number(row.rounds),
2827
- harness: Number(row.harness),
2818
+ jev: Number(row.jev),
2828
2819
  backup: Number(row.backup),
2829
2820
  local: Number(row.local),
2830
2821
  undecided: Number(row.undecided),