tryharness 0.7.78 → 0.7.82
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/README.md +4 -3
- package/assets/install.sh +104 -0
- package/cli.mjs +203 -321
- package/lib/adapters.mjs +7 -6
- package/lib/agentRuntimes.mjs +2 -1
- package/lib/backupSetup.mjs +0 -52
- package/lib/boardProtocol.json +21 -1
- package/lib/browserPage.mjs +30 -0
- package/lib/coordinator.mjs +0 -2
- package/lib/daemon.mjs +117 -7
- package/lib/desktop.mjs +7 -1
- package/lib/dispatcher.mjs +12 -2
- package/lib/environments.mjs +4 -11
- package/lib/goalCommands.mjs +18 -8
- package/lib/hookDialects.mjs +2 -1
- package/lib/jobAnswers.mjs +2 -1
- package/lib/kanban.mjs +217 -48
- package/lib/localStack.mjs +24 -9
- package/lib/machineRoutes.mjs +9 -0
- package/lib/machineRuns.mjs +9 -1
- package/lib/manager.mjs +60 -2
- package/lib/mcp-stdio.mjs +9 -3
- package/lib/museSession.mjs +2 -1
- package/lib/nativeHost.mjs +11 -2
- package/lib/network.mjs +20 -0
- package/lib/notify.mjs +48 -16
- package/lib/onboard.mjs +71 -366
- package/lib/ownMachines.mjs +95 -44
- package/lib/pairing.mjs +0 -84
- package/lib/paths.mjs +17 -0
- package/lib/peopleBoard.mjs +131 -0
- package/lib/personNotices.mjs +9 -25
- package/lib/phones.mjs +1 -0
- package/lib/profile.mjs +0 -109
- package/lib/projectBoard.mjs +219 -0
- package/lib/projectPieces.mjs +26 -0
- package/lib/projects.mjs +37 -4
- package/lib/removeHarness.mjs +91 -0
- package/lib/roomChannels.mjs +2 -0
- package/lib/runAuthority.mjs +23 -9
- package/lib/runBrief.mjs +20 -14
- package/lib/runner.mjs +3 -3
- package/lib/runtime-install.mjs +22 -2
- package/lib/screen.mjs +133 -0
- package/lib/selfUpdate.mjs +6 -6
- package/lib/service.mjs +120 -7
- package/lib/sessionControl.mjs +10 -0
- package/lib/setupChoices.mjs +400 -0
- package/lib/setupMode.mjs +137 -0
- package/lib/store.mjs +6 -3
- package/lib/swarm.mjs +181 -61
- package/lib/t3.mjs +23 -14
- package/lib/taskCommands.mjs +25 -15
- package/lib/taskRooms.mjs +2 -4
- package/lib/threadActions.mjs +16 -4
- package/lib/threadAuthority.mjs +28 -10
- package/lib/threadRuns.mjs +162 -74
- package/lib/toolCheck.mjs +136 -0
- package/lib/ui.mjs +15 -1
- package/lib/wakes.mjs +3 -3
- package/npm-shrinkwrap.json +14 -14
- package/package.json +4 -4
- package/release.json +64 -55
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// A shared project's board: the one board every person in the project and their agents see, built on each computer
|
|
2
|
+
// from the project's record (projects.mjs), so every copy shows the same cards. It holds:
|
|
3
|
+
// - the project's pieces and the work agents said they are doing (plan_work) as cards, their column, title and holder
|
|
4
|
+
// following the record: an open piece is To do, one held or work under way In progress, work done Review, merged
|
|
5
|
+
// Done; work that clashes is blocked;
|
|
6
|
+
// - the cards agents and people add (update_board, a task handed out in the room): a `card` entry made by the side
|
|
7
|
+
// that added it.
|
|
8
|
+
// The record's rule holds: each side writes only its own entries. A side's changes to a card (its column, note,
|
|
9
|
+
// blocked, its tasks and trail) are one `card-edit` entry of that side's per card, each field stamped with when it was
|
|
10
|
+
// set; every computer reads a field's newest value across all sides, so moves from either side land the same way.
|
|
11
|
+
import { oneLine } from "./oneLine.mjs";
|
|
12
|
+
|
|
13
|
+
export const BOARD_KINDS = ["card", "card-edit"];
|
|
14
|
+
const FIELDS = ["title", "column", "agent", "note", "blocked", "needsYou"];
|
|
15
|
+
// A card from the record is moved by the record: these of its fields are never set on the board.
|
|
16
|
+
const RECORD_FIELDS = new Set(["title", "column", "agent"]);
|
|
17
|
+
const HISTORY_LIMIT = 30;
|
|
18
|
+
const WORK_COLUMNS = {
|
|
19
|
+
checking: "doing",
|
|
20
|
+
unchecked: "doing",
|
|
21
|
+
clear: "doing",
|
|
22
|
+
overlap: "doing",
|
|
23
|
+
clash: "doing",
|
|
24
|
+
review: "review",
|
|
25
|
+
merged: "done",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** The one entry a side keeps for its changes to one card; an entry under another id is not that side's. */
|
|
29
|
+
export const editIdOf = (cardId, side) => `card-edit:${cardId}:${side}`;
|
|
30
|
+
|
|
31
|
+
export function createProjectBoard({ items, write, local, shared, pieces }) {
|
|
32
|
+
const now = () => new Date().toISOString();
|
|
33
|
+
const named = (p, field, value, toShared) =>
|
|
34
|
+
field === "agent" && value
|
|
35
|
+
? toShared
|
|
36
|
+
? shared(p, value)
|
|
37
|
+
: local(p, value)
|
|
38
|
+
: (value ?? null);
|
|
39
|
+
const editsOf = (p) => {
|
|
40
|
+
const byCard = new Map();
|
|
41
|
+
for (const edit of items(p.id, "card-edit")) {
|
|
42
|
+
const cardId = String(edit.body.card ?? "");
|
|
43
|
+
if (edit.id !== editIdOf(cardId, edit.side)) continue;
|
|
44
|
+
byCard.set(cardId, [...(byCard.get(cardId) ?? []), edit]);
|
|
45
|
+
}
|
|
46
|
+
return byCard;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// A card as every side's changes leave it: each field its newest value, every side's tasks and trail together.
|
|
50
|
+
const fold = (p, base, edits) => {
|
|
51
|
+
const newest = {};
|
|
52
|
+
for (const edit of edits)
|
|
53
|
+
for (const [field, change] of Object.entries(edit.body.fields ?? {})) {
|
|
54
|
+
const settable =
|
|
55
|
+
[...FIELDS, "removed"].includes(field) &&
|
|
56
|
+
!(base.derived && RECORD_FIELDS.has(field));
|
|
57
|
+
if (!settable) continue;
|
|
58
|
+
if (!newest[field] || String(change.at) > String(newest[field].at))
|
|
59
|
+
newest[field] = change;
|
|
60
|
+
}
|
|
61
|
+
const card = { ...base };
|
|
62
|
+
for (const [field, change] of Object.entries(newest))
|
|
63
|
+
card[field] = named(p, field, change.value, false);
|
|
64
|
+
card.tasks = [...new Set(edits.flatMap((edit) => edit.body.tasks ?? []))];
|
|
65
|
+
card.history = edits
|
|
66
|
+
.flatMap((edit) =>
|
|
67
|
+
(edit.body.history ?? []).map((entry) => ({
|
|
68
|
+
...entry,
|
|
69
|
+
by: local(p, entry.by),
|
|
70
|
+
}))
|
|
71
|
+
)
|
|
72
|
+
.sort((a, b) => String(a.at).localeCompare(String(b.at)))
|
|
73
|
+
.slice(-HISTORY_LIMIT);
|
|
74
|
+
card.at = [base.at, ...edits.map((edit) => edit.updatedAt)]
|
|
75
|
+
.filter(Boolean)
|
|
76
|
+
.sort()
|
|
77
|
+
.at(-1);
|
|
78
|
+
return card;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const blank = {
|
|
82
|
+
note: null,
|
|
83
|
+
blocked: null,
|
|
84
|
+
needsYou: null,
|
|
85
|
+
tasks: [],
|
|
86
|
+
history: [],
|
|
87
|
+
};
|
|
88
|
+
// The pieces and the work under way, as the record has them.
|
|
89
|
+
const fromRecord = (p) => [
|
|
90
|
+
...pieces.cards(p).map((piece) => ({
|
|
91
|
+
...blank,
|
|
92
|
+
id: piece.id,
|
|
93
|
+
title: oneLine(piece.title, 120),
|
|
94
|
+
column: piece.column,
|
|
95
|
+
agent: piece.owner ? local(p, piece.owner) : null,
|
|
96
|
+
needsYou: piece.offered ? "a person's OK for its handoff" : null,
|
|
97
|
+
by: local(p, piece.by),
|
|
98
|
+
derived: "piece",
|
|
99
|
+
at: piece.at,
|
|
100
|
+
})),
|
|
101
|
+
...items(p.id, "work")
|
|
102
|
+
.filter((work) => !work.body.piece && WORK_COLUMNS[work.body.status])
|
|
103
|
+
.map((work) => {
|
|
104
|
+
const agent = local(p, `${work.side}/${work.body.agent}`);
|
|
105
|
+
const clash = work.body.status === "clash";
|
|
106
|
+
return {
|
|
107
|
+
...blank,
|
|
108
|
+
id: work.id,
|
|
109
|
+
title: oneLine(work.body.summary, 120),
|
|
110
|
+
column: WORK_COLUMNS[work.body.status],
|
|
111
|
+
agent,
|
|
112
|
+
blocked: clash
|
|
113
|
+
? oneLine(
|
|
114
|
+
`clashes with other work${work.body.check?.reason ? `: ${work.body.check.reason}` : ""}`,
|
|
115
|
+
240
|
|
116
|
+
)
|
|
117
|
+
: null,
|
|
118
|
+
by: agent,
|
|
119
|
+
derived: "work",
|
|
120
|
+
at: work.at,
|
|
121
|
+
};
|
|
122
|
+
}),
|
|
123
|
+
];
|
|
124
|
+
const added = (p) =>
|
|
125
|
+
items(p.id, "card").map((entry) => ({
|
|
126
|
+
...blank,
|
|
127
|
+
id: entry.id,
|
|
128
|
+
title: oneLine(entry.body.title, 120),
|
|
129
|
+
column: "todo",
|
|
130
|
+
agent: null,
|
|
131
|
+
by: local(p, entry.body.by ?? `${entry.side}/person`),
|
|
132
|
+
auto: Boolean(entry.body.auto),
|
|
133
|
+
at: entry.at,
|
|
134
|
+
}));
|
|
135
|
+
const every = (p) => {
|
|
136
|
+
const edits = editsOf(p);
|
|
137
|
+
return [...fromRecord(p), ...added(p)].map((card) =>
|
|
138
|
+
fold(p, card, edits.get(card.id) ?? [])
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/** The board's cards, as on every computer in the project. */
|
|
143
|
+
const load = (p) => every(p).filter((card) => !card.removed);
|
|
144
|
+
|
|
145
|
+
/** The cards as this side left them: what it added and changed becomes its own entries, and goes across. */
|
|
146
|
+
const save = (p, cards) => {
|
|
147
|
+
const before = new Map(every(p).map((card) => [card.id, card]));
|
|
148
|
+
const edits = editsOf(p);
|
|
149
|
+
const at = now();
|
|
150
|
+
const record = (card, changes, history, tasks) => {
|
|
151
|
+
const id = editIdOf(card.id, p.me);
|
|
152
|
+
const mine = (edits.get(card.id) ?? []).find((edit) => edit.id === id);
|
|
153
|
+
write(
|
|
154
|
+
p,
|
|
155
|
+
"card-edit",
|
|
156
|
+
{
|
|
157
|
+
card: card.id,
|
|
158
|
+
fields: { ...(mine?.body.fields ?? {}), ...changes },
|
|
159
|
+
history: [
|
|
160
|
+
...(mine?.body.history ?? []),
|
|
161
|
+
...history.map((entry) => ({ ...entry, by: shared(p, entry.by) })),
|
|
162
|
+
].slice(-HISTORY_LIMIT),
|
|
163
|
+
tasks,
|
|
164
|
+
},
|
|
165
|
+
id
|
|
166
|
+
);
|
|
167
|
+
};
|
|
168
|
+
for (const card of cards) {
|
|
169
|
+
const was = before.get(card.id);
|
|
170
|
+
if (!was)
|
|
171
|
+
write(
|
|
172
|
+
p,
|
|
173
|
+
"card",
|
|
174
|
+
{
|
|
175
|
+
title: card.title,
|
|
176
|
+
by: shared(p, card.by ?? "user"),
|
|
177
|
+
auto: Boolean(card.auto),
|
|
178
|
+
},
|
|
179
|
+
card.id
|
|
180
|
+
);
|
|
181
|
+
const start = was ?? { ...card, ...blank, column: "todo", agent: null };
|
|
182
|
+
const changes = {};
|
|
183
|
+
for (const field of FIELDS) {
|
|
184
|
+
if (card.derived && RECORD_FIELDS.has(field)) continue;
|
|
185
|
+
const value = card[field] ?? null;
|
|
186
|
+
if (JSON.stringify(value) === JSON.stringify(start[field] ?? null))
|
|
187
|
+
continue;
|
|
188
|
+
changes[field] = { value: named(p, field, value, true), at };
|
|
189
|
+
}
|
|
190
|
+
const seen = new Set(
|
|
191
|
+
(was?.history ?? []).map((entry) => `${entry.at}|${entry.text}`)
|
|
192
|
+
);
|
|
193
|
+
const history = (card.history ?? []).filter(
|
|
194
|
+
(entry) => !seen.has(`${entry.at}|${entry.text}`)
|
|
195
|
+
);
|
|
196
|
+
// Tasks are each side's own: another side's task ids stay in its entry.
|
|
197
|
+
const theirs = new Set(
|
|
198
|
+
(edits.get(card.id) ?? [])
|
|
199
|
+
.filter((edit) => edit.side !== p.me)
|
|
200
|
+
.flatMap((edit) => edit.body.tasks ?? [])
|
|
201
|
+
);
|
|
202
|
+
const tasks = (card.tasks ?? []).filter((id) => !theirs.has(id));
|
|
203
|
+
const mineBefore = (was?.tasks ?? []).filter((id) => !theirs.has(id));
|
|
204
|
+
const tasksChanged = JSON.stringify(tasks) !== JSON.stringify(mineBefore);
|
|
205
|
+
if (Object.keys(changes).length || history.length || tasksChanged)
|
|
206
|
+
record(card, changes, history, tasks);
|
|
207
|
+
}
|
|
208
|
+
const kept = new Set(cards.map((card) => card.id));
|
|
209
|
+
for (const [id, was] of before) {
|
|
210
|
+
if (kept.has(id) || was.removed || was.derived) continue;
|
|
211
|
+
const mine = (edits.get(id) ?? [])
|
|
212
|
+
.filter((edit) => edit.side === p.me)
|
|
213
|
+
.flatMap((edit) => edit.body.tasks ?? []);
|
|
214
|
+
record(was, { removed: { value: true, at } }, [], mine);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
return { load, save };
|
|
219
|
+
}
|
package/lib/projectPieces.mjs
CHANGED
|
@@ -871,12 +871,38 @@ export function createPieces({
|
|
|
871
871
|
return item(id);
|
|
872
872
|
};
|
|
873
873
|
|
|
874
|
+
/** The pieces as the project's board shows them (projectBoard.mjs), read without changing anything. */
|
|
875
|
+
const cards = (p) =>
|
|
876
|
+
items(p.id, "piece")
|
|
877
|
+
.filter((piece) => !piece.body.withdrawn)
|
|
878
|
+
.map((piece) => {
|
|
879
|
+
const state = stateOf(p, piece.id);
|
|
880
|
+
const done = doneOf(p, piece.id);
|
|
881
|
+
const column = done
|
|
882
|
+
? done.body.status === "merged"
|
|
883
|
+
? "done"
|
|
884
|
+
: "review"
|
|
885
|
+
: state.owner
|
|
886
|
+
? "doing"
|
|
887
|
+
: "todo";
|
|
888
|
+
return {
|
|
889
|
+
id: piece.id,
|
|
890
|
+
title: piece.body.summary,
|
|
891
|
+
column,
|
|
892
|
+
owner: state.owner,
|
|
893
|
+
offered: Boolean(state.offered),
|
|
894
|
+
by: piece.body.by ?? `${piece.side}/person`,
|
|
895
|
+
at: piece.at,
|
|
896
|
+
};
|
|
897
|
+
});
|
|
898
|
+
|
|
874
899
|
return {
|
|
875
900
|
changed,
|
|
876
901
|
accepted,
|
|
877
902
|
declined,
|
|
878
903
|
command,
|
|
879
904
|
view,
|
|
905
|
+
cards,
|
|
880
906
|
strengthsOf,
|
|
881
907
|
brief,
|
|
882
908
|
refresh,
|
package/lib/projects.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { DISPATCHER, nameOf } from "./members.mjs";
|
|
|
5
5
|
import { secretReason } from "./secrets.mjs";
|
|
6
6
|
import { createRoomChannels, agreementHash } from "./roomChannels.mjs";
|
|
7
7
|
import { createPieces, RECORD_KINDS } from "./projectPieces.mjs";
|
|
8
|
+
import { BOARD_KINDS, createProjectBoard, editIdOf } from "./projectBoard.mjs";
|
|
8
9
|
import {
|
|
9
10
|
SETTINGS,
|
|
10
11
|
SETTING_KEYS,
|
|
@@ -782,7 +783,8 @@ export function createProjects({
|
|
|
782
783
|
`${p.partner} left the project. This room stays here; nothing more goes between you.`
|
|
783
784
|
);
|
|
784
785
|
notifyDesktop(
|
|
785
|
-
`${p.partner} left the project "${oneLine(p.title, 60)}"
|
|
786
|
+
`${p.partner} left the project "${oneLine(p.title, 60)}".`,
|
|
787
|
+
{ thread: p.roomId }
|
|
786
788
|
);
|
|
787
789
|
}
|
|
788
790
|
return { ok: true };
|
|
@@ -932,9 +934,16 @@ export function createProjects({
|
|
|
932
934
|
"setting",
|
|
933
935
|
"note",
|
|
934
936
|
...RECORD_KINDS,
|
|
937
|
+
...BOARD_KINDS,
|
|
935
938
|
].includes(entry.kind)
|
|
936
939
|
)
|
|
937
940
|
return { ok: true };
|
|
941
|
+
// A side's changes to a card are its one entry for that card; under another id it could stand in for another's.
|
|
942
|
+
if (
|
|
943
|
+
entry.kind === "card-edit" &&
|
|
944
|
+
entry.id !== editIdOf(entry.body?.card, entry.side)
|
|
945
|
+
)
|
|
946
|
+
return { ok: false, error: "a card's changes in the wrong place" };
|
|
938
947
|
// An answer is its side's own entry for one proposal; one under another id could stand in for this person's.
|
|
939
948
|
if (
|
|
940
949
|
entry.kind === "answer" &&
|
|
@@ -1378,7 +1387,8 @@ export function createProjects({
|
|
|
1378
1387
|
[work.id, ...result.with]
|
|
1379
1388
|
);
|
|
1380
1389
|
notifyDesktop(
|
|
1381
|
-
`Work clashes in "${oneLine(p.title, 60)}": ${nameOf(agent)} waits while the agents settle it
|
|
1390
|
+
`Work clashes in "${oneLine(p.title, 60)}": ${nameOf(agent)} waits while the agents settle it.`,
|
|
1391
|
+
{ thread: p.roomId }
|
|
1382
1392
|
);
|
|
1383
1393
|
start(
|
|
1384
1394
|
"review",
|
|
@@ -1833,7 +1843,12 @@ export function createProjects({
|
|
|
1833
1843
|
opened,
|
|
1834
1844
|
`${opened.partner} joined. Their agents work here with yours from now on.`
|
|
1835
1845
|
);
|
|
1836
|
-
notifyDesktop(
|
|
1846
|
+
notifyDesktop(
|
|
1847
|
+
`${opened.partner} joined "${oneLine(opened.title, 60)}".`,
|
|
1848
|
+
{
|
|
1849
|
+
thread: opened.roomId,
|
|
1850
|
+
}
|
|
1851
|
+
);
|
|
1837
1852
|
} else
|
|
1838
1853
|
note(
|
|
1839
1854
|
opened,
|
|
@@ -1855,7 +1870,9 @@ export function createProjects({
|
|
|
1855
1870
|
project(p.id),
|
|
1856
1871
|
`${p.partner} left the project. This room stays here; nothing more goes between you.`
|
|
1857
1872
|
);
|
|
1858
|
-
notifyDesktop(`${p.partner} left the project "${oneLine(p.title, 60)}"
|
|
1873
|
+
notifyDesktop(`${p.partner} left the project "${oneLine(p.title, 60)}".`, {
|
|
1874
|
+
thread: p.roomId,
|
|
1875
|
+
});
|
|
1859
1876
|
};
|
|
1860
1877
|
|
|
1861
1878
|
const leave = (p) => {
|
|
@@ -2423,6 +2440,8 @@ export function createProjects({
|
|
|
2423
2440
|
changedFiles,
|
|
2424
2441
|
branchSlug,
|
|
2425
2442
|
});
|
|
2443
|
+
// The project's one board, the same on every computer in it (projectBoard.mjs).
|
|
2444
|
+
const board = createProjectBoard({ items, write, local, shared, pieces });
|
|
2426
2445
|
|
|
2427
2446
|
// ---- the board commands ----
|
|
2428
2447
|
|
|
@@ -2494,6 +2513,11 @@ export function createProjects({
|
|
|
2494
2513
|
)?.status === "joining",
|
|
2495
2514
|
title: invite.project.title,
|
|
2496
2515
|
from: invite.project.from,
|
|
2516
|
+
at: invite.createdAt ?? null,
|
|
2517
|
+
// Who comes with the person inviting, by name: a computer on an older version says nothing here.
|
|
2518
|
+
theirAgents: channels
|
|
2519
|
+
.knownAgents(invite.project.agents)
|
|
2520
|
+
.map(nameOf),
|
|
2497
2521
|
// The sender's computer's key, to compare with them before joining (pinned only on joining).
|
|
2498
2522
|
fingerprint: invite.fingerprint ?? null,
|
|
2499
2523
|
kind: invite.project.repo?.first ? "project" : "room",
|
|
@@ -2799,6 +2823,15 @@ export function createProjects({
|
|
|
2799
2823
|
learned,
|
|
2800
2824
|
refresh,
|
|
2801
2825
|
isProjectRoom: (goalId) => Boolean(projectOfRoom(goalId)),
|
|
2826
|
+
/** A project room's board, kept in the project's record so every computer in it shows the same cards. */
|
|
2827
|
+
boardOf: (goalId) => {
|
|
2828
|
+
const p = projectOfRoom(goalId);
|
|
2829
|
+
if (!p) return null;
|
|
2830
|
+
return {
|
|
2831
|
+
load: () => board.load(project(p.id)),
|
|
2832
|
+
save: (cards) => board.save(project(p.id), cards),
|
|
2833
|
+
};
|
|
2834
|
+
},
|
|
2802
2835
|
/**
|
|
2803
2836
|
* What a project's room waits on the person for, as the thread's needs-you items: an OK the other side or an agent
|
|
2804
2837
|
* asked for (agree), and an agent's post kept here until the person shares it (share).
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { removeAgentConfigurations } from "./adapters.mjs";
|
|
4
|
+
import { detectAgents } from "./commands.mjs";
|
|
5
|
+
import { uninstallDesktop } from "./desktop.mjs";
|
|
6
|
+
import { readJson, writeJsonAtomic } from "./files.mjs";
|
|
7
|
+
import { removeNativeHost } from "./nativeHost.mjs";
|
|
8
|
+
import { uninstallService } from "./service.mjs";
|
|
9
|
+
import { removeLocalWakes } from "./wakes.mjs";
|
|
10
|
+
|
|
11
|
+
// Taking Harness off this computer: `tryharness uninstall`, and stopping setup before signing in (Ctrl-C in the
|
|
12
|
+
// installer, or Remove Harness in the setup window), which must leave nothing behind.
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Remove what Harness set up here: the app and its login items, the browser's link to this computer, Harness in the
|
|
16
|
+
* person's agents, local wakes and what setup downloaded. The person's own things (board, history, keys, choices)
|
|
17
|
+
* stay unless `everything`; a Harness folder holding none of them, as before the first sign-in, goes whole.
|
|
18
|
+
* `agents` limits the agents undone to those setup changed (all when omitted). The background service goes after the
|
|
19
|
+
* app when `stopService`; otherwise it is the caller's to stop, since it may be the caller. Returns whether the
|
|
20
|
+
* folder went.
|
|
21
|
+
*/
|
|
22
|
+
export function removeHarnessHere({
|
|
23
|
+
paths,
|
|
24
|
+
everything = false,
|
|
25
|
+
agents = null,
|
|
26
|
+
stopService = false,
|
|
27
|
+
}) {
|
|
28
|
+
// The app first, so its window goes the moment someone backs out, before the slower steps below.
|
|
29
|
+
uninstallDesktop();
|
|
30
|
+
if (stopService) uninstallService();
|
|
31
|
+
removeNativeHost();
|
|
32
|
+
undoAgents(agents);
|
|
33
|
+
const nothingOfTheirs = !fs.existsSync(paths.database);
|
|
34
|
+
const wholeFolder = everything || nothingOfTheirs;
|
|
35
|
+
const removed = wholeFolder
|
|
36
|
+
? [paths.home]
|
|
37
|
+
: [...downloadedParts(paths), paths.status, paths.socket];
|
|
38
|
+
for (const target of removed)
|
|
39
|
+
try {
|
|
40
|
+
fs.rmSync(target, { recursive: true, force: true });
|
|
41
|
+
} catch {}
|
|
42
|
+
if (!wholeFolder) keepChoicesOnly(paths.config);
|
|
43
|
+
return { folderRemoved: wholeFolder };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Stop setup before sign-in from the daemon itself: everything goes, the service last, because stopping it ends us. */
|
|
47
|
+
export function stopSetupHere({ paths }) {
|
|
48
|
+
const result = removeHarnessHere({ paths, agents: chosenAgents(paths) });
|
|
49
|
+
uninstallService();
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The agents setup set up before sign-in: the ones the person chose on an earlier install, if any. */
|
|
54
|
+
export function chosenAgents(paths) {
|
|
55
|
+
return readJson(paths.config, {}).swarmAgents ?? [];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Each agent's Harness setup is undone through its own CLI, a second or so apiece, so only the ones changed are.
|
|
59
|
+
function undoAgents(agents) {
|
|
60
|
+
if (agents === null) {
|
|
61
|
+
removeAgentConfigurations();
|
|
62
|
+
removeLocalWakes();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (!agents.length) return;
|
|
66
|
+
removeAgentConfigurations({
|
|
67
|
+
detected: detectAgents().filter((found) => agents.includes(found.agent)),
|
|
68
|
+
});
|
|
69
|
+
if (agents.some((agent) => LOCAL_WAKE_AGENTS.includes(agent)))
|
|
70
|
+
removeLocalWakes();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// The agents woken through their own local setup (wakes.mjs).
|
|
74
|
+
const LOCAL_WAKE_AGENTS = ["openclaw", "hermes"];
|
|
75
|
+
|
|
76
|
+
// What setup downloaded into the Harness folder: the daemon's runtime, its command, local models and their engine.
|
|
77
|
+
function downloadedParts(paths) {
|
|
78
|
+
return [
|
|
79
|
+
paths.runtime,
|
|
80
|
+
path.join(paths.home, "bin"),
|
|
81
|
+
paths.models,
|
|
82
|
+
path.join(paths.home, "local"),
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// The pairing goes; the person's choices stay (who is in their swarm, who they took out), so setting up again keeps
|
|
87
|
+
// their swarm (a reinstall once came back without Bankr, Quotient, Grok Bot and Muse).
|
|
88
|
+
function keepChoicesOnly(configPath) {
|
|
89
|
+
const { token: _token, ...choices } = readJson(configPath, {});
|
|
90
|
+
if (Object.keys(choices).length) writeJsonAtomic(configPath, choices);
|
|
91
|
+
}
|
package/lib/roomChannels.mjs
CHANGED
|
@@ -181,6 +181,7 @@ export function createRoomChannels({
|
|
|
181
181
|
settings: room.settings,
|
|
182
182
|
history: room.history,
|
|
183
183
|
members: room.members,
|
|
184
|
+
agents: room.agents,
|
|
184
185
|
...details(room.id),
|
|
185
186
|
});
|
|
186
187
|
const sending = new Set();
|
|
@@ -643,6 +644,7 @@ export function createRoomChannels({
|
|
|
643
644
|
invite,
|
|
644
645
|
// Whether an invitation names its real sender and this person, as join requires; throws why not.
|
|
645
646
|
validate: validateInvite,
|
|
647
|
+
knownAgents,
|
|
646
648
|
join,
|
|
647
649
|
setAgents,
|
|
648
650
|
opened,
|
package/lib/runAuthority.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
nameOf,
|
|
12
12
|
speaksThroughHarness,
|
|
13
13
|
} from "./members.mjs";
|
|
14
|
+
import { FROM_MACHINE } from "./machineRoutes.mjs";
|
|
14
15
|
import { runCapability, runningPids } from "./runner.mjs";
|
|
15
16
|
import {
|
|
16
17
|
descendsFrom,
|
|
@@ -30,9 +31,19 @@ export const RUN_CALLER = Symbol("the run that called");
|
|
|
30
31
|
// for an agent whose run posts work again could go on forever. Past this many hand-offs in a row with no word from the
|
|
31
32
|
// person, the next one waits for their Start. In place of a daily limit the person never set.
|
|
32
33
|
export const MAX_HANDOFFS = 10;
|
|
34
|
+
/**
|
|
35
|
+
* The run that made a call, { id, review, restricted }, or null: one Harness started on this computer (checkCaller),
|
|
36
|
+
* or one on another of the person's computers, as that computer sealed it with the call (ownMachines.mjs callHome).
|
|
37
|
+
* Only a call home opened from another computer carries FROM_MACHINE, so no local caller can name a run here.
|
|
38
|
+
*/
|
|
39
|
+
export const callerRun = (request) => {
|
|
40
|
+
if (request?.[RUN_CALLER]) return request[RUN_CALLER];
|
|
41
|
+
const sealed = request?.[FROM_MACHINE] !== undefined ? request.fromRun : null;
|
|
42
|
+
return sealed && typeof sealed === "object" ? sealed : null;
|
|
43
|
+
};
|
|
33
44
|
/** How the run that made a call was held in, so what it asks for is held in too: "review", "restricted" or null. */
|
|
34
45
|
export const callerLimit = (request) => {
|
|
35
|
-
const run = request
|
|
46
|
+
const run = callerRun(request);
|
|
36
47
|
return run?.review ? "review" : run?.restricted ? "restricted" : null;
|
|
37
48
|
};
|
|
38
49
|
/** Whether a call came from a run that may not act on the person's go: a restricted run or a read-only review. */
|
|
@@ -244,26 +255,29 @@ export function createRunAuthority({ store, installedAgents }) {
|
|
|
244
255
|
|
|
245
256
|
// Why an ask from one of the person's own agents cannot use a standing permission at all, or null. `hosted`: it came
|
|
246
257
|
// from Harness's server itself (HOSTED_CALLER), never a local process or another computer; `here`: from a process on
|
|
247
|
-
// this computer, claiming no Harness origin. Each agent's ask must come the one way that agent speaks. The guard's flag
|
|
258
|
+
// this computer or another the person drives, claiming no Harness origin. Each agent's ask must come the one way that agent speaks. The guard's flag
|
|
248
259
|
// is a label for readers (it cannot tell the person's agents coordinating from planted orders); words it reads as
|
|
249
260
|
// orders aimed at the person's agents wait for the person, as do words through Harness's server it could not read
|
|
250
261
|
// (security audit S4): that is where planted instructions would reach for their secrets. An agent on this computer
|
|
251
|
-
// needs no reading, as in a thread (threadAuthority.mjs personsGo)
|
|
262
|
+
// or another the person drives needs no reading, as in a thread (threadAuthority.mjs personsGo); one on a cloud
|
|
263
|
+
// computer Harness runs for them (`cloud`) is read like words through Harness's server.
|
|
252
264
|
const askRefusal = (ask) => {
|
|
253
265
|
const proposer = String(ask?.proposer ?? "");
|
|
266
|
+
const read = speaksThroughHarness(proposer) || ask?.cloud === true;
|
|
254
267
|
return !PROPOSERS.includes(proposer)
|
|
255
268
|
? `${nameOf(proposer)} is not one of your own agents that may start it.`
|
|
256
269
|
: speaksThroughHarness(proposer) && (ask.hosted !== true || ask.window)
|
|
257
270
|
? `${nameOf(proposer)}'s ask did not come through Harness as its asks do.`
|
|
258
271
|
: !speaksThroughHarness(proposer) &&
|
|
259
|
-
(ask.hosted === true ||
|
|
260
|
-
|
|
272
|
+
(ask.hosted === true ||
|
|
273
|
+
(ask.here !== true && ask.cloud !== true) ||
|
|
274
|
+
ask.window)
|
|
275
|
+
? `${nameOf(proposer)}'s ask did not come from one of your computers as its asks do.`
|
|
261
276
|
: ask.limited
|
|
262
277
|
? `${nameOf(proposer)} asked from a held-in run.`
|
|
263
|
-
:
|
|
264
|
-
(!ask.guard || ask.guard.unavailable)
|
|
278
|
+
: read && (!ask.guard || ask.guard.unavailable)
|
|
265
279
|
? `the guard on this computer could not read ${nameOf(proposer)}'s words.`
|
|
266
|
-
: ask.guard
|
|
280
|
+
: ask.guard?.verdict === "hold"
|
|
267
281
|
? `the guard on this computer read ${nameOf(proposer)}'s words as orders aimed at your agents.`
|
|
268
282
|
: (ask.handoffs ?? 0) > MAX_HANDOFFS
|
|
269
283
|
? `your agents have handed this work on ${MAX_HANDOFFS} times in a row without you, so a loop cannot run on its own.`
|
|
@@ -302,7 +316,7 @@ export function createRunAuthority({ store, installedAgents }) {
|
|
|
302
316
|
* It counts as one of the agent's standing runs and keeps the agent-written label; the thread's own folder is the one
|
|
303
317
|
* checked (null: a fresh scratch folder of the thread's, which holds nothing of the person's).
|
|
304
318
|
*
|
|
305
|
-
* `ask`: { proposer, hosted, here, guard, limited, window, handoffs }, as the thread heard it. Returns { started } or { started:
|
|
319
|
+
* `ask`: { proposer, hosted, here, cloud, guard, limited, window, handoffs }, as the thread heard it. Returns { started } or { started:
|
|
306
320
|
* false, reason }, the reason ending "<agent> waits for your Start: ".
|
|
307
321
|
*/
|
|
308
322
|
const admitProposed = (wake, ask, folder) => {
|
package/lib/runBrief.mjs
CHANGED
|
@@ -179,6 +179,8 @@ export function createRunBriefs({
|
|
|
179
179
|
const refs = task.context_refs.map(
|
|
180
180
|
(ref) => `- ${ref.kind}: ${ref.ref}${ref.note ? ` (${ref.note})` : ""}`
|
|
181
181
|
);
|
|
182
|
+
// Every run in a thread, its turns too, starts from the thread's board: it is where the thread's work is managed.
|
|
183
|
+
const thread = task.parent_id ? store.getTask(task.parent_id) : null;
|
|
182
184
|
return [
|
|
183
185
|
{
|
|
184
186
|
name: "provenance",
|
|
@@ -186,6 +188,16 @@ export function createRunBriefs({
|
|
|
186
188
|
source: "who wrote the task",
|
|
187
189
|
text: provenanceLine(task, person?.displayName),
|
|
188
190
|
},
|
|
191
|
+
...(thread?.kind === "goal"
|
|
192
|
+
? [
|
|
193
|
+
{
|
|
194
|
+
name: "thread board",
|
|
195
|
+
priority: "core",
|
|
196
|
+
source: `thread ${thread.id}`,
|
|
197
|
+
text: boardBrief(thread.id),
|
|
198
|
+
},
|
|
199
|
+
]
|
|
200
|
+
: []),
|
|
189
201
|
{
|
|
190
202
|
name: "objective",
|
|
191
203
|
priority: "core",
|
|
@@ -205,18 +217,7 @@ export function createRunBriefs({
|
|
|
205
217
|
text: refs.length ? `Context:\n${refs.join("\n")}` : "",
|
|
206
218
|
pointer: `Context: ${refs.length} reference${refs.length === 1 ? "" : "s"}; get_task ${task.id} lists them.`,
|
|
207
219
|
},
|
|
208
|
-
...(room?.kind === "goal"
|
|
209
|
-
? [
|
|
210
|
-
roomSection(room, agent),
|
|
211
|
-
{
|
|
212
|
-
name: "thread board",
|
|
213
|
-
priority: "recommended",
|
|
214
|
-
source: `thread ${room.id}`,
|
|
215
|
-
text: boardBrief(room.id),
|
|
216
|
-
pointer: `This thread has a board of cards the person follows its work on: keep yours current with update_board (thread ${room.id}).`,
|
|
217
|
-
},
|
|
218
|
-
]
|
|
219
|
-
: []),
|
|
220
|
+
...(room?.kind === "goal" ? [roomSection(room, agent)] : []),
|
|
220
221
|
// Who the agent works for, from the profile setup imported (profile.mjs); like lessons, only for agents here.
|
|
221
222
|
{
|
|
222
223
|
name: "the person",
|
|
@@ -335,6 +336,11 @@ export function createRunBriefs({
|
|
|
335
336
|
const memory = await memoryNotes(task, wake, dryRun);
|
|
336
337
|
const local = await localContext(task, agent, { wake, room, dryRun });
|
|
337
338
|
const body = sectionsFor({ task, agent, wake, room, local, memory });
|
|
339
|
+
// The earlier session's words follow what the run is asked.
|
|
340
|
+
const asked =
|
|
341
|
+
body.findIndex((section) =>
|
|
342
|
+
["brief", "wake brief"].includes(section.name)
|
|
343
|
+
) + 1;
|
|
338
344
|
sections = [
|
|
339
345
|
{
|
|
340
346
|
name: "T3 catch-up",
|
|
@@ -343,7 +349,7 @@ export function createRunBriefs({
|
|
|
343
349
|
text: t3 && task.parent_id ? t3CatchUp(task.parent_id, agent) : "",
|
|
344
350
|
},
|
|
345
351
|
...notes,
|
|
346
|
-
...body.slice(0,
|
|
352
|
+
...body.slice(0, asked),
|
|
347
353
|
...(handed
|
|
348
354
|
? [
|
|
349
355
|
{
|
|
@@ -354,7 +360,7 @@ export function createRunBriefs({
|
|
|
354
360
|
},
|
|
355
361
|
]
|
|
356
362
|
: []),
|
|
357
|
-
...body.slice(
|
|
363
|
+
...body.slice(asked),
|
|
358
364
|
];
|
|
359
365
|
}
|
|
360
366
|
const fitted = fitSections(sections, BRIEF_BUDGET);
|
package/lib/runner.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { agentEnvironment } from "./agentnode.mjs";
|
|
|
9
9
|
import { runtimeOf } from "./agentRuntimeConfig.mjs";
|
|
10
10
|
import { runProtocolTask } from "./agentRuntimes.mjs";
|
|
11
11
|
import { scrubValues } from "./vault.mjs";
|
|
12
|
-
import { historyRoots, paths } from "./paths.mjs";
|
|
12
|
+
import { harnessNode, historyRoots, paths } from "./paths.mjs";
|
|
13
13
|
|
|
14
14
|
const running = new Set();
|
|
15
15
|
const children = new Map();
|
|
@@ -312,7 +312,7 @@ export const restrictedClaudeSettings = (cwd, home = os.homedir()) => ({
|
|
|
312
312
|
export const restrictedMcpConfig = () => ({
|
|
313
313
|
mcpServers: {
|
|
314
314
|
harness: {
|
|
315
|
-
command:
|
|
315
|
+
command: harnessNode(),
|
|
316
316
|
args: [
|
|
317
317
|
fileURLToPath(new URL("./mcp-stdio.mjs", import.meta.url)),
|
|
318
318
|
"--agent",
|
|
@@ -554,7 +554,7 @@ export function agentInvocation(task, { executable = null } = {}) {
|
|
|
554
554
|
'approval_policy="never"',
|
|
555
555
|
// Only Harness's board, as for restricted Claude Code: none of the person's other MCP servers.
|
|
556
556
|
"-c",
|
|
557
|
-
`mcp_servers={harness={command=${JSON.stringify(
|
|
557
|
+
`mcp_servers={harness={command=${JSON.stringify(harnessNode())},args=${JSON.stringify([fileURLToPath(new URL("./mcp-stdio.mjs", import.meta.url)), "--agent", "codex", "--restricted"])}}}`,
|
|
558
558
|
"-c",
|
|
559
559
|
'mcp_servers.harness.default_tools_approval_mode="approve"',
|
|
560
560
|
]
|