tryharness 0.7.30 → 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/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/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"
|