tryharness 0.7.78 → 0.7.81
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/boardProtocol.json +4 -0
- package/lib/coordinator.mjs +0 -2
- package/lib/daemon.mjs +28 -2
- package/lib/goalCommands.mjs +16 -7
- package/lib/kanban.mjs +217 -48
- package/lib/machineRoutes.mjs +9 -0
- package/lib/machineRuns.mjs +9 -1
- package/lib/manager.mjs +60 -2
- package/lib/mcp-stdio.mjs +3 -3
- package/lib/network.mjs +19 -0
- package/lib/ownMachines.mjs +91 -43
- package/lib/peopleBoard.mjs +131 -0
- package/lib/phones.mjs +1 -0
- package/lib/projectBoard.mjs +219 -0
- package/lib/projectPieces.mjs +26 -0
- package/lib/projects.mjs +19 -0
- package/lib/runAuthority.mjs +23 -9
- package/lib/runBrief.mjs +20 -14
- package/lib/store.mjs +6 -3
- package/lib/swarm.mjs +181 -61
- package/lib/taskCommands.mjs +25 -15
- package/lib/taskRooms.mjs +2 -4
- package/lib/threadActions.mjs +14 -3
- package/lib/threadAuthority.mjs +28 -10
- package/lib/threadRuns.mjs +162 -74
- package/npm-shrinkwrap.json +14 -14
- package/package.json +4 -4
- package/release.json +29 -27
package/lib/boardProtocol.json
CHANGED
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
"board.relay.decide": "relay",
|
|
97
97
|
"board.relay.defaults": "relay",
|
|
98
98
|
"board.relay.list": "relay",
|
|
99
|
+
"board.relay.board": "relay",
|
|
99
100
|
"board.relay.network": "relay",
|
|
100
101
|
"board.relay.peers": "relay",
|
|
101
102
|
"board.relay.request": "relay",
|
|
@@ -362,6 +363,7 @@
|
|
|
362
363
|
"board.template.save",
|
|
363
364
|
"board.template.use",
|
|
364
365
|
"board.relay.list",
|
|
366
|
+
"board.relay.board",
|
|
365
367
|
"board.relay.network",
|
|
366
368
|
"board.relay.decide",
|
|
367
369
|
"board.relay.request",
|
|
@@ -446,6 +448,7 @@
|
|
|
446
448
|
"board.standing.check",
|
|
447
449
|
"board.standing.off",
|
|
448
450
|
"board.relay.list",
|
|
451
|
+
"board.relay.board",
|
|
449
452
|
"board.relay.network",
|
|
450
453
|
"board.relay.decide",
|
|
451
454
|
"board.relay.request",
|
|
@@ -678,6 +681,7 @@
|
|
|
678
681
|
"board.file.get",
|
|
679
682
|
"board.file.share",
|
|
680
683
|
"board.relay.list",
|
|
684
|
+
"board.relay.board",
|
|
681
685
|
"board.relay.network",
|
|
682
686
|
"board.relay.decide",
|
|
683
687
|
"board.relay.request",
|
package/lib/coordinator.mjs
CHANGED
|
@@ -1819,8 +1819,6 @@ export function createCoordinator({
|
|
|
1819
1819
|
store.threadRuns(goalId).some(going) ||
|
|
1820
1820
|
hostedAtWork(goalId).length > 0 ||
|
|
1821
1821
|
busyInT3(thread).length > 0;
|
|
1822
|
-
// A thread started through Harness by an agent that runs elsewhere gets no rounds until the person sets a spend ceiling.
|
|
1823
|
-
if (store.meta(`hosted-thread:${goalId}`)) return;
|
|
1824
1822
|
const local = mode() === "local";
|
|
1825
1823
|
const seenUpTo = () =>
|
|
1826
1824
|
store.roomPosts(goalId, 0, 500).at(-1)?.seq ?? state.lastSeenSeq;
|
package/lib/daemon.mjs
CHANGED
|
@@ -816,6 +816,8 @@ export async function startDaemon() {
|
|
|
816
816
|
store,
|
|
817
817
|
log,
|
|
818
818
|
onChange: (threadId) => notifyBoard(store.getTask(threadId)),
|
|
819
|
+
// A shared project's room keeps its board in the project's record, the same on every computer in it.
|
|
820
|
+
shared: (threadId) => projects?.boardOf(threadId) ?? null,
|
|
819
821
|
});
|
|
820
822
|
const notifyBoard = (task) => {
|
|
821
823
|
if (!task) return;
|
|
@@ -1335,6 +1337,8 @@ export async function startDaemon() {
|
|
|
1335
1337
|
dispatcher,
|
|
1336
1338
|
goals,
|
|
1337
1339
|
settled: (threadId) => coordinator.resumed(threadId),
|
|
1340
|
+
computerAddress: actions.computerAddress,
|
|
1341
|
+
agentsIn: (text) => mentionsIn(text, ROOM_AGENTS),
|
|
1338
1342
|
handOn: handOnAgent,
|
|
1339
1343
|
post: (entry) => {
|
|
1340
1344
|
const posted = store.roomPost(entry);
|
|
@@ -1449,6 +1453,7 @@ export async function startDaemon() {
|
|
|
1449
1453
|
void memory.heard(thread, post);
|
|
1450
1454
|
};
|
|
1451
1455
|
const goalCommand = createGoalCommands({
|
|
1456
|
+
boardView: (threadId) => kanban.view(threadId),
|
|
1452
1457
|
heardRelayed: (thread, post) => void manager.heard(thread, post),
|
|
1453
1458
|
computerOf,
|
|
1454
1459
|
teams,
|
|
@@ -1991,6 +1996,7 @@ export async function startDaemon() {
|
|
|
1991
1996
|
goalCommand,
|
|
1992
1997
|
stopThreadRuns,
|
|
1993
1998
|
steered: (goalId, agent) => threadRuns.steered(goalId, agent),
|
|
1999
|
+
computerOfRun: (run) => threadRuns.computerOfRun(run),
|
|
1994
2000
|
runningPids,
|
|
1995
2001
|
provenanceFor,
|
|
1996
2002
|
runLog: (runId) => taskFiles(runId).log,
|
|
@@ -2012,6 +2018,17 @@ export async function startDaemon() {
|
|
|
2012
2018
|
available().map((id) => ({ id, about: aboutOf(id), setup: setupOf(id) })),
|
|
2013
2019
|
worktrees,
|
|
2014
2020
|
folders,
|
|
2021
|
+
// The person's other computers, read when a composer or thread names one: ownMachines is made after this.
|
|
2022
|
+
computers: {
|
|
2023
|
+
self: () => ownMachines?.self() ?? machine.id,
|
|
2024
|
+
labelOf: (id) => ownMachines?.labelOf(id) ?? null,
|
|
2025
|
+
foldersOn: (id, question) =>
|
|
2026
|
+
ownMachines?.foldersOn(id, question) ?? {
|
|
2027
|
+
ok: false,
|
|
2028
|
+
error: "your other computers are not reachable",
|
|
2029
|
+
},
|
|
2030
|
+
checkoutOn: (id, folder) => ownMachines?.checkoutOn(id, folder) ?? null,
|
|
2031
|
+
},
|
|
2015
2032
|
runsIn: threadRuns.where,
|
|
2016
2033
|
authorizeRun: (id) =>
|
|
2017
2034
|
boardCommand({ command: "board.run", agent: "user", id }),
|
|
@@ -2158,9 +2175,9 @@ export async function startDaemon() {
|
|
|
2158
2175
|
store,
|
|
2159
2176
|
validAgent,
|
|
2160
2177
|
touchListener,
|
|
2161
|
-
// A task posted
|
|
2178
|
+
// A task posted into a thread is on its board once it exists: on the card it was posted for, or its own (kanban.mjs).
|
|
2162
2179
|
answered: (request, answer) =>
|
|
2163
|
-
request.command === "board.post" && request.
|
|
2180
|
+
request.command === "board.post" && request.parentId && answer?.ok
|
|
2164
2181
|
? kanban.posted(request, answer)
|
|
2165
2182
|
: answer,
|
|
2166
2183
|
machineOf: (request) => request[FROM_MACHINE] ?? machine.id,
|
|
@@ -2712,6 +2729,15 @@ export async function startDaemon() {
|
|
|
2712
2729
|
ownModels,
|
|
2713
2730
|
ownLive,
|
|
2714
2731
|
answerCapability: capabilityCheck.answer,
|
|
2732
|
+
// A composer on home whose message names this computer lists this computer's folders (swarm.mjs board.swarm.places).
|
|
2733
|
+
ownFolders: async (question) =>
|
|
2734
|
+
question.browse !== undefined
|
|
2735
|
+
? folders.browse(question.browse)
|
|
2736
|
+
: {
|
|
2737
|
+
ok: true,
|
|
2738
|
+
places: folders.known({ own: true }),
|
|
2739
|
+
home: os.homedir(),
|
|
2740
|
+
},
|
|
2715
2741
|
answerLink: proxyLinks
|
|
2716
2742
|
? (from, call) => proxyLinks.answer(from, call)
|
|
2717
2743
|
: null,
|
package/lib/goalCommands.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { provenanceFor } from "./provenance.mjs";
|
|
|
8
8
|
import { DISPATCHER, TAGGED_ONLY, nameOf } from "./members.mjs";
|
|
9
9
|
import { picksIn } from "./models.mjs";
|
|
10
10
|
import { roomPage } from "./roomPage.mjs";
|
|
11
|
-
import {
|
|
11
|
+
import { fromCloud, withComputer } from "./machineRoutes.mjs";
|
|
12
12
|
import { callerLimit, HOSTED_CALLER } from "./runAuthority.mjs";
|
|
13
13
|
|
|
14
14
|
export function createGoalCommands({
|
|
@@ -23,6 +23,8 @@ export function createGoalCommands({
|
|
|
23
23
|
flagNote,
|
|
24
24
|
// A post's words as an agent reads them (serverWords.mjs agentText); the person reads every post as written.
|
|
25
25
|
agentText = (post) => post.text,
|
|
26
|
+
// The thread's board as an agent reads it (kanban.mjs view): where the thread's work is managed.
|
|
27
|
+
boardView = () => null,
|
|
26
28
|
heardPerson,
|
|
27
29
|
heardRelayed = () => {},
|
|
28
30
|
inRoom,
|
|
@@ -181,7 +183,13 @@ export function createGoalCommands({
|
|
|
181
183
|
files,
|
|
182
184
|
};
|
|
183
185
|
const page = roomPage(store, goal.id, request);
|
|
184
|
-
return {
|
|
186
|
+
return {
|
|
187
|
+
...view,
|
|
188
|
+
board: boardView(goal.id),
|
|
189
|
+
...page,
|
|
190
|
+
posts: page.posts.map(readable),
|
|
191
|
+
files,
|
|
192
|
+
};
|
|
185
193
|
}
|
|
186
194
|
if (request.command === "board.room.learn") {
|
|
187
195
|
if (!inRoom(goal, agent) || agent === "user")
|
|
@@ -381,11 +389,12 @@ export function createGoalCommands({
|
|
|
381
389
|
return { ok: true, post, paused: true };
|
|
382
390
|
}
|
|
383
391
|
const told = wakeFor(goal.id, post, agent, wakes, {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
392
|
+
hosted: request.hostedCaller === true,
|
|
393
|
+
// An agent's words from another computer the person drives carry their go as from this one, its run's limits
|
|
394
|
+
// sealed with them (owner, November 2, in place of audit M1); from a cloud computer Harness runs, the guard
|
|
395
|
+
// reads them as words through Harness's server.
|
|
396
|
+
cloud:
|
|
397
|
+
fromCloud(store, request) && !["user", "harness"].includes(agent),
|
|
389
398
|
limited: callerLimit(request),
|
|
390
399
|
window: request.fromWindow === true,
|
|
391
400
|
target: request.targetMachine ?? null,
|
package/lib/kanban.mjs
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
// A thread's board: the pieces of work in it as cards in four columns, To do, In progress, Review and Done, so the
|
|
2
|
-
// person can tell at a glance where the work stands and follow one piece without reading the whole thread.
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// for a
|
|
7
|
-
//
|
|
2
|
+
// person can tell at a glance where the work stands and follow one piece without reading the whole thread. It is where
|
|
3
|
+
// the thread's agents manage the work, so it holds all of it:
|
|
4
|
+
// - every task handed out in the thread is a card: one is added for it as it is posted, unless it was posted for a card
|
|
5
|
+
// already there, and the task moves it (claimed: In progress, or Review for a check; failed: blocked; done: Review,
|
|
6
|
+
// or Done for a passed check);
|
|
7
|
+
// - agents add cards for the pieces they split the work into and move them as the work goes (update_board);
|
|
8
|
+
// - a thread turn that ends with its agent's card still In progress moves it on for them: to Review when the turn
|
|
9
|
+
// finished, blocked with why when it failed.
|
|
10
|
+
// Every thread turn starts from the board (runBrief.mjs), and every change answers with the whole board. Nothing waits
|
|
11
|
+
// on it: no agent is held for a card. Cards are kept per thread like its plan, so the buddy and the phone read the same
|
|
12
|
+
// ones (board.swarm.read). A board shared with other people (a shared project's room) is kept where they all read it
|
|
13
|
+
// instead (`shared`, projectBoard.mjs), and its cards from that record, a piece or work under way, move with the record.
|
|
8
14
|
import { randomUUID } from "node:crypto";
|
|
9
15
|
import { nameOf } from "./members.mjs";
|
|
10
16
|
import { oneLine } from "./oneLine.mjs";
|
|
@@ -25,13 +31,37 @@ const REVIEW_STEPS = new Set(["check", "judge"]);
|
|
|
25
31
|
// A task an agent holds and works on, and one not finished yet.
|
|
26
32
|
const WORKING = new Set(["claimed", "running"]);
|
|
27
33
|
const UNFINISHED = new Set(["open", "claimed", "running", "needs_input"]);
|
|
34
|
+
const ENDED = new Set(["done", "failed", "unknown"]);
|
|
35
|
+
// A task asked in a thread is named for the thread in front of its words (asks.mjs, threadActions.mjs): its card is
|
|
36
|
+
// named by the words alone.
|
|
37
|
+
const ASKED = /^Asked in "[^]*?": (?:\S+ (?:asked|mentioned) you: )?([^]*)$/;
|
|
28
38
|
|
|
29
39
|
const words = (value, limit) => oneLine(String(value ?? "")).slice(0, limit);
|
|
30
|
-
|
|
40
|
+
// Another person's side is named by its handle: "maya" for the person, "maya's Codex" for an agent.
|
|
41
|
+
const whoIs = (agent) => {
|
|
42
|
+
if (agent === "user") return "You";
|
|
43
|
+
const [handle, who] = String(agent).split("/");
|
|
44
|
+
if (!who) return nameOf(agent);
|
|
45
|
+
return who === "person" ? handle : `${handle}'s ${nameOf(who)}`;
|
|
46
|
+
};
|
|
47
|
+
const RECORD_MOVES = {
|
|
48
|
+
piece: "plan_work moves a piece (claim, hand_to, done)",
|
|
49
|
+
work: "plan_work moves work under way (done, stopped)",
|
|
50
|
+
};
|
|
31
51
|
|
|
32
|
-
export function createKanban({
|
|
52
|
+
export function createKanban({
|
|
53
|
+
store,
|
|
54
|
+
log = () => {},
|
|
55
|
+
onChange = () => {},
|
|
56
|
+
// The board of a thread shared with other people, kept where they all read it ({ load, save }), or null.
|
|
57
|
+
shared = () => null,
|
|
58
|
+
}) {
|
|
33
59
|
const key = (threadId) => `kanban:${threadId}`;
|
|
60
|
+
const hasBoard = (threadId) =>
|
|
61
|
+
Boolean(shared(threadId) || store.meta(key(threadId)));
|
|
34
62
|
const cardsOf = (threadId) => {
|
|
63
|
+
const elsewhere = shared(threadId);
|
|
64
|
+
if (elsewhere) return elsewhere.load();
|
|
35
65
|
try {
|
|
36
66
|
const kept = JSON.parse(store.meta(key(threadId)) || "[]");
|
|
37
67
|
return Array.isArray(kept) ? kept : [];
|
|
@@ -40,7 +70,9 @@ export function createKanban({ store, log = () => {}, onChange = () => {} }) {
|
|
|
40
70
|
}
|
|
41
71
|
};
|
|
42
72
|
const save = (threadId, cards) => {
|
|
43
|
-
|
|
73
|
+
const elsewhere = shared(threadId);
|
|
74
|
+
if (elsewhere) elsewhere.save(cards);
|
|
75
|
+
else store.meta(key(threadId), JSON.stringify(cards));
|
|
44
76
|
onChange(threadId);
|
|
45
77
|
};
|
|
46
78
|
const threadOf = (id) => {
|
|
@@ -54,8 +86,17 @@ export function createKanban({ store, log = () => {}, onChange = () => {} }) {
|
|
|
54
86
|
].slice(-HISTORY_LIMIT);
|
|
55
87
|
card.at = new Date().toISOString();
|
|
56
88
|
};
|
|
89
|
+
// A full board makes room by letting its oldest finished card go; with nothing finished it is full.
|
|
90
|
+
const roomFor = (cards) => {
|
|
91
|
+
if (cards.length < MAX_CARDS) return cards;
|
|
92
|
+
const finished = cards
|
|
93
|
+
.filter((card) => card.column === "done")
|
|
94
|
+
.sort((a, b) => String(a.at).localeCompare(String(b.at)))[0];
|
|
95
|
+
return finished ? cards.filter((card) => card !== finished) : null;
|
|
96
|
+
};
|
|
57
97
|
const moveTo = (card, column, by) => {
|
|
58
|
-
|
|
98
|
+
// A card from a shared record moves with the record.
|
|
99
|
+
if (card.derived || card.column === column) return false;
|
|
59
100
|
card.column = column;
|
|
60
101
|
remember(card, by, `${whoIs(by)} moved it to ${COLUMN_NAMES[column]}`);
|
|
61
102
|
return true;
|
|
@@ -83,7 +124,8 @@ export function createKanban({ store, log = () => {}, onChange = () => {} }) {
|
|
|
83
124
|
if (!cardId) {
|
|
84
125
|
const title = words(request.title, TITLE_LIMIT);
|
|
85
126
|
if (!title) return { ok: false, error: "a new card needs a title" };
|
|
86
|
-
|
|
127
|
+
const kept = roomFor(cards);
|
|
128
|
+
if (!kept)
|
|
87
129
|
return {
|
|
88
130
|
ok: false,
|
|
89
131
|
error: `a thread's board holds ${MAX_CARDS} cards; finish or remove some first`,
|
|
@@ -101,13 +143,25 @@ export function createKanban({ store, log = () => {}, onChange = () => {} }) {
|
|
|
101
143
|
at: null,
|
|
102
144
|
history: [],
|
|
103
145
|
};
|
|
146
|
+
if (card.column === "doing" && !card.agent && agent !== "user")
|
|
147
|
+
card.agent = agent;
|
|
104
148
|
remember(card, agent, `${whoIs(agent)} added it`);
|
|
105
|
-
save(thread.id, [...
|
|
106
|
-
return { ok: true, card };
|
|
149
|
+
save(thread.id, [...kept, card]);
|
|
150
|
+
return { ok: true, card, board: view(thread.id) };
|
|
107
151
|
}
|
|
108
152
|
const card = cards.find((each) => each.id === cardId);
|
|
109
153
|
if (!card)
|
|
110
154
|
return { ok: false, error: "no card on this thread's board has that id" };
|
|
155
|
+
const moved =
|
|
156
|
+
column ||
|
|
157
|
+
request.title != null ||
|
|
158
|
+
request.agent !== undefined ||
|
|
159
|
+
request.remove === true;
|
|
160
|
+
if (card.derived && moved)
|
|
161
|
+
return {
|
|
162
|
+
ok: false,
|
|
163
|
+
error: `this card is the project's ${card.derived}: ${RECORD_MOVES[card.derived]}; its note, blocked and needs_you are set here`,
|
|
164
|
+
};
|
|
111
165
|
if (request.remove === true) {
|
|
112
166
|
if (agent !== "user" && agent !== card.by)
|
|
113
167
|
return {
|
|
@@ -118,9 +172,17 @@ export function createKanban({ store, log = () => {}, onChange = () => {} }) {
|
|
|
118
172
|
thread.id,
|
|
119
173
|
cards.filter((each) => each.id !== cardId)
|
|
120
174
|
);
|
|
121
|
-
return { ok: true, removed: cardId };
|
|
175
|
+
return { ok: true, removed: cardId, board: view(thread.id) };
|
|
122
176
|
}
|
|
123
177
|
if (column) moveTo(card, column, agent);
|
|
178
|
+
// An agent that starts a piece nobody has takes it.
|
|
179
|
+
if (
|
|
180
|
+
column === "doing" &&
|
|
181
|
+
!card.agent &&
|
|
182
|
+
request.agent === undefined &&
|
|
183
|
+
agent !== "user"
|
|
184
|
+
)
|
|
185
|
+
card.agent = agent;
|
|
124
186
|
if (request.title != null) {
|
|
125
187
|
const title = words(request.title, TITLE_LIMIT);
|
|
126
188
|
if (title) card.title = title;
|
|
@@ -146,7 +208,7 @@ export function createKanban({ store, log = () => {}, onChange = () => {} }) {
|
|
|
146
208
|
card.needsYou = words(request.needs_you || "", NOTE_LIMIT) || null;
|
|
147
209
|
card.at = new Date().toISOString();
|
|
148
210
|
save(thread.id, cards);
|
|
149
|
-
return { ok: true, card };
|
|
211
|
+
return { ok: true, card, board: view(thread.id) };
|
|
150
212
|
};
|
|
151
213
|
|
|
152
214
|
/** A task was posted with a card: it is linked, so what happens to the task moves the card. */
|
|
@@ -155,19 +217,104 @@ export function createKanban({ store, log = () => {}, onChange = () => {} }) {
|
|
|
155
217
|
const card = cards.find((each) => each.id === cardId);
|
|
156
218
|
if (!card || card.tasks.includes(taskId)) return Boolean(card);
|
|
157
219
|
card.tasks = [...card.tasks, taskId];
|
|
158
|
-
|
|
220
|
+
// The card added for the task as it was posted gives way to the one it was posted for.
|
|
221
|
+
const kept = cards.filter(
|
|
222
|
+
(each) =>
|
|
223
|
+
!(each.auto && each.tasks.length === 1 && each.tasks[0] === taskId)
|
|
224
|
+
);
|
|
225
|
+
save(threadId, kept);
|
|
159
226
|
// The task may have been claimed in the same breath as it was posted.
|
|
160
227
|
changed(store.getTask(taskId));
|
|
161
228
|
return true;
|
|
162
229
|
};
|
|
163
230
|
|
|
231
|
+
/** A task handed out in a thread is on its board from the moment it is posted. */
|
|
232
|
+
const cardFor = (task, cards) => {
|
|
233
|
+
const kept = roomFor(cards);
|
|
234
|
+
if (!kept) {
|
|
235
|
+
log(`board of ${task.parent_id} is full: task ${task.id} has no card`);
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
const asked = ASKED.exec(String(task.objective ?? ""));
|
|
239
|
+
const card = {
|
|
240
|
+
id: randomUUID().slice(0, 8),
|
|
241
|
+
title: words(asked?.[1] ?? task.objective, TITLE_LIMIT) || "A task",
|
|
242
|
+
column: "todo",
|
|
243
|
+
note: null,
|
|
244
|
+
agent: task.target_agent || null,
|
|
245
|
+
blocked: null,
|
|
246
|
+
needsYou: null,
|
|
247
|
+
tasks: [task.id],
|
|
248
|
+
by: task.origin_agent,
|
|
249
|
+
auto: true,
|
|
250
|
+
at: null,
|
|
251
|
+
history: [],
|
|
252
|
+
};
|
|
253
|
+
remember(
|
|
254
|
+
card,
|
|
255
|
+
task.origin_agent,
|
|
256
|
+
`${whoIs(task.origin_agent)} handed it out`
|
|
257
|
+
);
|
|
258
|
+
kept.push(card);
|
|
259
|
+
return { card, cards: kept };
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
/** A thread turn ended: its agent's card still In progress moves on, to Review or blocked. */
|
|
263
|
+
const turnEnded = (turn, threadId) => {
|
|
264
|
+
if (!ENDED.has(turn.status) || !hasBoard(threadId)) return;
|
|
265
|
+
const handled = `kanban-turn:${turn.id}`;
|
|
266
|
+
if (store.meta(handled)) return;
|
|
267
|
+
store.meta(handled, "1");
|
|
268
|
+
const agent = turn.claimed_by || turn.target_agent;
|
|
269
|
+
// Another turn of the same agent already started there: the card is that turn's now.
|
|
270
|
+
const stillWorking = store
|
|
271
|
+
.threadRuns(threadId)
|
|
272
|
+
.some(
|
|
273
|
+
(run) =>
|
|
274
|
+
run.id !== turn.id &&
|
|
275
|
+
run.target_agent === agent &&
|
|
276
|
+
UNFINISHED.has(run.status)
|
|
277
|
+
);
|
|
278
|
+
if (stillWorking) return;
|
|
279
|
+
const cards = cardsOf(threadId);
|
|
280
|
+
const why = words(turn.result || "its turn stopped", NOTE_LIMIT);
|
|
281
|
+
let moved = false;
|
|
282
|
+
for (const card of cards) {
|
|
283
|
+
if (card.derived || card.agent !== agent || card.column !== "doing")
|
|
284
|
+
continue;
|
|
285
|
+
// A card a task of its own moves is that task's to move.
|
|
286
|
+
const tasked = card.tasks.some((id) =>
|
|
287
|
+
UNFINISHED.has(store.getTask(id)?.status)
|
|
288
|
+
);
|
|
289
|
+
if (tasked) continue;
|
|
290
|
+
if (turn.status === "done") moveTo(card, "review", agent);
|
|
291
|
+
else if (card.blocked !== why) {
|
|
292
|
+
card.blocked = why;
|
|
293
|
+
remember(card, agent, `${whoIs(agent)}'s turn stopped: ${why}`);
|
|
294
|
+
} else continue;
|
|
295
|
+
card.at = new Date().toISOString();
|
|
296
|
+
moved = true;
|
|
297
|
+
}
|
|
298
|
+
if (moved) save(threadId, cards);
|
|
299
|
+
};
|
|
300
|
+
|
|
164
301
|
/** A task changed: the card it is linked to moves with it. */
|
|
165
302
|
const changed = (task) => {
|
|
166
303
|
const threadId = task?.parent_id;
|
|
167
|
-
if (!threadId
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
304
|
+
if (!threadId) return;
|
|
305
|
+
if (task.kind === "wake") return turnEnded(task, threadId);
|
|
306
|
+
if (task.kind !== "task" || !threadOf(threadId)) return;
|
|
307
|
+
let cards = cardsOf(threadId);
|
|
308
|
+
let card = cards.find((each) => each.tasks.includes(task.id));
|
|
309
|
+
let added = false;
|
|
310
|
+
if (!card) {
|
|
311
|
+
// Only work still to do is added: a task that ended before the board knew it stays off it.
|
|
312
|
+
if (ENDED.has(task.status)) return;
|
|
313
|
+
const made = cardFor(task, cards);
|
|
314
|
+
if (!made) return;
|
|
315
|
+
({ card, cards } = made);
|
|
316
|
+
added = true;
|
|
317
|
+
}
|
|
171
318
|
const reviews = REVIEW_STEPS.has(task.step);
|
|
172
319
|
const holder = task.claimed_by || task.target_agent;
|
|
173
320
|
let moved = false;
|
|
@@ -194,34 +341,48 @@ export function createKanban({ store, log = () => {}, onChange = () => {} }) {
|
|
|
194
341
|
(id) => id !== task.id && UNFINISHED.has(store.getTask(id)?.status)
|
|
195
342
|
);
|
|
196
343
|
if (reviews && !stillOpen) moved = moveTo(card, "done", holder);
|
|
197
|
-
else if (!stillOpen &&
|
|
344
|
+
else if (!stillOpen && ["todo", "doing"].includes(card.column))
|
|
198
345
|
// The work it stands for is finished; whoever reviews it, or the agent, moves it on.
|
|
199
346
|
moved = moveTo(card, "review", holder);
|
|
347
|
+
if (card.blocked && !stillOpen) {
|
|
348
|
+
card.blocked = null;
|
|
349
|
+
moved = true;
|
|
350
|
+
}
|
|
200
351
|
}
|
|
201
|
-
if (moved) {
|
|
352
|
+
if (moved || added) {
|
|
202
353
|
card.at = new Date().toISOString();
|
|
203
354
|
save(threadId, cards);
|
|
204
355
|
}
|
|
205
356
|
};
|
|
206
357
|
|
|
207
|
-
/**
|
|
208
|
-
const
|
|
358
|
+
/** The board as an agent reads it: one line per card, by column, with what each card is waiting on. */
|
|
359
|
+
const view = (threadId) => {
|
|
209
360
|
const cards = cardsOf(threadId);
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
361
|
+
if (!cards.length) return "No cards yet.";
|
|
362
|
+
return COLUMNS.flatMap((column) => {
|
|
363
|
+
const here = cards.filter((card) => card.column === column);
|
|
364
|
+
if (!here.length) return [];
|
|
365
|
+
return [
|
|
366
|
+
`${COLUMN_NAMES[column]}:`,
|
|
367
|
+
...here.map(
|
|
368
|
+
(card) =>
|
|
369
|
+
`- [${card.id}] ${card.title}${card.agent ? ` (${whoIs(card.agent)})` : ""}${card.derived ? `, the project's ${card.derived}` : ""}${card.blocked ? `, blocked: ${card.blocked}` : ""}${card.needsYou ? `, waits on the person: ${card.needsYou}` : ""}${card.note ? `. ${card.note}` : ""}`
|
|
370
|
+
),
|
|
371
|
+
];
|
|
372
|
+
}).join("\n");
|
|
221
373
|
};
|
|
222
374
|
|
|
375
|
+
/** What a run in the thread is told of its board: the cards, and how it manages the work on them. */
|
|
376
|
+
const brief = (threadId) =>
|
|
377
|
+
[
|
|
378
|
+
`This thread's board is where its work is managed, and the person follows the work on it. Each piece of the work is a card in To do, In progress, Review or Done.`,
|
|
379
|
+
view(threadId),
|
|
380
|
+
`Manage your work on it with update_board (thread ${threadId}). When you do work this turn, put it on a card: take a card that is already there or add one, move it to In progress as you start, to Review when it is ready to be checked and to Done when it is finished. Mark it blocked with why, or say what it waits on from the person. A turn that only answers needs no card. Handing a piece to another agent with post_task adds its card; post it with card to hand out a card already there. The task's claim and end move the card. Never wait on the board to do your work.`,
|
|
381
|
+
].join("\n\n");
|
|
382
|
+
|
|
223
383
|
return {
|
|
224
384
|
of: (threadId) => cardsOf(threadId),
|
|
385
|
+
view,
|
|
225
386
|
brief,
|
|
226
387
|
changed: (task) => {
|
|
227
388
|
try {
|
|
@@ -230,22 +391,30 @@ export function createKanban({ store, log = () => {}, onChange = () => {} }) {
|
|
|
230
391
|
log(`board card move failed for ${task?.id}: ${error.message}`);
|
|
231
392
|
}
|
|
232
393
|
},
|
|
233
|
-
/** After board.post:
|
|
394
|
+
/** After board.post into a thread: the task is on a card, the one it was posted for or its own, and the answer
|
|
395
|
+
* gives that card and the whole board. */
|
|
234
396
|
posted(request, answer) {
|
|
235
397
|
const taskId = answer?.task?.id ?? answer?.id;
|
|
236
|
-
if (!request.
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
String(request.card),
|
|
241
|
-
|
|
398
|
+
if (!request.parentId || typeof taskId !== "string") return answer;
|
|
399
|
+
const threadId = String(request.parentId);
|
|
400
|
+
if (!threadOf(threadId)) return answer;
|
|
401
|
+
const linked = request.card
|
|
402
|
+
? link(threadId, String(request.card), taskId)
|
|
403
|
+
: true;
|
|
404
|
+
changed(store.getTask(taskId));
|
|
405
|
+
const card = cardsOf(threadId).find((each) =>
|
|
406
|
+
each.tasks.includes(taskId)
|
|
242
407
|
);
|
|
243
|
-
return
|
|
244
|
-
|
|
245
|
-
: {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
408
|
+
return {
|
|
409
|
+
...answer,
|
|
410
|
+
...(card ? { card: card.id } : {}),
|
|
411
|
+
board: view(threadId),
|
|
412
|
+
...(linked
|
|
413
|
+
? {}
|
|
414
|
+
: {
|
|
415
|
+
note: "No card on the thread's board has that id, so the task has its own card.",
|
|
416
|
+
}),
|
|
417
|
+
};
|
|
249
418
|
},
|
|
250
419
|
command(request, agent) {
|
|
251
420
|
if (String(request.command) === "board.kanban.update")
|
package/lib/machineRoutes.mjs
CHANGED
|
@@ -27,6 +27,14 @@ const LOCAL_OWNERS = new Set([
|
|
|
27
27
|
*/
|
|
28
28
|
export const FROM_MACHINE = Symbol("the computer a board call came from");
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Whether a board call came from a cloud computer Harness runs for the person (own_machines.hosted), not one they
|
|
32
|
+
* drive: what its agents say is read by the guard here, as words through Harness's server are.
|
|
33
|
+
*/
|
|
34
|
+
export const fromCloud = (store, request) =>
|
|
35
|
+
request?.[FROM_MACHINE] !== undefined &&
|
|
36
|
+
Boolean(store.ownMachine(request[FROM_MACHINE])?.hosted);
|
|
37
|
+
|
|
30
38
|
/** Whether a worker sends this board command to home. */
|
|
31
39
|
export const goesHome = (command) =>
|
|
32
40
|
String(command).startsWith("board.") &&
|
|
@@ -289,6 +297,7 @@ const PERSON_WORK = new Set([
|
|
|
289
297
|
"board.landed.folder",
|
|
290
298
|
"board.environments.list",
|
|
291
299
|
"board.relay.list",
|
|
300
|
+
"board.relay.board",
|
|
292
301
|
"board.relay.seen",
|
|
293
302
|
"board.connector.operations",
|
|
294
303
|
"board.place.op",
|
package/lib/machineRuns.mjs
CHANGED
|
@@ -157,7 +157,11 @@ export function createMachineRuns({
|
|
|
157
157
|
const agent = task.target_agent;
|
|
158
158
|
log(`running ${agent}'s task ${task.id} from your home computer`);
|
|
159
159
|
// A start on another of the person's agents' asks on standing permission grants no secrets (runAuthority.mjs).
|
|
160
|
-
|
|
160
|
+
// Nor for a held-in run, nor work another person asked for (runWorker.mjs startBoardRun).
|
|
161
|
+
const secrets =
|
|
162
|
+
task.standing || task.restricted === true || task.ownSettingsOnly === true
|
|
163
|
+
? {}
|
|
164
|
+
: await secretsFor(task, agent);
|
|
161
165
|
// Sent again with the finish: the two calls go to home at once, and a finish that arrives first closes the run to
|
|
162
166
|
// the session call (two-machines: home kept no session, one run in four).
|
|
163
167
|
let session = null;
|
|
@@ -175,6 +179,10 @@ export function createMachineRuns({
|
|
|
175
179
|
...(SESSION_ID.test(task.resumeSession ?? "")
|
|
176
180
|
? { resumeSession: task.resumeSession }
|
|
177
181
|
: {}),
|
|
182
|
+
// Held in as home says (taskCommands.mjs forWorker); what the run asks home for is held in there too.
|
|
183
|
+
...(task.readOnly === true ? { readOnly: true } : {}),
|
|
184
|
+
...(task.restricted === true ? { restricted: true } : {}),
|
|
185
|
+
...(task.ownSettingsOnly === true ? { ownSettingsOnly: true } : {}),
|
|
178
186
|
...secrets,
|
|
179
187
|
},
|
|
180
188
|
(kind, text, extra) => {
|