tryharness 0.7.38 → 0.7.41
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/boardAccess.mjs +1 -0
- package/lib/boardProtocol.json +35 -3
- package/lib/boardThreads.mjs +3 -2
- package/lib/boardWatches.mjs +5 -0
- package/lib/bridge.mjs +17 -2
- package/lib/coordinator.mjs +11 -1
- package/lib/daemon.mjs +210 -18
- package/lib/goalCommands.mjs +2 -2
- package/lib/goals.mjs +14 -3
- package/lib/handoffs.mjs +117 -0
- package/lib/mcp-stdio.mjs +69 -15
- package/lib/notify.mjs +5 -4
- package/lib/onboard.mjs +1 -0
- package/lib/plans.mjs +538 -0
- package/lib/runWorker.mjs +18 -6
- package/lib/runner.mjs +6 -1
- package/lib/store.mjs +22 -1
- package/lib/swarm.mjs +98 -18
- package/lib/taskCommands.mjs +34 -2
- package/lib/threadView.mjs +426 -0
- package/lib/wakes.mjs +3 -2
- package/package.json +1 -1
package/lib/goals.mjs
CHANGED
|
@@ -60,7 +60,11 @@ export function createGoals({ store, notifyBoard = () => {} }) {
|
|
|
60
60
|
* A new version, from the lead's round or the person. A criterion kept word for word keeps what it reached; one left
|
|
61
61
|
* out is dropped, so the record still shows it. Posted in the thread with the post it follows.
|
|
62
62
|
*/
|
|
63
|
-
const set = (
|
|
63
|
+
const set = (
|
|
64
|
+
threadId,
|
|
65
|
+
{ statement, criteria, title },
|
|
66
|
+
{ by, seq = null }
|
|
67
|
+
) => {
|
|
64
68
|
const text = String(statement || "")
|
|
65
69
|
.trim()
|
|
66
70
|
.slice(0, 4_000);
|
|
@@ -92,8 +96,14 @@ export function createGoals({ store, notifyBoard = () => {} }) {
|
|
|
92
96
|
.map((criterion) => ({ ...criterion, status: "dropped" }));
|
|
93
97
|
const version = (before?.version ?? 0) + 1;
|
|
94
98
|
const at = new Date().toISOString();
|
|
99
|
+
// What the work is in a few words, for every list of threads; a version without one keeps the last.
|
|
100
|
+
const named =
|
|
101
|
+
String(title || "")
|
|
102
|
+
.trim()
|
|
103
|
+
.slice(0, 64) || before?.title;
|
|
95
104
|
const record = {
|
|
96
105
|
version,
|
|
106
|
+
...(named ? { title: named } : {}),
|
|
97
107
|
statement: text,
|
|
98
108
|
criteria: [...current, ...dropped].slice(0, MAX_CRITERIA),
|
|
99
109
|
state: "working",
|
|
@@ -139,9 +149,10 @@ export function createGoals({ store, notifyBoard = () => {} }) {
|
|
|
139
149
|
return { ...criterion, status: "met", evidence };
|
|
140
150
|
});
|
|
141
151
|
const allMet = criteria.every((criterion) => criterion.status !== "open");
|
|
142
|
-
// Met only when every check is reached: a round that says so early leaves it
|
|
152
|
+
// Met, or ready for the person's review, only when every check is reached: a round that says so early leaves it
|
|
153
|
+
// working (October 19: "Ready for your review" with one of three checks met).
|
|
143
154
|
const state = STATES.includes(goalState)
|
|
144
|
-
? goalState
|
|
155
|
+
? goalState !== "working" && !allMet
|
|
145
156
|
? "working"
|
|
146
157
|
: goalState
|
|
147
158
|
: record.state;
|
package/lib/handoffs.mjs
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { nameOf } from "./members.mjs";
|
|
2
|
+
|
|
3
|
+
// Work handed to an agent that has to be woken (Grok Bot by email, OpenClaw and Hermes on their gateways) is watched
|
|
4
|
+
// until the agent picks it up. A wake can be accepted and still never start a run (October 19: two of Grok Bot's
|
|
5
|
+
// emails went unanswered for 2 h and 20 min), so a missed pickup is never silent: the agent is woken again at 3
|
|
6
|
+
// minutes, and at 10 the work moves to Harness, whose server takes it at once. The thread says so each time, and the
|
|
7
|
+
// person can put the work back.
|
|
8
|
+
//
|
|
9
|
+
// The 3 and 10 minutes: Grok Bot's 36 email wakes from October 15 to 19 were claimed 13 to 59 s after sending, so 3
|
|
10
|
+
// minutes is three times its slowest normal pickup (owner, October 19).
|
|
11
|
+
|
|
12
|
+
export const HANDOFF_TIMING = { nudgeMs: 3 * 60_000, moveMs: 10 * 60_000 };
|
|
13
|
+
// A setup check waits as long as setup does (onboard.mjs, ten minutes), then it is off the board.
|
|
14
|
+
const SETUP_CHECK_MS = 15 * 60_000;
|
|
15
|
+
export const WATCHED = new Set(["grok-bot", "openclaw", "hermes"]);
|
|
16
|
+
|
|
17
|
+
// A setup check (onboard.mjs), marked since October 19, or by the exact objective setup posts from before that.
|
|
18
|
+
export const isSetupCheck = (store, task) =>
|
|
19
|
+
Boolean(store.meta(`setup-check:${task.id}`)) ||
|
|
20
|
+
task.objective === "Setup check from Harness: reply ready";
|
|
21
|
+
|
|
22
|
+
const minutes = (ms) => Math.max(1, Math.round(ms / 60_000));
|
|
23
|
+
|
|
24
|
+
export function createHandoffs({
|
|
25
|
+
store,
|
|
26
|
+
wakeAgain,
|
|
27
|
+
moveTo,
|
|
28
|
+
say,
|
|
29
|
+
timing = HANDOFF_TIMING,
|
|
30
|
+
now = Date.now,
|
|
31
|
+
}) {
|
|
32
|
+
const read = (key) => {
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(store.meta(key) || "null");
|
|
35
|
+
} catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const nudgedKey = (task) => `handoff-nudged:${task.id}:${task.updated_at}`;
|
|
40
|
+
const movedKey = (taskId) => `handoff-moved:${taskId}`;
|
|
41
|
+
// How long the work has waited: since it was posted, or since it last went back to the agent (an answer, say).
|
|
42
|
+
const waitedMs = (task) => now() - Date.parse(task.updated_at);
|
|
43
|
+
const watched = (task) =>
|
|
44
|
+
task?.status === "open" &&
|
|
45
|
+
task.kind === "task" &&
|
|
46
|
+
WATCHED.has(task.target_agent) &&
|
|
47
|
+
Boolean(task.parent_id) &&
|
|
48
|
+
store.getTask(task.parent_id)?.kind === "goal";
|
|
49
|
+
|
|
50
|
+
function nudge(task) {
|
|
51
|
+
store.meta(nudgedKey(task), new Date(now()).toISOString());
|
|
52
|
+
wakeAgain(task.target_agent, task.id);
|
|
53
|
+
say(
|
|
54
|
+
task.parent_id,
|
|
55
|
+
`${nameOf(task.target_agent)} hasn't picked this up after ${minutes(waitedMs(task))} min, so it was woken again.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function move(task) {
|
|
60
|
+
const waited = waitedMs(task);
|
|
61
|
+
if (!moveTo(task, "harness")) return;
|
|
62
|
+
store.meta(
|
|
63
|
+
movedKey(task.id),
|
|
64
|
+
JSON.stringify({
|
|
65
|
+
from: task.target_agent,
|
|
66
|
+
to: "harness",
|
|
67
|
+
at: new Date(now()).toISOString(),
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
say(
|
|
71
|
+
task.parent_id,
|
|
72
|
+
`${nameOf(task.target_agent)} didn't pick this up in ${minutes(waited)} min, so Harness has it now.`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Checks every watched handoff once: called on a timer. */
|
|
77
|
+
function tick() {
|
|
78
|
+
for (const task of store.listTasks({ status: "open", limit: 200 })) {
|
|
79
|
+
if (isSetupCheck(store, task)) {
|
|
80
|
+
if (now() - Date.parse(task.created_at) > SETUP_CHECK_MS)
|
|
81
|
+
store.removeTask(task.id);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (!watched(task)) continue;
|
|
85
|
+
const waited = waitedMs(task);
|
|
86
|
+
if (waited >= timing.moveMs) move(task);
|
|
87
|
+
else if (waited >= timing.nudgeMs && !store.meta(nudgedKey(task)))
|
|
88
|
+
nudge(task);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Where a late or moved handoff stands, as one line for its thread; null when it is on time. */
|
|
93
|
+
function of(run) {
|
|
94
|
+
const moved = read(movedKey(run.id));
|
|
95
|
+
if (moved)
|
|
96
|
+
return {
|
|
97
|
+
at: moved.at,
|
|
98
|
+
line: `Moved to ${nameOf(moved.to)}: ${nameOf(moved.from)} didn't pick it up`,
|
|
99
|
+
movedTo: moved.to,
|
|
100
|
+
};
|
|
101
|
+
if (
|
|
102
|
+
run.status !== "open" ||
|
|
103
|
+
run.kind !== "task" ||
|
|
104
|
+
!WATCHED.has(run.target_agent)
|
|
105
|
+
)
|
|
106
|
+
return null;
|
|
107
|
+
const nudged = store.meta(nudgedKey(run));
|
|
108
|
+
return nudged
|
|
109
|
+
? {
|
|
110
|
+
at: nudged,
|
|
111
|
+
line: `${nameOf(run.target_agent)} hasn't picked it up yet (${minutes(waitedMs(run))} min); woken again`,
|
|
112
|
+
}
|
|
113
|
+
: null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return { tick, of };
|
|
117
|
+
}
|
package/lib/mcp-stdio.mjs
CHANGED
|
@@ -102,11 +102,38 @@ const LOCAL_TOOLS = [
|
|
|
102
102
|
additionalProperties: false,
|
|
103
103
|
},
|
|
104
104
|
},
|
|
105
|
+
after: {
|
|
106
|
+
type: "array",
|
|
107
|
+
items: { type: "string" },
|
|
108
|
+
description:
|
|
109
|
+
"with parent_id set to a thread: ids of tasks in that thread this one waits for. It is posted once they are all done, with their answers in its brief, and does not start if one of them stops. Use it to lay out steps that depend on each other; work that can start now needs none",
|
|
110
|
+
},
|
|
105
111
|
},
|
|
106
112
|
required: ["objective"],
|
|
107
113
|
additionalProperties: false,
|
|
108
114
|
},
|
|
109
115
|
},
|
|
116
|
+
{
|
|
117
|
+
name: "use_template",
|
|
118
|
+
description:
|
|
119
|
+
"Start a thread's work from one of the person's saved templates: agents, what each is asked and which waits for which. Without name it lists the templates with their {{blanks}}. With name and parent_id (the thread) it adds the template's steps there, the blanks filled from fill; steps with nothing wired into them start now, the rest when the work they wait for is done.",
|
|
120
|
+
inputSchema: {
|
|
121
|
+
type: "object",
|
|
122
|
+
properties: {
|
|
123
|
+
name: { type: "string" },
|
|
124
|
+
parent_id: {
|
|
125
|
+
type: "string",
|
|
126
|
+
description: "the thread to add the steps to",
|
|
127
|
+
},
|
|
128
|
+
fill: {
|
|
129
|
+
type: "object",
|
|
130
|
+
additionalProperties: { type: "string" },
|
|
131
|
+
description: "a value for each {{blank}} in the template",
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
additionalProperties: false,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
110
137
|
{
|
|
111
138
|
name: "wallet",
|
|
112
139
|
description:
|
|
@@ -609,6 +636,22 @@ const LOCAL_TOOLS = [
|
|
|
609
636
|
},
|
|
610
637
|
];
|
|
611
638
|
|
|
639
|
+
const postTask = (args) => ({
|
|
640
|
+
command: "board.post",
|
|
641
|
+
objective: args.objective,
|
|
642
|
+
brief: args.brief,
|
|
643
|
+
targetAgent: args.target_agent,
|
|
644
|
+
targetAgents: args.target_agents,
|
|
645
|
+
parentId: args.parent_id,
|
|
646
|
+
contextRefs: args.context_refs,
|
|
647
|
+
runWorkspace: args.run_workspace,
|
|
648
|
+
inSession: args.in_session === true,
|
|
649
|
+
model: args.model,
|
|
650
|
+
effort: args.effort,
|
|
651
|
+
posterCwd: process.cwd(),
|
|
652
|
+
posterPid: process.ppid,
|
|
653
|
+
});
|
|
654
|
+
|
|
612
655
|
const BOARD_CALLS = {
|
|
613
656
|
list_agents: () => ({ command: "board.swarm.agents" }),
|
|
614
657
|
list_models: (args) => ({
|
|
@@ -753,21 +796,32 @@ const BOARD_CALLS = {
|
|
|
753
796
|
hash: args.hash,
|
|
754
797
|
chain: args.chain,
|
|
755
798
|
}),
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
799
|
+
// Work that waits for other work in a thread is a plan step (plans.mjs) until what it waits for is done.
|
|
800
|
+
post_task: (args) =>
|
|
801
|
+
Array.isArray(args.after) && args.after.length
|
|
802
|
+
? {
|
|
803
|
+
command: "board.plan.add",
|
|
804
|
+
id: String(args.parent_id || ""),
|
|
805
|
+
nodes: [
|
|
806
|
+
{
|
|
807
|
+
key: "step",
|
|
808
|
+
agent: args.target_agent,
|
|
809
|
+
objective: args.objective,
|
|
810
|
+
brief: args.brief,
|
|
811
|
+
after: args.after,
|
|
812
|
+
},
|
|
813
|
+
],
|
|
814
|
+
}
|
|
815
|
+
: postTask(args),
|
|
816
|
+
use_template: (args) =>
|
|
817
|
+
args.name && args.parent_id
|
|
818
|
+
? {
|
|
819
|
+
command: "board.template.use",
|
|
820
|
+
name: String(args.name),
|
|
821
|
+
id: String(args.parent_id),
|
|
822
|
+
fill: args.fill ?? {},
|
|
823
|
+
}
|
|
824
|
+
: { command: "board.template.list" },
|
|
771
825
|
claim_task: (args) => ({
|
|
772
826
|
command: "board.claim",
|
|
773
827
|
id: String(args.id || ""),
|
package/lib/notify.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { nameOf } from "./members.mjs";
|
|
2
3
|
|
|
3
4
|
// A desktop notification from the daemon, for the person who does not have Harness open:
|
|
4
5
|
// work that needs them (an agent asks to run something, a question, a stale claim, a request
|
|
@@ -72,18 +73,18 @@ export function notificationFor(task, { previous = null } = {}) {
|
|
|
72
73
|
!previous.run_authorized_at
|
|
73
74
|
)
|
|
74
75
|
) {
|
|
75
|
-
return `${task.origin_agent} wants ${task.target_agent} to
|
|
76
|
+
return `${nameOf(task.origin_agent)} wants ${nameOf(task.target_agent)} to start: ${objective}. Start it from the buddy or your phone.`;
|
|
76
77
|
}
|
|
77
78
|
if (
|
|
78
79
|
task.status === "needs_input" &&
|
|
79
80
|
(task.holder === "user" || task.origin_agent === "user") &&
|
|
80
81
|
previous?.status !== "needs_input"
|
|
81
82
|
) {
|
|
82
|
-
return `${task.claimed_by}
|
|
83
|
+
return `${nameOf(task.claimed_by)} asks you about ${objective}: ${String(task.result || "").slice(0, 120)}`;
|
|
83
84
|
}
|
|
84
85
|
if (task.status === "unknown" && previous?.status !== "unknown")
|
|
85
|
-
return `
|
|
86
|
+
return `It is not known how ${nameOf(task.target_agent)}'s run ended: ${objective}`;
|
|
86
87
|
if (task.status === "open" && task.target_agent === "harness" && !previous)
|
|
87
|
-
return `${task.origin_agent}
|
|
88
|
+
return `${nameOf(task.origin_agent)} asked Harness: ${objective}`;
|
|
88
89
|
return null;
|
|
89
90
|
}
|
package/lib/onboard.mjs
CHANGED