tryharness 0.7.29 → 0.7.31
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/lib/activity.mjs +33 -10
- package/lib/coordinator.mjs +12 -4
- package/package.json +1 -1
package/lib/activity.mjs
CHANGED
|
@@ -18,7 +18,13 @@ export const QUIET_MS = 5 * 60_000;
|
|
|
18
18
|
// Measured 2026-10-10 with ps: an idle server with a file watcher reads 0.0-0.1 %, a working process 99.9-100 %.
|
|
19
19
|
export const CPU_BUSY = 5;
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
// OpenCode is named so its process and the app hosting it are never paused; its transcripts are not read here.
|
|
22
|
+
const AGENT_NAMES = {
|
|
23
|
+
claude: "claude-code",
|
|
24
|
+
codex: "codex",
|
|
25
|
+
pi: "pi",
|
|
26
|
+
opencode: "opencode",
|
|
27
|
+
};
|
|
22
28
|
const RUNTIMES = new Set(["node", "bun", "deno"]);
|
|
23
29
|
// Claude Code runs every tool command in a shell; its other children (MCP servers, caffeinate) are not work.
|
|
24
30
|
const SHELLS = new Set(["sh", "bash", "zsh", "fish", "dash", "ksh"]);
|
|
@@ -68,16 +74,30 @@ const textOf = (content) =>
|
|
|
68
74
|
? content.map((part) => part?.text || "").join("")
|
|
69
75
|
: "";
|
|
70
76
|
|
|
71
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Whether a transcript's last turn is still open, and when it started, from its newest rows.
|
|
79
|
+
* A finished turn's end is its newest row. Rows from inside a turn newer than any end are a turn
|
|
80
|
+
* still open: its prompt lies further back than the rows read (a long turn), or it was started by
|
|
81
|
+
* something other than a typed prompt (another agent's message, a queued command).
|
|
82
|
+
*/
|
|
72
83
|
export function turnOf(agent, rows) {
|
|
84
|
+
let inTurn = false;
|
|
85
|
+
let oldest = null;
|
|
86
|
+
const passed = (row) => {
|
|
87
|
+
inTurn = true;
|
|
88
|
+
oldest = stamp(row.timestamp) ?? oldest;
|
|
89
|
+
};
|
|
90
|
+
const ended = () =>
|
|
91
|
+
inTurn ? { open: true, startedAt: oldest } : { open: false };
|
|
73
92
|
for (let index = rows.length - 1; index >= 0; index -= 1) {
|
|
74
93
|
const row = rows[index];
|
|
75
94
|
if (agent === "codex") {
|
|
76
95
|
const kind = row.type === "event_msg" ? row.payload?.type : null;
|
|
77
96
|
if (kind === "task_started")
|
|
78
97
|
return { open: true, startedAt: stamp(row.timestamp) };
|
|
79
|
-
if (kind === "task_complete" || kind === "turn_aborted")
|
|
80
|
-
|
|
98
|
+
if (kind === "task_complete" || kind === "turn_aborted") return ended();
|
|
99
|
+
// Codex writes settings events after a turn ends; only the model's items are inside one.
|
|
100
|
+
if (row.type === "response_item") passed(row);
|
|
81
101
|
} else if (agent === "pi") {
|
|
82
102
|
const message = row.type === "message" ? row.message : null;
|
|
83
103
|
if (!message) continue;
|
|
@@ -87,29 +107,32 @@ export function turnOf(agent, rows) {
|
|
|
87
107
|
startedAt: stamp(row.timestamp ?? message.timestamp),
|
|
88
108
|
};
|
|
89
109
|
if (message.role === "assistant" && message.stopReason !== "toolUse")
|
|
90
|
-
return
|
|
110
|
+
return ended();
|
|
111
|
+
passed(row);
|
|
91
112
|
} else {
|
|
92
113
|
if (row.isMeta || (row.type !== "user" && row.type !== "assistant"))
|
|
93
114
|
continue;
|
|
94
115
|
const content = row.message?.content;
|
|
95
116
|
if (row.type === "assistant") {
|
|
96
|
-
if (row.message?.stop_reason === "end_turn") return
|
|
117
|
+
if (row.message?.stop_reason === "end_turn") return ended();
|
|
118
|
+
passed(row);
|
|
97
119
|
continue;
|
|
98
120
|
}
|
|
99
121
|
if (
|
|
100
122
|
Array.isArray(content) &&
|
|
101
123
|
content.some((part) => part?.type === "tool_result")
|
|
102
|
-
)
|
|
124
|
+
) {
|
|
125
|
+
passed(row);
|
|
103
126
|
continue;
|
|
127
|
+
}
|
|
104
128
|
const text = textOf(content);
|
|
105
|
-
if (text.startsWith("[Request interrupted by user"))
|
|
106
|
-
return { open: false };
|
|
129
|
+
if (text.startsWith("[Request interrupted by user")) return ended();
|
|
107
130
|
if (text.startsWith("<local-command") || text.startsWith("<command-"))
|
|
108
131
|
continue;
|
|
109
132
|
return { open: true, startedAt: stamp(row.timestamp) };
|
|
110
133
|
}
|
|
111
134
|
}
|
|
112
|
-
return
|
|
135
|
+
return ended();
|
|
113
136
|
}
|
|
114
137
|
|
|
115
138
|
function tailRows(file) {
|
package/lib/coordinator.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { MACHINE_RUNNERS, MEMBERS, nameOf } from "./members.mjs";
|
|
|
10
10
|
// agent, a question for the person, a part left behind, a pause. Every round is recorded with its facts and cost.
|
|
11
11
|
// The person's own message to the swarm (`@swarm`, or one in a thread that names no agent) gets its round at once, even
|
|
12
12
|
// while agents work, and every agent with a part in it is brought in together (an assembly). When Harness cannot decide
|
|
13
|
-
// that round, or finds no part for anyone in
|
|
13
|
+
// that round, or finds no part for anyone in it, every agent that can work there hears the message as the
|
|
14
14
|
// person wrote it (owner, October 15): Harness is never the only way the person's words reach their swarm.
|
|
15
15
|
// A round Harness cannot decide (an error, a dropped connection) is decided by a backup: the person's coding agents on
|
|
16
16
|
// this computer with their tools off, most finished work first (owner, October 15: "if harness is going to be the main
|
|
@@ -339,7 +339,7 @@ export function createCoordinator({
|
|
|
339
339
|
// when it was written to the whole swarm (or no agent is in it yet) every agent the person has. Not Harness, which could
|
|
340
340
|
// not decide; not an agent the person named, who has it already; an agent on Harness's server only while this computer
|
|
341
341
|
// reaches Harness; Bankr and Quotient only once in the thread. Returns who heard it.
|
|
342
|
-
// `decided`: Harness found no part for anyone in
|
|
342
|
+
// `decided`: Harness found no part for anyone in the person's message, so the agents already in the thread hear it (the whole
|
|
343
343
|
// swarm only when none is in it yet); with no decision at all, an `@swarm` reaches the whole swarm.
|
|
344
344
|
const tellEveryone = (thread, asked, why, { decided = false } = {}) => {
|
|
345
345
|
const inThread = thread.goal.team.filter(
|
|
@@ -383,7 +383,7 @@ export function createCoordinator({
|
|
|
383
383
|
thread.id,
|
|
384
384
|
names,
|
|
385
385
|
words,
|
|
386
|
-
|
|
386
|
+
`${asked.swarm ? "the person wrote to the whole swarm and " : ""}every agent here heard the person's message as they wrote it${why ? ", since Harness could not work out who does what" : asked.swarm ? "" : ", since Harness found no one part in it"}. Do the part of it that is yours; if none of it is, say so in one line and stop`
|
|
387
387
|
);
|
|
388
388
|
notifyBoard(store.getTask(thread.id));
|
|
389
389
|
return names;
|
|
@@ -454,6 +454,14 @@ export function createCoordinator({
|
|
|
454
454
|
) => {
|
|
455
455
|
if (applyGoal(thread, given, coordinator)) return;
|
|
456
456
|
const decision = guardQuestion(thread, given, candidates, rules);
|
|
457
|
+
// The person's message is never met with silence: a round that brings no one in and asks them nothing lets the
|
|
458
|
+
// agents hear it as they wrote it, as with `@swarm` (owner, October 16: "it should never be silent if jev doesnt
|
|
459
|
+
// understand thats fallback behavior").
|
|
460
|
+
if (asked && decision.action === "wait") {
|
|
461
|
+
tellEveryone(thread, asked, null, { decided: true });
|
|
462
|
+
notifyBoard(store.getTask(thread.id));
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
457
465
|
if (decision.openItem)
|
|
458
466
|
postAsCoordinator({
|
|
459
467
|
goalId: thread.id,
|
|
@@ -480,7 +488,7 @@ export function createCoordinator({
|
|
|
480
488
|
part.text
|
|
481
489
|
);
|
|
482
490
|
if (!parts.length) {
|
|
483
|
-
if (asked
|
|
491
|
+
if (asked) tellEveryone(thread, asked, null, { decided: true });
|
|
484
492
|
notifyBoard(store.getTask(thread.id));
|
|
485
493
|
return;
|
|
486
494
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tryharness",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.31",
|
|
4
4
|
"description": "Harness Relay: the daemon that turns the agents on this machine into your personal swarm. Memory, history, and work handed between any of them.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tryharness": "cli.mjs"
|