tryharness 0.7.77 → 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/capabilityCheck.mjs +9 -1
- package/lib/coordinator.mjs +156 -14
- package/lib/daemon.mjs +43 -3
- package/lib/dispatcher.mjs +24 -4
- package/lib/goalCommands.mjs +40 -11
- package/lib/goals.mjs +9 -3
- package/lib/kanban.mjs +217 -48
- package/lib/machineRoutes.mjs +9 -0
- package/lib/machineRuns.mjs +9 -1
- package/lib/manager.mjs +94 -2
- package/lib/mcp-stdio.mjs +3 -3
- package/lib/network.mjs +19 -0
- package/lib/ownMachines.mjs +96 -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 +185 -62
- package/lib/taskCommands.mjs +25 -15
- package/lib/taskRooms.mjs +2 -4
- package/lib/threadActions.mjs +23 -8
- package/lib/threadAuthority.mjs +28 -10
- package/lib/threadRuns.mjs +279 -86
- package/lib/threadView.mjs +1 -1
- package/npm-shrinkwrap.json +14 -14
- package/package.json +4 -4
- package/release.json +33 -31
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,
|
|
@@ -932,9 +933,16 @@ export function createProjects({
|
|
|
932
933
|
"setting",
|
|
933
934
|
"note",
|
|
934
935
|
...RECORD_KINDS,
|
|
936
|
+
...BOARD_KINDS,
|
|
935
937
|
].includes(entry.kind)
|
|
936
938
|
)
|
|
937
939
|
return { ok: true };
|
|
940
|
+
// A side's changes to a card are its one entry for that card; under another id it could stand in for another's.
|
|
941
|
+
if (
|
|
942
|
+
entry.kind === "card-edit" &&
|
|
943
|
+
entry.id !== editIdOf(entry.body?.card, entry.side)
|
|
944
|
+
)
|
|
945
|
+
return { ok: false, error: "a card's changes in the wrong place" };
|
|
938
946
|
// An answer is its side's own entry for one proposal; one under another id could stand in for this person's.
|
|
939
947
|
if (
|
|
940
948
|
entry.kind === "answer" &&
|
|
@@ -2423,6 +2431,8 @@ export function createProjects({
|
|
|
2423
2431
|
changedFiles,
|
|
2424
2432
|
branchSlug,
|
|
2425
2433
|
});
|
|
2434
|
+
// The project's one board, the same on every computer in it (projectBoard.mjs).
|
|
2435
|
+
const board = createProjectBoard({ items, write, local, shared, pieces });
|
|
2426
2436
|
|
|
2427
2437
|
// ---- the board commands ----
|
|
2428
2438
|
|
|
@@ -2799,6 +2809,15 @@ export function createProjects({
|
|
|
2799
2809
|
learned,
|
|
2800
2810
|
refresh,
|
|
2801
2811
|
isProjectRoom: (goalId) => Boolean(projectOfRoom(goalId)),
|
|
2812
|
+
/** A project room's board, kept in the project's record so every computer in it shows the same cards. */
|
|
2813
|
+
boardOf: (goalId) => {
|
|
2814
|
+
const p = projectOfRoom(goalId);
|
|
2815
|
+
if (!p) return null;
|
|
2816
|
+
return {
|
|
2817
|
+
load: () => board.load(project(p.id)),
|
|
2818
|
+
save: (cards) => board.save(project(p.id), cards),
|
|
2819
|
+
};
|
|
2820
|
+
},
|
|
2802
2821
|
/**
|
|
2803
2822
|
* 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
2823
|
* asked for (agree), and an agent's post kept here until the person shares it (share).
|
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/store.mjs
CHANGED
|
@@ -2668,14 +2668,17 @@ export function openStore(file) {
|
|
|
2668
2668
|
).n
|
|
2669
2669
|
);
|
|
2670
2670
|
},
|
|
2671
|
-
|
|
2671
|
+
// `machine`: only posts from that computer, or from none named.
|
|
2672
|
+
postsBy(goalId, author, since, machine = null) {
|
|
2672
2673
|
return Number(
|
|
2673
2674
|
execute(
|
|
2674
2675
|
"get",
|
|
2675
|
-
"select count(*) as n from board_contributions where task_id = ? and author = ? and created_at >= ? and kind != 'held'",
|
|
2676
|
+
"select count(*) as n from board_contributions where task_id = ? and author = ? and created_at >= ? and kind != 'held' and (? is null or machine is null or machine = ?)",
|
|
2676
2677
|
goalId,
|
|
2677
2678
|
author,
|
|
2678
|
-
since
|
|
2679
|
+
since,
|
|
2680
|
+
machine,
|
|
2681
|
+
machine
|
|
2679
2682
|
).n
|
|
2680
2683
|
);
|
|
2681
2684
|
},
|
package/lib/swarm.mjs
CHANGED
|
@@ -199,6 +199,9 @@ export function createSwarm({
|
|
|
199
199
|
// The person chose a model for an agent here (an agent on Harness's AI also takes it as its default).
|
|
200
200
|
modelChosen = () => {},
|
|
201
201
|
folders,
|
|
202
|
+
// The person's other computers (daemon.mjs): this one's id, a computer's name, its folders for the composer
|
|
203
|
+
// (ownMachines.mjs foldersOn) and its checkout of a folder here (checkoutOn).
|
|
204
|
+
computers = null,
|
|
202
205
|
runsIn,
|
|
203
206
|
threadFiles = () => ({ files: [], rendering: [] }),
|
|
204
207
|
whyWaiting = () => null,
|
|
@@ -228,6 +231,8 @@ export function createSwarm({
|
|
|
228
231
|
notifyFocus = () => {},
|
|
229
232
|
// What the person's words just did to a run they steered (threadRuns.mjs steered): a promise of the thread's note.
|
|
230
233
|
steered = () => null,
|
|
234
|
+
// The computer a thread's run is on, by id (threadRuns.mjs computerOfRun).
|
|
235
|
+
computerOfRun = (run) => run.claimed_machine ?? null,
|
|
231
236
|
}) {
|
|
232
237
|
const focus = createWorkFocus({ store });
|
|
233
238
|
const readWork = async (id, hostedCaller = false) => {
|
|
@@ -381,6 +386,8 @@ export function createSwarm({
|
|
|
381
386
|
// The task this room was opened for, when it is a task's own room.
|
|
382
387
|
root: store.meta(`task-room:${thread.id}`) || null,
|
|
383
388
|
folder: thread.goal.workspace,
|
|
389
|
+
// The folder on another of the person's computers it works in instead, with that computer.
|
|
390
|
+
folderOn: folderOnOf(thread.id),
|
|
384
391
|
working: [
|
|
385
392
|
...new Set(
|
|
386
393
|
runs
|
|
@@ -510,7 +517,8 @@ export function createSwarm({
|
|
|
510
517
|
!team.length || team.some((name) => PROCESS_NAMES[name]);
|
|
511
518
|
// Where each coding agent in a thread would run its turn there: in T3 Code, or here, and why not T3 when the person uses it there.
|
|
512
519
|
// `lastWorked`: where its agent last worked, when Harness picked another folder from the message, for the person to take.
|
|
513
|
-
|
|
520
|
+
// `on`: the other computer the folder is on ({ id, label }), null for this one. No folder: a scratch folder.
|
|
521
|
+
const placeOf = (folder, team, by, lastWorked = null, on = null) => ({
|
|
514
522
|
ok: true,
|
|
515
523
|
folder,
|
|
516
524
|
name: folder ? path.basename(folder) : null,
|
|
@@ -518,13 +526,61 @@ export function createSwarm({
|
|
|
518
526
|
lastWorked: lastWorked
|
|
519
527
|
? { folder: lastWorked, name: path.basename(lastWorked) }
|
|
520
528
|
: null,
|
|
521
|
-
runs:
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
529
|
+
runs:
|
|
530
|
+
folder && !on
|
|
531
|
+
? team
|
|
532
|
+
.filter((name) => PROCESS_NAMES[name])
|
|
533
|
+
.map((name) => ({ agent: name, ...runsIn(name, folder) }))
|
|
534
|
+
: [],
|
|
535
|
+
computer: on,
|
|
526
536
|
});
|
|
527
537
|
|
|
538
|
+
/**
|
|
539
|
+
* The other computer of the person's whose folders a thread works in: the one a computer id names, else the one the
|
|
540
|
+
* message sends its agents to (`#pop-os`, `@codex on pop-os`); null for this computer or none.
|
|
541
|
+
*/
|
|
542
|
+
const computerFor = ({ id = null, address = null, team = [] }) => {
|
|
543
|
+
if (!computers) return null;
|
|
544
|
+
const named =
|
|
545
|
+
id ??
|
|
546
|
+
(address?.ok
|
|
547
|
+
? (address.shared ?? team.map(address.forAgent).find(Boolean))?.id
|
|
548
|
+
: null);
|
|
549
|
+
if (!named || named === computers.self()) return null;
|
|
550
|
+
return { id: String(named), label: computers.labelOf(named) ?? named };
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
// A thread whose folder is on another of the person's computers: { machine, path }. Its folder here stays empty, so
|
|
554
|
+
// a turn on any other computer works in a scratch folder (threadRuns.mjs).
|
|
555
|
+
const folderAway = (threadId) => {
|
|
556
|
+
try {
|
|
557
|
+
return JSON.parse(store.meta(`thread-folder-on:${threadId}`) || "null");
|
|
558
|
+
} catch {
|
|
559
|
+
return null;
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
const setFolderAway = (threadId, on, folder) => {
|
|
563
|
+
const away = on && folder ? { machine: on.id, path: folder } : null;
|
|
564
|
+
store.meta(
|
|
565
|
+
`thread-folder-on:${threadId}`,
|
|
566
|
+
away ? JSON.stringify(away) : ""
|
|
567
|
+
);
|
|
568
|
+
// Its agents' turns go to that computer unless a message names another.
|
|
569
|
+
if (away) store.meta(`thread-work-computer:${threadId}`, on.id);
|
|
570
|
+
};
|
|
571
|
+
const folderOnOf = (threadId) => {
|
|
572
|
+
const away = folderAway(threadId);
|
|
573
|
+
return away
|
|
574
|
+
? {
|
|
575
|
+
folder: away.path,
|
|
576
|
+
computer: {
|
|
577
|
+
id: away.machine,
|
|
578
|
+
label: computers?.labelOf(away.machine) ?? away.machine,
|
|
579
|
+
},
|
|
580
|
+
}
|
|
581
|
+
: null;
|
|
582
|
+
};
|
|
583
|
+
|
|
528
584
|
const askOf = (run) => askOfRun(store, run);
|
|
529
585
|
const linkThreads = (from, to, agent) => {
|
|
530
586
|
const note = (goalId, text) =>
|
|
@@ -708,10 +764,12 @@ export function createSwarm({
|
|
|
708
764
|
|
|
709
765
|
/**
|
|
710
766
|
* The person's words in a chat that is not a thread (the PiP chat, the extension, the buddy's box, the phone's New
|
|
711
|
-
* message), naming one agent that is working (owner, October 26: steering "from any chat interface")
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
767
|
+
* message), naming one agent that is working (owner, October 26: steering "from any chat interface"). The person
|
|
768
|
+
* picks where they go: one of the threads it works in, or a new thread (`choose`; owner, November 2, after "@claude
|
|
769
|
+
* #pop-os fix opencode" from the extension went into Claude Code's video edit on the Mac). Named for a computer the
|
|
770
|
+
* agent is not at work on, at work elsewhere or nowhere, they start a new thread with no choice (`newThread`). At
|
|
771
|
+
* work nowhere and naming no computer, null, and the chat goes on as it would have. Words for the whole swarm, or
|
|
772
|
+
* naming several agents, are never a steer.
|
|
715
773
|
*/
|
|
716
774
|
const steerFromChat = (request) => {
|
|
717
775
|
const text = String(request.text || "");
|
|
@@ -722,32 +780,45 @@ export function createSwarm({
|
|
|
722
780
|
const named = asked ? [asked] : mentionsIn(text, roomAgents);
|
|
723
781
|
if (named.length !== 1) return null;
|
|
724
782
|
const [agent] = named;
|
|
725
|
-
const
|
|
783
|
+
const address = computerAddress(text, "user", {
|
|
784
|
+
target: request.targetMachine ?? null,
|
|
785
|
+
});
|
|
786
|
+
const computer = address.ok ? (address.forAgent(agent)?.id ?? null) : null;
|
|
787
|
+
const working = (thread) =>
|
|
788
|
+
store
|
|
789
|
+
.threadRuns(thread.id)
|
|
790
|
+
.filter(
|
|
791
|
+
(run) => run.target_agent === agent && run.status === "running"
|
|
792
|
+
);
|
|
793
|
+
const atWork = store
|
|
726
794
|
.goals({ all: false })
|
|
727
|
-
.filter(
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
if (threads.length
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
795
|
+
.filter((thread) => thread.status === "open" && working(thread).length);
|
|
796
|
+
// At work nowhere: words naming a computer start a thread there, since Harness's own handoffs cannot place work
|
|
797
|
+
// on a computer; naming none, the chat goes on as before.
|
|
798
|
+
if (!atWork.length)
|
|
799
|
+
return computer ? { ok: true, steered: false, newThread: true } : null;
|
|
800
|
+
const threads = computer
|
|
801
|
+
? atWork.filter((thread) =>
|
|
802
|
+
working(thread).some((run) => computerOfRun(run) === computer)
|
|
803
|
+
)
|
|
804
|
+
: atWork;
|
|
805
|
+
if (!threads.length) return { ok: true, steered: false, newThread: true };
|
|
806
|
+
const titled = threads.map((thread) => ({
|
|
807
|
+
id: thread.id,
|
|
808
|
+
title: summary(thread).title,
|
|
809
|
+
}));
|
|
810
|
+
return {
|
|
811
|
+
ok: true,
|
|
812
|
+
steered: false,
|
|
813
|
+
choose: {
|
|
814
|
+
agent,
|
|
815
|
+
question:
|
|
816
|
+
titled.length === 1
|
|
817
|
+
? `${nameOf(agent)} is working in "${titled[0].title}". Send this there, or start a new thread?`
|
|
818
|
+
: `${nameOf(agent)} is working in ${titled.length} threads. Send this to one of them, or start a new thread?`,
|
|
819
|
+
threads: titled,
|
|
820
|
+
},
|
|
821
|
+
};
|
|
751
822
|
};
|
|
752
823
|
|
|
753
824
|
// One of the person's agents as a command names it, or why not.
|
|
@@ -1110,8 +1181,7 @@ export function createSwarm({
|
|
|
1110
1181
|
: listing();
|
|
1111
1182
|
}
|
|
1112
1183
|
// Any of the person's agents may start a thread and stop one it started. The thread carries the agent's trust, so
|
|
1113
|
-
// nothing in it runs without the person's Start
|
|
1114
|
-
// are paid) until the person sets a spend ceiling.
|
|
1184
|
+
// nothing in it runs without the person's Start.
|
|
1115
1185
|
if (agent !== "user" && command === "board.swarm.start") {
|
|
1116
1186
|
const text = String(request.text || "")
|
|
1117
1187
|
.trim()
|
|
@@ -1156,7 +1226,6 @@ export function createSwarm({
|
|
|
1156
1226
|
maxPosts: defaults.maxPosts,
|
|
1157
1227
|
maxWakes: defaults.maxWakes,
|
|
1158
1228
|
});
|
|
1159
|
-
if (request.hostedCaller) store.meta(`hosted-thread:${thread.id}`, "1");
|
|
1160
1229
|
// A thread an agent starts from another says so in both, so neither is a dead end for the person.
|
|
1161
1230
|
const [from] = store.threadsWorkedIn(agent);
|
|
1162
1231
|
if (from)
|
|
@@ -1206,9 +1275,22 @@ export function createSwarm({
|
|
|
1206
1275
|
// Where a thread works, for the composer (folders.mjs): the folders the person works in, any folder on the computer
|
|
1207
1276
|
// from a typed path, and where a message would work: the folder chosen (`folder`) or the one Harness suggests, and
|
|
1208
1277
|
// where each coding agent named in it (`text`, `to`, `agents`) runs its turns there.
|
|
1278
|
+
// `computer`: another of the person's computers, whose own folders are listed (asked there).
|
|
1279
|
+
const listedOn = request.computer
|
|
1280
|
+
? computerFor({ id: String(request.computer) })
|
|
1281
|
+
: null;
|
|
1209
1282
|
if (command === "board.swarm.places")
|
|
1210
|
-
return
|
|
1211
|
-
|
|
1283
|
+
return listedOn
|
|
1284
|
+
? { pending: computers.foldersOn(listedOn.id, { places: true }) }
|
|
1285
|
+
: { ok: true, places: folders.known(), home: os.homedir() };
|
|
1286
|
+
if (command === "board.swarm.browse")
|
|
1287
|
+
return listedOn
|
|
1288
|
+
? {
|
|
1289
|
+
pending: computers.foldersOn(listedOn.id, {
|
|
1290
|
+
browse: String(request.path ?? ""),
|
|
1291
|
+
}),
|
|
1292
|
+
}
|
|
1293
|
+
: folders.browse(request.path);
|
|
1212
1294
|
if (command === "board.swarm.place") {
|
|
1213
1295
|
const text = String(request.text || "").slice(0, 20_000);
|
|
1214
1296
|
const to = recipient(request);
|
|
@@ -1223,19 +1305,31 @@ export function createSwarm({
|
|
|
1223
1305
|
: []),
|
|
1224
1306
|
]),
|
|
1225
1307
|
];
|
|
1308
|
+
const on =
|
|
1309
|
+
listedOn ??
|
|
1310
|
+
computerFor({ address: computerAddress(text, "user"), team });
|
|
1311
|
+
if (request.noFolder === true)
|
|
1312
|
+
return placeOf(null, team, "you", null, on);
|
|
1226
1313
|
if (request.folder) {
|
|
1227
1314
|
const folder = String(request.folder);
|
|
1315
|
+
if (on)
|
|
1316
|
+
return path.isAbsolute(folder)
|
|
1317
|
+
? placeOf(folder, team, "you", null, on)
|
|
1318
|
+
: { ok: false, error: `${folder} is not a full path` };
|
|
1228
1319
|
return isDir(folder)
|
|
1229
1320
|
? placeOf(path.resolve(folder), team, "you")
|
|
1230
1321
|
: { ok: false, error: `${folder} is not a folder on this computer` };
|
|
1231
1322
|
}
|
|
1232
|
-
if (!needsFolder(team)) return placeOf(null, team, null);
|
|
1323
|
+
if (!needsFolder(team)) return placeOf(null, team, null, null, on);
|
|
1233
1324
|
return {
|
|
1234
1325
|
pending: folders
|
|
1235
1326
|
.suggest(text, team)
|
|
1236
|
-
.then(({ folder, by, lastWorked }) =>
|
|
1237
|
-
placeOf(folder, team, by, lastWorked)
|
|
1238
|
-
|
|
1327
|
+
.then(({ folder, by, lastWorked }) => {
|
|
1328
|
+
if (!on) return placeOf(folder, team, by, lastWorked);
|
|
1329
|
+
// Harness picks among the folders here; the computer named works in its checkout of the same repository.
|
|
1330
|
+
const there = folder ? computers.checkoutOn(on.id, folder) : null;
|
|
1331
|
+
return placeOf(there, team, there ? by : null, null, on);
|
|
1332
|
+
}),
|
|
1239
1333
|
};
|
|
1240
1334
|
}
|
|
1241
1335
|
// The person's own note on one agent's card ("use it for reviews"), told to every other agent; no text clears it.
|
|
@@ -1458,9 +1552,9 @@ export function createSwarm({
|
|
|
1458
1552
|
.slice(0, 20_000);
|
|
1459
1553
|
if (!text) return { ok: false, error: "a thread starts with a message" };
|
|
1460
1554
|
// From a chat outside any thread (the buddy's box, the phone's New message): words for one agent already at work
|
|
1461
|
-
//
|
|
1555
|
+
// ask whether they go to its thread or start this one; for it on a computer it is not at work on, this one starts.
|
|
1462
1556
|
const steering = request.steer === true ? steerFromChat(request) : null;
|
|
1463
|
-
if (steering) return steering;
|
|
1557
|
+
if (steering && !steering.newThread) return steering;
|
|
1464
1558
|
// What it may spend of the person's Harness credits, set once as it starts.
|
|
1465
1559
|
const ceiling = ceilingFrom(request.ceilingUsd);
|
|
1466
1560
|
if (ceiling === undefined)
|
|
@@ -1470,11 +1564,8 @@ export function createSwarm({
|
|
|
1470
1564
|
? request.continueSession
|
|
1471
1565
|
: null;
|
|
1472
1566
|
let folder = request.folder ? String(request.folder) : null;
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
ok: false,
|
|
1476
|
-
error: `${folder} is not an absolute path to a folder`,
|
|
1477
|
-
};
|
|
1567
|
+
// The person chose no folder: its agents work in a scratch folder, and Harness picks none.
|
|
1568
|
+
const noFolder = request.noFolder === true && !folder;
|
|
1478
1569
|
const to = recipient(request);
|
|
1479
1570
|
if (to === false)
|
|
1480
1571
|
return {
|
|
@@ -1490,6 +1581,17 @@ export function createSwarm({
|
|
|
1490
1581
|
const target = request.targetMachine ?? null;
|
|
1491
1582
|
const address = computerAddress(text, "user", { target });
|
|
1492
1583
|
if (!address.ok) return { ok: false, error: address.error };
|
|
1584
|
+
// `computer`: the other computer the folder is on (its composer listed that computer's folders). A folder of this
|
|
1585
|
+
// computer's stays the thread's; another computer works in its own checkout of it, else a scratch folder.
|
|
1586
|
+
const folderOn =
|
|
1587
|
+
folder && request.computer
|
|
1588
|
+
? computerFor({ id: String(request.computer) })
|
|
1589
|
+
: null;
|
|
1590
|
+
if (folder && !(folderOn ? path.isAbsolute(folder) : isDir(folder)))
|
|
1591
|
+
return {
|
|
1592
|
+
ok: false,
|
|
1593
|
+
error: `${folder} is not an absolute path to a folder`,
|
|
1594
|
+
};
|
|
1493
1595
|
if (from) {
|
|
1494
1596
|
const agentName = String(from.agent || ""),
|
|
1495
1597
|
sessionId = String(from.sessionId || "");
|
|
@@ -1530,10 +1632,11 @@ export function createSwarm({
|
|
|
1530
1632
|
provenance: provenanceFor("user"),
|
|
1531
1633
|
team: [...new Set(team)],
|
|
1532
1634
|
facilitator: DISPATCHER,
|
|
1533
|
-
workspace: where ? path.resolve(where) : null,
|
|
1635
|
+
workspace: !folderOn && where ? path.resolve(where) : null,
|
|
1534
1636
|
maxPosts: defaults.maxPosts,
|
|
1535
1637
|
maxWakes: defaults.maxWakes,
|
|
1536
1638
|
});
|
|
1639
|
+
if (folderOn) setFolderAway(thread.id, folderOn, where);
|
|
1537
1640
|
if (ceiling !== null) setCeiling(thread.id, ceiling);
|
|
1538
1641
|
if (from) {
|
|
1539
1642
|
store.setGoalSession(
|
|
@@ -1562,7 +1665,7 @@ export function createSwarm({
|
|
|
1562
1665
|
notifyBoard(store.getTask(id));
|
|
1563
1666
|
return { ok: true, thread: summary(store.getTask(id)) };
|
|
1564
1667
|
};
|
|
1565
|
-
if (folder || !needsFolder([...team])) {
|
|
1668
|
+
if (folder || noFolder || !needsFolder([...team])) {
|
|
1566
1669
|
const thread = begin(folder);
|
|
1567
1670
|
hear(thread);
|
|
1568
1671
|
return started(thread);
|
|
@@ -1582,7 +1685,7 @@ export function createSwarm({
|
|
|
1582
1685
|
void suggestion.then(({ folder: picked }) => {
|
|
1583
1686
|
const now = store.getTask(thread.id);
|
|
1584
1687
|
if (now?.status !== "open") return;
|
|
1585
|
-
if (picked && !now.goal.workspace)
|
|
1688
|
+
if (picked && !now.goal.workspace && !folderAway(thread.id))
|
|
1586
1689
|
store.setGoalFolder(thread.id, path.resolve(picked));
|
|
1587
1690
|
hear(thread);
|
|
1588
1691
|
notifyBoard(store.getTask(thread.id));
|
|
@@ -1989,12 +2092,15 @@ export function createSwarm({
|
|
|
1989
2092
|
if (thread.status !== "paused")
|
|
1990
2093
|
return { ok: false, error: `the thread is ${thread.status}` };
|
|
1991
2094
|
store.setGoalState(thread.id, { status: "open" });
|
|
1992
|
-
store.roomPost({
|
|
2095
|
+
const resumedNote = store.roomPost({
|
|
1993
2096
|
goalId: thread.id,
|
|
1994
2097
|
author: "user",
|
|
1995
2098
|
kind: "note",
|
|
1996
2099
|
text: "Resumed by you.",
|
|
1997
2100
|
});
|
|
2101
|
+
// What came in since, the coordinator reads from here: a pause with nothing new since is not applied again.
|
|
2102
|
+
if (resumedNote)
|
|
2103
|
+
store.meta(`resumed-note:${thread.id}`, String(resumedNote.seq));
|
|
1998
2104
|
// A one-time check-in held while the thread was paused runs now.
|
|
1999
2105
|
schedules?.tick();
|
|
2000
2106
|
notifyBoard(store.getTask(thread.id));
|
|
@@ -2003,15 +2109,26 @@ export function createSwarm({
|
|
|
2003
2109
|
}
|
|
2004
2110
|
// The person moves the thread to another folder between turns. Each agent starts a new session there, as a session
|
|
2005
2111
|
// and a T3 thread belong to the folder they ran in.
|
|
2112
|
+
// `noFolder`: to a scratch folder; `computer`: to a folder on another of the person's computers.
|
|
2006
2113
|
if (command === "board.swarm.folder") {
|
|
2007
|
-
const
|
|
2008
|
-
|
|
2114
|
+
const on = request.computer
|
|
2115
|
+
? computerFor({ id: String(request.computer) })
|
|
2116
|
+
: null;
|
|
2117
|
+
const folder =
|
|
2118
|
+
request.noFolder === true ? null : String(request.folder || "");
|
|
2119
|
+
if (folder !== null && !(on ? path.isAbsolute(folder) : isDir(folder)))
|
|
2009
2120
|
return {
|
|
2010
2121
|
ok: false,
|
|
2011
|
-
error:
|
|
2122
|
+
error: on
|
|
2123
|
+
? `${folder} is not a full path`
|
|
2124
|
+
: `${folder} is not a folder on this computer`,
|
|
2012
2125
|
};
|
|
2013
|
-
const where = path.resolve(folder);
|
|
2014
|
-
|
|
2126
|
+
const where = folder && !on ? path.resolve(folder) : folder;
|
|
2127
|
+
const away = folderAway(thread.id);
|
|
2128
|
+
const now = away
|
|
2129
|
+
? { machine: away.machine, path: away.path }
|
|
2130
|
+
: { machine: null, path: thread.goal.workspace ?? null };
|
|
2131
|
+
if (where === now.path && (on?.id ?? null) === now.machine)
|
|
2015
2132
|
return { ok: true, thread: summary(thread) };
|
|
2016
2133
|
if (
|
|
2017
2134
|
store
|
|
@@ -2025,7 +2142,9 @@ export function createSwarm({
|
|
|
2025
2142
|
};
|
|
2026
2143
|
const moved = worktrees.moved(thread.id);
|
|
2027
2144
|
if (!moved.ok) return moved;
|
|
2028
|
-
store.setGoalFolder(thread.id, where);
|
|
2145
|
+
store.setGoalFolder(thread.id, on ? null : where);
|
|
2146
|
+
setFolderAway(thread.id, on, on ? where : null);
|
|
2147
|
+
if (away && !on) store.meta(`thread-work-computer:${thread.id}`, "");
|
|
2029
2148
|
for (const name of Object.keys(thread.goal.sessions || {}))
|
|
2030
2149
|
store.setGoalSession(thread.id, name, null);
|
|
2031
2150
|
for (const name of thread.goal.team)
|
|
@@ -2035,7 +2154,11 @@ export function createSwarm({
|
|
|
2035
2154
|
goalId: thread.id,
|
|
2036
2155
|
author: "user",
|
|
2037
2156
|
kind: "note",
|
|
2038
|
-
text:
|
|
2157
|
+
text: !where
|
|
2158
|
+
? "Now working in a scratch folder."
|
|
2159
|
+
: on
|
|
2160
|
+
? `Now working in ${where} on ${on.label}.`
|
|
2161
|
+
: `Now working in ${where}.`,
|
|
2039
2162
|
});
|
|
2040
2163
|
notifyBoard(store.getTask(thread.id));
|
|
2041
2164
|
return { ok: true, thread: summary(store.getTask(thread.id)) };
|