tryharness 0.7.44 → 0.7.53
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 +232 -12
- package/cli.mjs +406 -184
- package/lib/actorRoster.mjs +28 -5
- package/lib/adapters.mjs +9 -1
- package/lib/agentRuntimeConfig.mjs +36 -0
- package/lib/agentRuntimes.mjs +560 -0
- package/lib/atlas.mjs +7 -2
- package/lib/boardCommands.mjs +5 -10
- package/lib/boardFileCommands.mjs +2 -1
- package/lib/boardMirror.mjs +459 -0
- package/lib/boardProtocol.json +259 -6
- package/lib/boardTools.mjs +2 -6
- package/lib/bridge.mjs +27 -3
- package/lib/browserWake.mjs +60 -0
- package/lib/cards.mjs +35 -2
- package/lib/commands.mjs +20 -5
- package/lib/connectionTools.d.ts +13 -0
- package/lib/connectionTools.js +45 -0
- package/lib/connectorAuth.mjs +309 -0
- package/lib/connectorCatalog.json +41 -0
- package/lib/connectorCommands.mjs +121 -0
- package/lib/connectorGoogle.mjs +513 -0
- package/lib/connectors.mjs +805 -0
- package/lib/coordinator.mjs +16 -2
- package/lib/coreModels.mjs +78 -0
- package/lib/daemon.mjs +775 -46
- package/lib/desktop.mjs +7 -2
- package/lib/digest.mjs +32 -0
- package/lib/directLink.mjs +283 -0
- package/lib/environments.mjs +595 -0
- package/lib/folders.mjs +2 -2
- package/lib/goalCommands.mjs +61 -12
- package/lib/inference.mjs +263 -152
- package/lib/lessons.mjs +6 -0
- package/lib/lineup.mjs +324 -0
- package/lib/localmodels.mjs +10 -0
- package/lib/machineIdentity.mjs +3 -0
- package/lib/machineRoutes.mjs +40 -2
- package/lib/machineRuns.mjs +30 -3
- package/lib/machineSeal.mjs +69 -10
- package/lib/mcp-stdio.mjs +180 -98
- package/lib/mcpRelay.mjs +119 -0
- package/lib/members.json +12 -0
- package/lib/members.mjs +33 -0
- package/lib/modelMemory.mjs +100 -0
- package/lib/modelTiers.json +1183 -0
- package/lib/modelTiers.mjs +133 -0
- package/lib/models.mjs +41 -8
- package/lib/museSession.mjs +119 -0
- package/lib/nativeHost.mjs +203 -0
- package/lib/network.mjs +38 -1
- package/lib/nudge.mjs +10 -2
- package/lib/onboard.mjs +430 -1
- package/lib/oneclawLocal.mjs +150 -0
- package/lib/ownMachines.mjs +521 -36
- package/lib/pairing.mjs +165 -0
- package/lib/paths.mjs +4 -0
- package/lib/phones.mjs +61 -0
- package/lib/placeCommands.mjs +27 -0
- package/lib/places.mjs +10 -2
- package/lib/plans.mjs +151 -27
- package/lib/profile.mjs +152 -0
- package/lib/projectGit.mjs +328 -0
- package/lib/projectSettings.mjs +120 -0
- package/lib/projects.mjs +2539 -0
- package/lib/readiness.mjs +283 -0
- package/lib/repoLinks.mjs +354 -0
- package/lib/roomChannels.mjs +641 -0
- package/lib/runBrief.mjs +32 -2
- package/lib/runRequests.mjs +157 -0
- package/lib/runWorker.mjs +20 -7
- package/lib/runner.mjs +67 -8
- package/lib/secretPatterns.json +55 -0
- package/lib/secrets.mjs +10 -27
- package/lib/seen.mjs +102 -0
- package/lib/service.mjs +11 -6
- package/lib/sessionControl.mjs +10 -8
- package/lib/sessionIndex.mjs +5 -3
- package/lib/store.mjs +559 -30
- package/lib/subagents.mjs +8 -4
- package/lib/swarm.mjs +379 -38
- package/lib/swarmMemory.mjs +947 -0
- package/lib/t3.mjs +43 -13
- package/lib/taskCommands.mjs +58 -5
- package/lib/taskRuns.mjs +61 -11
- package/lib/team.json +17 -15
- package/lib/team.mjs +68 -18
- package/lib/threadRuns.mjs +50 -7
- package/lib/threadView.mjs +68 -15
- package/lib/tokenizer.mjs +405 -0
- package/lib/ui.mjs +16 -2
- package/lib/usageTotals.mjs +148 -0
- package/lib/vault.mjs +1144 -0
- package/lib/vaultCloud.mjs +117 -0
- package/lib/vaultCommands.mjs +201 -0
- package/lib/vaultTools.d.ts +12 -0
- package/lib/vaultTools.js +42 -0
- package/lib/windowAsks.mjs +42 -0
- package/lib/workFocus.mjs +59 -0
- package/lib/workLinks.mjs +90 -0
- package/package.json +9 -4
package/lib/subagents.mjs
CHANGED
|
@@ -93,7 +93,11 @@ const quote = (value) => `'${String(value).replace(/'/g, "''")}'`;
|
|
|
93
93
|
* The subagents of one run: `{ id, parent, type, task, startedAt, endedAt, live, depth, steps }`, oldest first.
|
|
94
94
|
* `parent` is the subagent that spawned it, or null for the run's own session. `now` is for tests.
|
|
95
95
|
*/
|
|
96
|
-
export function createSubagents({
|
|
96
|
+
export function createSubagents({
|
|
97
|
+
now = () => Date.now(),
|
|
98
|
+
// Every value in the person's vault out of a subagent's steps (vault.mjs).
|
|
99
|
+
scrub = (value) => value,
|
|
100
|
+
} = {}) {
|
|
97
101
|
// Finished subagents by file (or OpenCode session), and Claude Code's folder for each session.
|
|
98
102
|
const done = new Map();
|
|
99
103
|
const claudeFolders = new Map();
|
|
@@ -161,7 +165,7 @@ export function createSubagents({ now = () => Date.now() } = {}) {
|
|
|
161
165
|
endedAt: open ? null : iso(mtime),
|
|
162
166
|
live: open,
|
|
163
167
|
depth: Number(meta.spawnDepth) || 1,
|
|
164
|
-
steps: lastSteps(sessionFeed("claude-code", file, 40)),
|
|
168
|
+
steps: scrub(lastSteps(sessionFeed("claude-code", file, 40))),
|
|
165
169
|
});
|
|
166
170
|
});
|
|
167
171
|
}
|
|
@@ -252,7 +256,7 @@ export function createSubagents({ now = () => Date.now() } = {}) {
|
|
|
252
256
|
endedAt: open ? null : iso(mtime),
|
|
253
257
|
live: open,
|
|
254
258
|
depth: meta.depth,
|
|
255
|
-
steps: lastSteps(sessionFeed("codex", file, 40)),
|
|
259
|
+
steps: scrub(lastSteps(sessionFeed("codex", file, 40))),
|
|
256
260
|
});
|
|
257
261
|
});
|
|
258
262
|
}
|
|
@@ -299,7 +303,7 @@ export function createSubagents({ now = () => Date.now() } = {}) {
|
|
|
299
303
|
endedAt: open ? null : iso(Number(row.time_updated)),
|
|
300
304
|
live: open,
|
|
301
305
|
depth: Number(row.depth) || 1,
|
|
302
|
-
steps: lastSteps(steps),
|
|
306
|
+
steps: scrub(lastSteps(steps)),
|
|
303
307
|
});
|
|
304
308
|
});
|
|
305
309
|
}
|
package/lib/swarm.mjs
CHANGED
|
@@ -4,9 +4,19 @@ import path from "node:path";
|
|
|
4
4
|
import { spawnSync } from "node:child_process";
|
|
5
5
|
import { readRunSteps } from "./runner.mjs";
|
|
6
6
|
import { createSubagents } from "./subagents.mjs";
|
|
7
|
-
import { nameOf, resolveMember } from "./members.mjs";
|
|
8
|
-
import {
|
|
7
|
+
import { MACHINE_RUNNERS, member, nameOf, resolveMember } from "./members.mjs";
|
|
8
|
+
import {
|
|
9
|
+
setNote,
|
|
10
|
+
setTier,
|
|
11
|
+
swarmBlock,
|
|
12
|
+
swarmCards,
|
|
13
|
+
swarmDigest,
|
|
14
|
+
youLine,
|
|
15
|
+
} from "./cards.mjs";
|
|
16
|
+
import { TIERS } from "./modelTiers.mjs";
|
|
9
17
|
import { askOfRun } from "./threadView.mjs";
|
|
18
|
+
import { createWorkFocus } from "./workFocus.mjs";
|
|
19
|
+
import { createWorkLinks } from "./workLinks.mjs";
|
|
10
20
|
import {
|
|
11
21
|
DEFAULT_ROUTING,
|
|
12
22
|
PICKABLE,
|
|
@@ -29,6 +39,12 @@ export const PROCESS_NAMES = {
|
|
|
29
39
|
codex: "codex",
|
|
30
40
|
pi: "pi",
|
|
31
41
|
opencode: "opencode",
|
|
42
|
+
...Object.fromEntries(
|
|
43
|
+
MACHINE_RUNNERS.filter((id) => member(id)?.runtime).map((id) => [
|
|
44
|
+
id,
|
|
45
|
+
member(id).runtime.command,
|
|
46
|
+
])
|
|
47
|
+
),
|
|
32
48
|
};
|
|
33
49
|
const SAY_LIMIT = 4_000;
|
|
34
50
|
// `@swarm` in the person's message: written to their whole swarm, not to one agent.
|
|
@@ -83,6 +99,8 @@ export function agentProcessCwds(exclude = new Set()) {
|
|
|
83
99
|
|
|
84
100
|
export function createSwarm({
|
|
85
101
|
store,
|
|
102
|
+
// What this computer hands the person's Harness page through the extension (browserWake.mjs).
|
|
103
|
+
browserWake = null,
|
|
86
104
|
roomAgents,
|
|
87
105
|
mentionsIn,
|
|
88
106
|
wakeFor,
|
|
@@ -96,8 +114,12 @@ export function createSwarm({
|
|
|
96
114
|
coordinator,
|
|
97
115
|
worktrees,
|
|
98
116
|
roster,
|
|
117
|
+
// The coding agents here waiting to join the swarm, with their last check (readiness.mjs), for the person's browser.
|
|
118
|
+
joining = () => [],
|
|
99
119
|
// Which of the person's computers each coding agent is on (actorRoster.mjs), when there are several.
|
|
100
120
|
withMachines = (card) => card,
|
|
121
|
+
// Where an agent calling from a computer is (ownMachines.mjs whereIs), for what it is told of itself; null when unknown.
|
|
122
|
+
whereIs = () => null,
|
|
101
123
|
authorizeRun,
|
|
102
124
|
pickable,
|
|
103
125
|
listModels,
|
|
@@ -112,13 +134,38 @@ export function createSwarm({
|
|
|
112
134
|
// The person's post read for their reaction and for lessons (reactions.mjs, lessons.mjs), and what was learned.
|
|
113
135
|
heardPerson = () => {},
|
|
114
136
|
lessons = null,
|
|
137
|
+
// The swarm's long-running memory (swarmMemory.mjs): what swarm_memory recalls, and what the person forgets.
|
|
138
|
+
memory = null,
|
|
115
139
|
// The subagents each run's own session spawned (subagents.mjs), for the thread's canvas.
|
|
116
140
|
subagents = createSubagents(),
|
|
117
141
|
// Work wired to wait for other work in the thread (plans.mjs).
|
|
118
142
|
plansOf = () => [],
|
|
119
143
|
// The thread as the person reads it on every surface (threadView.mjs).
|
|
120
144
|
threadView = null,
|
|
145
|
+
// The project a thread is the room of, shared with another person's swarm (projects.mjs).
|
|
146
|
+
projectOf = () => null,
|
|
147
|
+
// The person's words name an agent of the other side of a shared project: theirs to answer, not this swarm's to sort.
|
|
148
|
+
addressesPartner = () => false,
|
|
149
|
+
environments = null,
|
|
150
|
+
notifyFocus = () => {},
|
|
121
151
|
}) {
|
|
152
|
+
const focus = createWorkFocus({ store });
|
|
153
|
+
const readWork = async (id, hostedCaller = false) => {
|
|
154
|
+
if (environments?.owns(id)) return environments.read(id);
|
|
155
|
+
const local = store.getTask(String(id || ""));
|
|
156
|
+
return local?.kind === "goal"
|
|
157
|
+
? read(local, hostedCaller)
|
|
158
|
+
: { ok: false, error: "Work thread not found." };
|
|
159
|
+
};
|
|
160
|
+
const related = createWorkLinks({ store, readWork });
|
|
161
|
+
const linkedRevision = (id) => {
|
|
162
|
+
if (environments?.owns(id)) {
|
|
163
|
+
const source = environments.roots().find((entry) => entry.id === id);
|
|
164
|
+
return source ? focus.decorate(source).focus.revision : null;
|
|
165
|
+
}
|
|
166
|
+
const local = store.getTask(id);
|
|
167
|
+
return local?.kind === "goal" ? summary(local, false).focus.revision : null;
|
|
168
|
+
};
|
|
122
169
|
// What the person let a thread spend of their Harness credits, in dollars, or null for no limit of its own.
|
|
123
170
|
const ceilingOf = (threadId) => {
|
|
124
171
|
const limit = Number(store.meta(`spend-ceiling:${threadId}`));
|
|
@@ -212,15 +259,18 @@ export function createSwarm({
|
|
|
212
259
|
: null;
|
|
213
260
|
};
|
|
214
261
|
|
|
215
|
-
const summary = (thread) => {
|
|
262
|
+
const summary = (thread, includeRelated = true) => {
|
|
216
263
|
const posts = store.roomPosts(thread.id, 0, 500);
|
|
217
264
|
const runs = store.threadRuns(thread.id);
|
|
218
265
|
const last = posts.at(-1);
|
|
219
266
|
const live = runs.find((run) => run.status === "running");
|
|
220
267
|
const step = live ? readRunSteps(runLog(live.id), 1)[0] : null;
|
|
221
268
|
const view = threadView?.row(thread, posts) ?? null;
|
|
222
|
-
return {
|
|
269
|
+
return focus.decorate({
|
|
223
270
|
id: thread.id,
|
|
271
|
+
relatedVersion: includeRelated
|
|
272
|
+
? related.version(thread.id, linkedRevision)
|
|
273
|
+
: null,
|
|
224
274
|
title: view?.title ?? thread.objective,
|
|
225
275
|
objective: thread.objective,
|
|
226
276
|
// The same title, state, line and needs-you items on every surface (threadView.mjs).
|
|
@@ -297,7 +347,9 @@ export function createSwarm({
|
|
|
297
347
|
checkIns: schedules?.list({ threadId: thread.id }) ?? [],
|
|
298
348
|
ceilingUsd: ceilingOf(thread.id),
|
|
299
349
|
changes: worktrees.summary(thread.id),
|
|
300
|
-
|
|
350
|
+
// A project shared with another person's swarm (projects.mjs): which, and with whom.
|
|
351
|
+
project: projectOf(thread.id),
|
|
352
|
+
});
|
|
301
353
|
};
|
|
302
354
|
|
|
303
355
|
// The person's terminal sessions not yet in a thread, newest first, each saying whether it is still open there.
|
|
@@ -415,7 +467,7 @@ export function createSwarm({
|
|
|
415
467
|
const posts = store.roomPosts(thread.id, 0, 500);
|
|
416
468
|
return {
|
|
417
469
|
ok: true,
|
|
418
|
-
thread: summary(thread),
|
|
470
|
+
thread: summary(thread, !hostedCaller),
|
|
419
471
|
posts,
|
|
420
472
|
// The thread in order as the person reads it: messages, steps gathered into groups, files (threadView.mjs).
|
|
421
473
|
timeline: threadView?.timeline(thread, posts) ?? [],
|
|
@@ -438,6 +490,8 @@ export function createSwarm({
|
|
|
438
490
|
|
|
439
491
|
// `to`: the one agent the person wrote to (the desktop's agent list), so their words go as written, with no @name.
|
|
440
492
|
const post = (thread, text, to = null) => {
|
|
493
|
+
if (projectOf(thread.id)?.status === "left")
|
|
494
|
+
return { ok: false, error: "Your participation in this room has ended." };
|
|
441
495
|
const picked = picksIn(store, text, roomAgents);
|
|
442
496
|
if (picked.error) return { ok: false, error: picked.error };
|
|
443
497
|
// A new name in the person's message joins the thread.
|
|
@@ -466,12 +520,17 @@ export function createSwarm({
|
|
|
466
520
|
},
|
|
467
521
|
"user"
|
|
468
522
|
);
|
|
469
|
-
if (
|
|
523
|
+
if (
|
|
524
|
+
!to &&
|
|
525
|
+
posted?.ok &&
|
|
526
|
+
!posted.paused &&
|
|
527
|
+
!addressesPartner(thread.id, text)
|
|
528
|
+
)
|
|
470
529
|
heardBy(current, posted.post, text);
|
|
471
530
|
return posted;
|
|
472
531
|
};
|
|
473
532
|
|
|
474
|
-
return function swarmCommand(request, agent) {
|
|
533
|
+
return function swarmCommand(request, agent, machine = null) {
|
|
475
534
|
const command = String(request.command);
|
|
476
535
|
if (command === "board.swarm.list") {
|
|
477
536
|
if (agent !== "user" && agent !== "harness")
|
|
@@ -479,14 +538,181 @@ export function createSwarm({
|
|
|
479
538
|
ok: false,
|
|
480
539
|
error: "only the person and Harness read the swarm",
|
|
481
540
|
};
|
|
482
|
-
|
|
541
|
+
const listed = () => ({
|
|
483
542
|
ok: true,
|
|
484
|
-
threads:
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
543
|
+
threads: [
|
|
544
|
+
...store
|
|
545
|
+
.goals({ all: request.all === true })
|
|
546
|
+
.filter((thread) => !SETUP_CHECK.test(thread.objective))
|
|
547
|
+
.map((thread) => summary(thread, !request.hostedCaller)),
|
|
548
|
+
...(!request.hostedCaller
|
|
549
|
+
? (environments?.roots() ?? []).map(focus.decorate)
|
|
550
|
+
: []),
|
|
551
|
+
],
|
|
488
552
|
sessions: request.sessions === false ? [] : sessions(),
|
|
489
553
|
agents: roster(),
|
|
554
|
+
joining: request.hostedCaller ? [] : joining(),
|
|
555
|
+
});
|
|
556
|
+
return environments && !request.hostedCaller
|
|
557
|
+
? { pending: environments.refresh().then(listed) }
|
|
558
|
+
: listed();
|
|
559
|
+
}
|
|
560
|
+
if (
|
|
561
|
+
[
|
|
562
|
+
"board.swarm.follow",
|
|
563
|
+
"board.swarm.seen",
|
|
564
|
+
"board.swarm.context",
|
|
565
|
+
"board.swarm.links",
|
|
566
|
+
"board.swarm.link",
|
|
567
|
+
].includes(command)
|
|
568
|
+
) {
|
|
569
|
+
if (
|
|
570
|
+
agent !== "user" ||
|
|
571
|
+
(request.hostedCaller &&
|
|
572
|
+
(environments?.owns(request.id) ||
|
|
573
|
+
environments?.owns(request.destination)))
|
|
574
|
+
)
|
|
575
|
+
return {
|
|
576
|
+
ok: false,
|
|
577
|
+
error: "Only the person manages their followed work and context.",
|
|
578
|
+
};
|
|
579
|
+
const perform = async () => {
|
|
580
|
+
if (["board.swarm.link", "board.swarm.links"].includes(command)) {
|
|
581
|
+
if (request.hostedCaller || environments?.owns(request.id))
|
|
582
|
+
return {
|
|
583
|
+
ok: false,
|
|
584
|
+
error:
|
|
585
|
+
"Manage related work on your computer or a browser linked to it.",
|
|
586
|
+
};
|
|
587
|
+
const target = store.getTask(String(request.id || ""));
|
|
588
|
+
if (target?.kind !== "goal")
|
|
589
|
+
return {
|
|
590
|
+
ok: false,
|
|
591
|
+
error: "Choose a Harness objective for this work.",
|
|
592
|
+
};
|
|
593
|
+
if (command === "board.swarm.links") return related.read(target.id);
|
|
594
|
+
const result = await related.update(request);
|
|
595
|
+
if (result.ok) notifyFocus(target.id);
|
|
596
|
+
return result;
|
|
597
|
+
}
|
|
598
|
+
const source = await readWork(
|
|
599
|
+
request.id,
|
|
600
|
+
request.hostedCaller === true
|
|
601
|
+
);
|
|
602
|
+
if (!source.ok) return source;
|
|
603
|
+
if (command !== "board.swarm.context") {
|
|
604
|
+
const result = focus.update(source.thread, request);
|
|
605
|
+
if (result.ok) notifyFocus(source.thread.id);
|
|
606
|
+
return result;
|
|
607
|
+
}
|
|
608
|
+
const selected = source.posts.find(
|
|
609
|
+
(entry) => entry.id === request.postId
|
|
610
|
+
);
|
|
611
|
+
if (
|
|
612
|
+
!selected ||
|
|
613
|
+
selected.author === "user" ||
|
|
614
|
+
!["result", "post"].includes(selected.kind)
|
|
615
|
+
)
|
|
616
|
+
return {
|
|
617
|
+
ok: false,
|
|
618
|
+
error: "Choose an agent's result from this work.",
|
|
619
|
+
};
|
|
620
|
+
if (request.destination === request.id)
|
|
621
|
+
return {
|
|
622
|
+
ok: false,
|
|
623
|
+
error: "Choose another work thread for this result.",
|
|
624
|
+
};
|
|
625
|
+
const target = await readWork(
|
|
626
|
+
request.destination,
|
|
627
|
+
request.hostedCaller === true
|
|
628
|
+
);
|
|
629
|
+
if (!target.ok) return target;
|
|
630
|
+
if (target.thread.project?.status === "left")
|
|
631
|
+
return {
|
|
632
|
+
ok: false,
|
|
633
|
+
error: "Your participation in this room has ended.",
|
|
634
|
+
};
|
|
635
|
+
if (target.thread.source && !target.thread.source.controls.send)
|
|
636
|
+
return {
|
|
637
|
+
ok: false,
|
|
638
|
+
error:
|
|
639
|
+
"The destination is read-only. Choose a thread you can message.",
|
|
640
|
+
};
|
|
641
|
+
const url = selected.source?.url ?? source.thread.source?.url ?? null;
|
|
642
|
+
const origin = source.thread.source?.environmentName ?? "Harness";
|
|
643
|
+
const attribution = `${nameOf(selected.author)} · ${origin} · ${source.thread.title}`;
|
|
644
|
+
const text = `Context from ${attribution}\n${url ?? `Harness thread: ${source.thread.id}`}\nRecorded ${selected.created_at}\n\n${selected.text}`;
|
|
645
|
+
if (text.length > 20_000)
|
|
646
|
+
return {
|
|
647
|
+
ok: false,
|
|
648
|
+
error:
|
|
649
|
+
"This result is too long for one message. Select a shorter result in its original session.",
|
|
650
|
+
};
|
|
651
|
+
return {
|
|
652
|
+
ok: true,
|
|
653
|
+
draft: {
|
|
654
|
+
text,
|
|
655
|
+
source: {
|
|
656
|
+
threadId: source.thread.id,
|
|
657
|
+
postId: selected.id,
|
|
658
|
+
author: selected.author,
|
|
659
|
+
url,
|
|
660
|
+
at: selected.created_at,
|
|
661
|
+
truncated: selected.source?.truncated === true,
|
|
662
|
+
},
|
|
663
|
+
},
|
|
664
|
+
destination: {
|
|
665
|
+
id: target.thread.id,
|
|
666
|
+
title: target.thread.title,
|
|
667
|
+
agents: target.thread.agents,
|
|
668
|
+
environment: target.thread.source?.environmentName ?? "Harness",
|
|
669
|
+
partner: target.thread.project?.partner ?? null,
|
|
670
|
+
},
|
|
671
|
+
};
|
|
672
|
+
};
|
|
673
|
+
return {
|
|
674
|
+
pending: perform().catch((error) => ({
|
|
675
|
+
ok: false,
|
|
676
|
+
error: error.message,
|
|
677
|
+
})),
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
if (environments?.owns(request.id)) {
|
|
681
|
+
if (request.hostedCaller || !["user", "harness"].includes(agent))
|
|
682
|
+
return {
|
|
683
|
+
ok: false,
|
|
684
|
+
error: "Outside sessions are private to the person.",
|
|
685
|
+
};
|
|
686
|
+
const pending = (operation) => ({
|
|
687
|
+
pending: operation.catch((error) => ({
|
|
688
|
+
ok: false,
|
|
689
|
+
error: error.message,
|
|
690
|
+
})),
|
|
691
|
+
});
|
|
692
|
+
if (command === "board.swarm.read")
|
|
693
|
+
return pending(
|
|
694
|
+
environments
|
|
695
|
+
.read(request.id)
|
|
696
|
+
.then((result) =>
|
|
697
|
+
result.ok
|
|
698
|
+
? { ...result, thread: focus.decorate(result.thread) }
|
|
699
|
+
: result
|
|
700
|
+
)
|
|
701
|
+
);
|
|
702
|
+
if (command === "board.swarm.post" || command === "board.swarm.stop")
|
|
703
|
+
return pending(
|
|
704
|
+
environments.control(
|
|
705
|
+
{
|
|
706
|
+
...request,
|
|
707
|
+
action: command === "board.swarm.stop" ? "stop" : "send",
|
|
708
|
+
},
|
|
709
|
+
agent
|
|
710
|
+
)
|
|
711
|
+
);
|
|
712
|
+
return {
|
|
713
|
+
ok: false,
|
|
714
|
+
error:
|
|
715
|
+
"This work belongs to its source environment. Open its original session for this action.",
|
|
490
716
|
};
|
|
491
717
|
}
|
|
492
718
|
// The swarm's shared memory, for any of the person's agents: what any agent wrote in any thread, and the coding
|
|
@@ -496,26 +722,35 @@ export function createSwarm({
|
|
|
496
722
|
.trim()
|
|
497
723
|
.slice(0, 500);
|
|
498
724
|
if (!query) return { ok: false, error: "search needs a query" };
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
.map((thread) => thread.id)
|
|
504
|
-
: null;
|
|
725
|
+
const hosted = Boolean(request.teamOnly) || request.hostedCaller === true;
|
|
726
|
+
const sessions = hosted ? [] : store.search({ query, limit: 5 });
|
|
727
|
+
if (!memory)
|
|
728
|
+
return { ok: true, threads: [], sessions, lessons: [], weak: true };
|
|
505
729
|
return {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
730
|
+
pending: memory
|
|
731
|
+
.recall(query, {
|
|
732
|
+
agent,
|
|
733
|
+
teamOnly: Boolean(request.teamOnly),
|
|
734
|
+
hosted,
|
|
735
|
+
everyFolder: true,
|
|
736
|
+
})
|
|
737
|
+
.then((found) => ({
|
|
738
|
+
ok: true,
|
|
739
|
+
// Posts, job results and receipts with their thread, author and time; a receipt is checked by code.
|
|
740
|
+
threads: found.posts,
|
|
741
|
+
sessions,
|
|
742
|
+
// What the person told the swarm, and what the dream keeps, to a caller on this computer.
|
|
743
|
+
lessons: found.lessons,
|
|
744
|
+
observations: found.observations,
|
|
745
|
+
// What the person saw (seen.mjs), when the person searches.
|
|
746
|
+
...(found.seen?.length ? { seen: found.seen } : {}),
|
|
747
|
+
weak: found.weak,
|
|
748
|
+
...(found.weak
|
|
749
|
+
? {
|
|
750
|
+
note: "Nothing closely matches: these are only the nearest. Say it was not found rather than relying on them.",
|
|
751
|
+
}
|
|
752
|
+
: {}),
|
|
753
|
+
})),
|
|
519
754
|
};
|
|
520
755
|
}
|
|
521
756
|
// Who can be asked: every other agent's card (cards.mjs), and the same cards as the block an agent is told when its
|
|
@@ -529,10 +764,14 @@ export function createSwarm({
|
|
|
529
764
|
{ lessons: local }
|
|
530
765
|
).map(withMachines);
|
|
531
766
|
const told = local ? (lessons?.told() ?? []) : [];
|
|
767
|
+
// Who is asking, and on which computer, ahead of everyone else.
|
|
768
|
+
const you = local ? youLine(agent, whereIs(machine)) : "";
|
|
532
769
|
return {
|
|
533
770
|
ok: true,
|
|
534
771
|
agents,
|
|
535
|
-
text: swarmBlock(agents, Date.now(), told)
|
|
772
|
+
text: [you, swarmBlock(agents, Date.now(), told)]
|
|
773
|
+
.filter(Boolean)
|
|
774
|
+
.join("\n\n"),
|
|
536
775
|
digest: swarmDigest(agents, told),
|
|
537
776
|
};
|
|
538
777
|
}
|
|
@@ -577,7 +816,7 @@ export function createSwarm({
|
|
|
577
816
|
});
|
|
578
817
|
// Harness's catalog is read the first time it is shown, once the server can send it.
|
|
579
818
|
return request.refresh === true && agent === "user"
|
|
580
|
-
? { pending: listModels().then(listing) }
|
|
819
|
+
? { pending: listModels({ protocols: true }).then(listing) }
|
|
581
820
|
: !named && !harnessModel.listed() && agent === "user"
|
|
582
821
|
? { pending: harnessModel.refresh().then(listing) }
|
|
583
822
|
: listing();
|
|
@@ -632,6 +871,7 @@ export function createSwarm({
|
|
|
632
871
|
kind: "post",
|
|
633
872
|
text,
|
|
634
873
|
mentions: addressed(store.getTask(thread.id), text),
|
|
874
|
+
machine,
|
|
635
875
|
});
|
|
636
876
|
wakeFor(thread.id, first, agent);
|
|
637
877
|
notifyBoard(store.getTask(thread.id));
|
|
@@ -707,6 +947,26 @@ export function createSwarm({
|
|
|
707
947
|
note: setNote(store, named.id, request.text),
|
|
708
948
|
};
|
|
709
949
|
}
|
|
950
|
+
// The person's own tier for one agent, which wins over its model's benchmark tier for the roles with a floor
|
|
951
|
+
// (team.json); "auto" goes back to the benchmark's.
|
|
952
|
+
if (command === "board.swarm.tier") {
|
|
953
|
+
if (agent !== "user")
|
|
954
|
+
return { ok: false, error: "only the person sets an agent's tier" };
|
|
955
|
+
const named = resolveMember(request.target);
|
|
956
|
+
if (!named.ok)
|
|
957
|
+
return {
|
|
958
|
+
ok: false,
|
|
959
|
+
error: named.candidates.length
|
|
960
|
+
? `"${request.target}" could be ${named.candidates.join(" or ")}; name one`
|
|
961
|
+
: `no agent called "${request.target}"`,
|
|
962
|
+
};
|
|
963
|
+
const tier = String(request.tier || "").toLowerCase();
|
|
964
|
+
if (![...TIERS, "auto"].includes(tier))
|
|
965
|
+
return { ok: false, error: "a tier is top, middle, bottom or auto" };
|
|
966
|
+
setTier(store, named.id, tier === "auto" ? null : tier);
|
|
967
|
+
const card = swarmCards(store, [{ id: named.id }])[0];
|
|
968
|
+
return { ok: true, agent: named.id, tier: card?.tier ?? null };
|
|
969
|
+
}
|
|
710
970
|
// The person's choice of model and effort for one agent: a model it lists, "auto", or "default" for its own settings.
|
|
711
971
|
if (command === "board.swarm.model") {
|
|
712
972
|
const named = resolveMember(request.target);
|
|
@@ -878,7 +1138,12 @@ export function createSwarm({
|
|
|
878
1138
|
ok: true,
|
|
879
1139
|
lessons: (
|
|
880
1140
|
lessons?.list({
|
|
881
|
-
status:
|
|
1141
|
+
status:
|
|
1142
|
+
request.retired === true
|
|
1143
|
+
? "retired"
|
|
1144
|
+
: request.replaced === true
|
|
1145
|
+
? "replaced"
|
|
1146
|
+
: "active",
|
|
882
1147
|
}) ?? []
|
|
883
1148
|
).map((lesson) => {
|
|
884
1149
|
const last = lesson.evidence.at(-1);
|
|
@@ -905,9 +1170,17 @@ export function createSwarm({
|
|
|
905
1170
|
};
|
|
906
1171
|
if (command === "board.swarm.lessons.remove") {
|
|
907
1172
|
const removed = lessons?.remove(request.id);
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
1173
|
+
if (!removed)
|
|
1174
|
+
return { ok: false, error: "no lesson starts with that id" };
|
|
1175
|
+
// The words it came from stop coming back through search and briefs too, so the swarm does not learn it again
|
|
1176
|
+
// from them (eval memory-swarm); they stay in their thread.
|
|
1177
|
+
memory?.forget({
|
|
1178
|
+
ids: removed.evidence.map((entry) => entry.postId).filter(Boolean),
|
|
1179
|
+
mode: "release",
|
|
1180
|
+
by: `lesson:${removed.id}`,
|
|
1181
|
+
reason: "the person took the lesson out",
|
|
1182
|
+
});
|
|
1183
|
+
return { ok: true, lesson: removed };
|
|
911
1184
|
}
|
|
912
1185
|
if (command === "board.swarm.lessons.undo")
|
|
913
1186
|
return {
|
|
@@ -936,6 +1209,43 @@ export function createSwarm({
|
|
|
936
1209
|
}
|
|
937
1210
|
),
|
|
938
1211
|
};
|
|
1212
|
+
// The swarm's memory (swarmMemory.mjs), the person's: what the dream keeps, what was forgotten or replaced and the
|
|
1213
|
+
// last dream; forgetting posts, lessons or observations by id, Undo, and a dream now.
|
|
1214
|
+
if (command === "board.swarm.memory")
|
|
1215
|
+
return {
|
|
1216
|
+
ok: true,
|
|
1217
|
+
observations: memory?.observations() ?? [],
|
|
1218
|
+
seen: memory?.seen() ?? [],
|
|
1219
|
+
forgotten: store.memoryMarks(),
|
|
1220
|
+
dream: memory?.lastDream() ?? null,
|
|
1221
|
+
};
|
|
1222
|
+
if (command === "board.swarm.forget") {
|
|
1223
|
+
const mode = request.mode === "purge" ? "purge" : "release";
|
|
1224
|
+
const forgotten =
|
|
1225
|
+
memory?.forget({
|
|
1226
|
+
ids: Array.isArray(request.ids) ? request.ids.map(String) : [],
|
|
1227
|
+
mode,
|
|
1228
|
+
by: "user",
|
|
1229
|
+
reason: request.reason ? String(request.reason).slice(0, 200) : null,
|
|
1230
|
+
}) ?? [];
|
|
1231
|
+
return forgotten.length
|
|
1232
|
+
? { ok: true, forgotten }
|
|
1233
|
+
: { ok: false, error: "nothing with those ids to forget" };
|
|
1234
|
+
}
|
|
1235
|
+
if (command === "board.swarm.unforget") {
|
|
1236
|
+
const back = memory?.unforget(String(request.id || ""));
|
|
1237
|
+
return back
|
|
1238
|
+
? { ok: true, back }
|
|
1239
|
+
: {
|
|
1240
|
+
ok: false,
|
|
1241
|
+
error:
|
|
1242
|
+
"nothing to bring back with that id (deleted words are gone for good)",
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
if (command === "board.swarm.dream")
|
|
1246
|
+
return memory
|
|
1247
|
+
? { pending: memory.dream() }
|
|
1248
|
+
: { ok: false, error: "this daemon keeps no memory" };
|
|
939
1249
|
// Check-ins (schedules.mjs), the person's: only the person gets this far, and the lead sets its own in its rounds
|
|
940
1250
|
// (coordinator.mjs). Every thread's, or ending one by its own id.
|
|
941
1251
|
if (command === "board.swarm.checkins" && !request.id)
|
|
@@ -1038,6 +1348,32 @@ export function createSwarm({
|
|
|
1038
1348
|
? { ok: true, thread: summary(store.getTask(thread.id)) }
|
|
1039
1349
|
: done;
|
|
1040
1350
|
}
|
|
1351
|
+
// The person lets Harness finish in their browser now what it left for the browser (owner, October 22: "right
|
|
1352
|
+
// away, even if away"): their extension's hidden Harness page takes it, claiming it only once this is recorded.
|
|
1353
|
+
if (command === "board.swarm.use_browser") {
|
|
1354
|
+
if (agent !== "user")
|
|
1355
|
+
return { ok: false, error: "only you let Harness use your browser" };
|
|
1356
|
+
const run = store
|
|
1357
|
+
.threadRuns(thread.id)
|
|
1358
|
+
.find((candidate) => candidate.id === String(request.runId || ""));
|
|
1359
|
+
if (
|
|
1360
|
+
!run ||
|
|
1361
|
+
run.target_agent !== "harness" ||
|
|
1362
|
+
run.status !== "open" ||
|
|
1363
|
+
!store.meta(`harness-window:${run.id}`)
|
|
1364
|
+
)
|
|
1365
|
+
return { ok: false, error: "that is not waiting for your browser" };
|
|
1366
|
+
if (!browserWake?.listening())
|
|
1367
|
+
return {
|
|
1368
|
+
ok: false,
|
|
1369
|
+
error:
|
|
1370
|
+
"your browser is not connected to this computer; open Harness on your computer instead",
|
|
1371
|
+
};
|
|
1372
|
+
store.meta(`harness-browser-allowed:${run.id}`, new Date().toISOString());
|
|
1373
|
+
browserWake.send({ kind: "board-task", task: run.id });
|
|
1374
|
+
notifyBoard(store.getTask(thread.id));
|
|
1375
|
+
return { ok: true, thread: summary(store.getTask(thread.id)) };
|
|
1376
|
+
}
|
|
1041
1377
|
// The person's Start for one run in the thread that waits for it.
|
|
1042
1378
|
if (command === "board.swarm.start_run") {
|
|
1043
1379
|
const run = store
|
|
@@ -1178,6 +1514,11 @@ export function createSwarm({
|
|
|
1178
1514
|
return { ok: true, thread: summary(store.getTask(thread.id)) };
|
|
1179
1515
|
}
|
|
1180
1516
|
if (command === "board.swarm.resume") {
|
|
1517
|
+
if (projectOf(thread.id)?.status === "left")
|
|
1518
|
+
return {
|
|
1519
|
+
ok: false,
|
|
1520
|
+
error: "Your participation in this room has ended.",
|
|
1521
|
+
};
|
|
1181
1522
|
if (thread.status !== "paused")
|
|
1182
1523
|
return { ok: false, error: `the thread is ${thread.status}` };
|
|
1183
1524
|
store.setGoalState(thread.id, { status: "open" });
|