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/t3.mjs
CHANGED
|
@@ -63,6 +63,10 @@ export async function findT3(home = t3Home(), hint = null) {
|
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/** Whether T3 Code has run on this computer: it writes its environment id the first time it starts. */
|
|
67
|
+
export const t3Installed = (home = t3Home()) =>
|
|
68
|
+
fs.existsSync(path.join(home, "environment-id"));
|
|
69
|
+
|
|
66
70
|
/** What Harness may do in T3 Code: "send", "read", "expired", or null before the person approves it. */
|
|
67
71
|
export function t3Access() {
|
|
68
72
|
const saved = readJson(file(), null);
|
|
@@ -76,6 +80,8 @@ export function t3Access() {
|
|
|
76
80
|
? "send"
|
|
77
81
|
: "read",
|
|
78
82
|
until: saved.expiresAt,
|
|
83
|
+
environmentId: saved.environmentId,
|
|
84
|
+
grantedAt: saved.approvedAt,
|
|
79
85
|
};
|
|
80
86
|
}
|
|
81
87
|
|
|
@@ -330,7 +336,14 @@ async function callTool(origin, token, name, args) {
|
|
|
330
336
|
}
|
|
331
337
|
|
|
332
338
|
/** One of T3's tools, as Harness was approved to use them, at T3's current address. */
|
|
333
|
-
|
|
339
|
+
const READ_TOOLS = new Set([
|
|
340
|
+
"orchestrator_capabilities",
|
|
341
|
+
"t3_project_list",
|
|
342
|
+
"t3_thread_list",
|
|
343
|
+
"t3_thread_read",
|
|
344
|
+
]);
|
|
345
|
+
|
|
346
|
+
export async function t3Tool(name, args) {
|
|
334
347
|
const saved = readJson(file(), null);
|
|
335
348
|
const access = t3Access();
|
|
336
349
|
if (!access)
|
|
@@ -340,7 +353,7 @@ async function t3Tool(name, args) {
|
|
|
340
353
|
);
|
|
341
354
|
if (access.state === "expired")
|
|
342
355
|
throw new T3Error("expired", "Harness's approval in T3 Code ran out.");
|
|
343
|
-
if (access.state !== "send")
|
|
356
|
+
if (access.state !== "send" && !READ_TOOLS.has(name))
|
|
344
357
|
throw new T3Error(
|
|
345
358
|
"read_only",
|
|
346
359
|
"Harness was approved in T3 Code to read only."
|
|
@@ -429,6 +442,9 @@ function stepOf(item) {
|
|
|
429
442
|
|
|
430
443
|
// The option T3 gives each agent's effort under, by agent.
|
|
431
444
|
const EFFORT_OPTIONS = new Set(["reasoningEffort", "effort"]);
|
|
445
|
+
// An option's choices: `values` since T3 #22889 (October 21), `options: [{ id }]` before.
|
|
446
|
+
const choicesOf = (option) =>
|
|
447
|
+
option.values ?? option.options?.map((level) => level.id) ?? [];
|
|
432
448
|
const versionOf = (id) => (id.match(/\d+/g) ?? []).map(Number);
|
|
433
449
|
const newerFirst = (a, b) => {
|
|
434
450
|
const [left, right] = [versionOf(a.id), versionOf(b.id)];
|
|
@@ -437,6 +453,15 @@ const newerFirst = (a, b) => {
|
|
|
437
453
|
return (right[i] ?? -1) - (left[i] ?? -1);
|
|
438
454
|
return 0;
|
|
439
455
|
};
|
|
456
|
+
const matching = (provider, model) => {
|
|
457
|
+
const offered = provider?.models ?? [];
|
|
458
|
+
return (
|
|
459
|
+
offered.find((entry) => entry.id === model) ??
|
|
460
|
+
offered
|
|
461
|
+
.filter((entry) => entry.id.startsWith(`claude-${model}-`))
|
|
462
|
+
.sort(newerFirst)[0]
|
|
463
|
+
);
|
|
464
|
+
};
|
|
440
465
|
|
|
441
466
|
/**
|
|
442
467
|
* The selection T3 Code runs an agent's turn with: the model and effort the buddy shows for it (the person's pick, else
|
|
@@ -444,26 +469,31 @@ const newerFirst = (a, b) => {
|
|
|
444
469
|
* a short name (opus), which is the newest of that family T3 offers. Null when nothing names a model. A model or effort
|
|
445
470
|
* T3 does not offer fails the turn rather than letting T3 run it on another (October 17: Codex ran on gpt-6-astra
|
|
446
471
|
* for days while the buddy showed gpt-6.1-sol).
|
|
472
|
+
*
|
|
473
|
+
* Since T3 #22889 (October 21) T3 lists a short list of each agent's models and says how many it left out; a model not
|
|
474
|
+
* on it is looked up with T3's search. An older T3 lists every model and leaves out none, so it is never searched.
|
|
447
475
|
*/
|
|
448
476
|
async function selectionFor({ instanceId, model, effort } = {}) {
|
|
449
477
|
if (!model) return null;
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
478
|
+
const offering = async (args) =>
|
|
479
|
+
(await t3Tool("orchestrator_capabilities", args)).providers?.find(
|
|
480
|
+
(entry) => entry.providerInstanceId === instanceId
|
|
481
|
+
);
|
|
482
|
+
const listed = await offering({});
|
|
483
|
+
const searched =
|
|
484
|
+
!matching(listed, model) && listed?.omittedModels
|
|
485
|
+
? await offering({ search: model })
|
|
486
|
+
: null;
|
|
487
|
+
const provider = searched ?? listed;
|
|
488
|
+
const found = matching(provider, model);
|
|
459
489
|
if (!found)
|
|
460
490
|
throw new T3Error(
|
|
461
491
|
"model",
|
|
462
|
-
`T3 Code does not offer ${model} for this agent (it offers ${
|
|
492
|
+
`T3 Code does not offer ${model} for this agent (it offers ${(provider?.models ?? []).map((entry) => entry.id).join(", ") || "none"}).`
|
|
463
493
|
);
|
|
464
494
|
if (!effort) return { instanceId, model: found.id, options: [] };
|
|
465
495
|
const option = found.options?.find((entry) => EFFORT_OPTIONS.has(entry.id));
|
|
466
|
-
if (!option
|
|
496
|
+
if (!option || !choicesOf(option).includes(effort))
|
|
467
497
|
throw new T3Error(
|
|
468
498
|
"model",
|
|
469
499
|
`T3 Code does not offer effort ${effort} for ${found.id}.`
|
package/lib/taskCommands.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
swarmBlock,
|
|
19
19
|
swarmDigest,
|
|
20
20
|
toldBlock,
|
|
21
|
+
youLine,
|
|
21
22
|
} from "./cards.mjs";
|
|
22
23
|
import { PICKABLE, resolvePick, setRunPick } from "./models.mjs";
|
|
23
24
|
import { onMachine, placeTask } from "./machineRoutes.mjs";
|
|
@@ -46,6 +47,7 @@ export function createTaskCommands({
|
|
|
46
47
|
lessons,
|
|
47
48
|
madeIn,
|
|
48
49
|
getNetwork,
|
|
50
|
+
getProjects = () => null,
|
|
49
51
|
notifyBoard,
|
|
50
52
|
openTaskRoom,
|
|
51
53
|
openThreadPost,
|
|
@@ -116,6 +118,7 @@ export function createTaskCommands({
|
|
|
116
118
|
hosted: Boolean(request.hostedCaller),
|
|
117
119
|
into: opts.into,
|
|
118
120
|
folder: opts.folder,
|
|
121
|
+
machine: opts.machine,
|
|
119
122
|
}
|
|
120
123
|
);
|
|
121
124
|
const opened = room.id !== opts.into;
|
|
@@ -280,6 +283,7 @@ export function createTaskCommands({
|
|
|
280
283
|
kind: "job",
|
|
281
284
|
text: `Posted a job${request.targetAgent ? ` for ${request.targetAgent}` : ""}: ${objective}`,
|
|
282
285
|
mentions: request.targetAgent ? [String(request.targetAgent)] : [],
|
|
286
|
+
machine,
|
|
283
287
|
});
|
|
284
288
|
}
|
|
285
289
|
// The folder a coding agent posts from (its stdio MCP's, which each agent starts in the session's folder); never
|
|
@@ -308,6 +312,7 @@ export function createTaskCommands({
|
|
|
308
312
|
objective,
|
|
309
313
|
into: workingThread,
|
|
310
314
|
folder: askerFolder,
|
|
315
|
+
machine,
|
|
311
316
|
});
|
|
312
317
|
}
|
|
313
318
|
// Which of the person's computers the work is for: the one named, else the poster's own when it works there in a
|
|
@@ -489,6 +494,7 @@ export function createTaskCommands({
|
|
|
489
494
|
thread[OPENED] && thread.peerKey ? String(thread.peerKey) : null,
|
|
490
495
|
});
|
|
491
496
|
getNetwork()?.opened(task.id);
|
|
497
|
+
getProjects()?.channelOpened(task.id);
|
|
492
498
|
}
|
|
493
499
|
if (pick) setRunPick(store, task.id, pick, agent);
|
|
494
500
|
// A job in a goal's room runs on the goal's authority; anywhere else, standing permission decides. The goal covers
|
|
@@ -552,6 +558,7 @@ export function createTaskCommands({
|
|
|
552
558
|
hosted: Boolean(request.hostedCaller),
|
|
553
559
|
into: workingThread,
|
|
554
560
|
folder: askerFolder,
|
|
561
|
+
machine,
|
|
555
562
|
});
|
|
556
563
|
const note = task.target_agent
|
|
557
564
|
? actors.setupNote(task.target_agent)
|
|
@@ -586,13 +593,15 @@ export function createTaskCommands({
|
|
|
586
593
|
{ lessons: local }
|
|
587
594
|
);
|
|
588
595
|
const told = local ? lessons.told() : [];
|
|
589
|
-
// Its parts too, so a session start short of room can send the cards in short form (nudge.mjs).
|
|
596
|
+
// Its parts too, so a session start short of room can send the cards in short form (nudge.mjs). `you`: who the
|
|
597
|
+
// caller is and the computer it runs on, the computer its call came from.
|
|
590
598
|
extra.swarm = {
|
|
591
599
|
text: swarmBlock(cards, Date.now(), told),
|
|
592
600
|
digest: swarmDigest(cards, told),
|
|
593
601
|
cards: cards.map((card) => cardLine(card)),
|
|
594
602
|
short: cards.map(shortCardLine),
|
|
595
603
|
told: toldBlock(told),
|
|
604
|
+
you: local ? youLine(agent, machines.whereIs(machine)) : "",
|
|
596
605
|
};
|
|
597
606
|
}
|
|
598
607
|
// The goal rooms an agent is on, for list_tasks and a session start: a start short of room points here for them.
|
|
@@ -608,7 +617,7 @@ export function createTaskCommands({
|
|
|
608
617
|
ok: true,
|
|
609
618
|
tasks,
|
|
610
619
|
...extra,
|
|
611
|
-
unread: store.unreadFor(agent),
|
|
620
|
+
unread: store.unreadFor(agent, machine),
|
|
612
621
|
goals: rooms(),
|
|
613
622
|
}
|
|
614
623
|
: { ok: true, tasks, ...extra };
|
|
@@ -626,6 +635,7 @@ export function createTaskCommands({
|
|
|
626
635
|
author: agent,
|
|
627
636
|
text: String(request.text || "").slice(0, 20000),
|
|
628
637
|
source: request.source ? String(request.source).slice(0, 1024) : null,
|
|
638
|
+
machine,
|
|
629
639
|
});
|
|
630
640
|
return entry
|
|
631
641
|
? { ok: true, entry, context: store.contextCount(id) }
|
|
@@ -800,6 +810,17 @@ export function createTaskCommands({
|
|
|
800
810
|
error:
|
|
801
811
|
"a task given to Harness is taken by an up-to-date Harness window by itself, as its own message; leave it open",
|
|
802
812
|
};
|
|
813
|
+
// The extension's hidden Harness page takes only what the person let it finish in their browser (swarm.mjs
|
|
814
|
+
// board.swarm.use_browser): the message that woke it is no permission.
|
|
815
|
+
else if (
|
|
816
|
+
request.command === "board.claim" &&
|
|
817
|
+
request.browser === true &&
|
|
818
|
+
!store.meta(`harness-browser-allowed:${id}`)
|
|
819
|
+
)
|
|
820
|
+
return {
|
|
821
|
+
ok: false,
|
|
822
|
+
error: "the person has not let Harness use their browser for this",
|
|
823
|
+
};
|
|
803
824
|
else if (request.command === "board.claim") {
|
|
804
825
|
outcome = store.claimTask(
|
|
805
826
|
id,
|
|
@@ -858,9 +879,32 @@ export function createTaskCommands({
|
|
|
858
879
|
id,
|
|
859
880
|
agent,
|
|
860
881
|
String(request.answer || "").slice(0, 20000),
|
|
861
|
-
expected
|
|
882
|
+
expected,
|
|
883
|
+
machine
|
|
862
884
|
);
|
|
863
|
-
|
|
885
|
+
// The hidden Harness page stopped at a question for the person, who may be away: the task waits for them at
|
|
886
|
+
// their computer, saying what it would ask, and is not offered to the browser again until they open Harness. Given
|
|
887
|
+
// back for Harness as this daemon gives back what Harness's server left for the browser (daemon.mjs).
|
|
888
|
+
else if (
|
|
889
|
+
request.command === "board.release" &&
|
|
890
|
+
agent === "harness" &&
|
|
891
|
+
request.browser === true
|
|
892
|
+
) {
|
|
893
|
+
const task = store.getTask(id);
|
|
894
|
+
if (task?.claimed_by !== "harness" || !store.meta(`harness-window:${id}`))
|
|
895
|
+
return {
|
|
896
|
+
ok: false,
|
|
897
|
+
error: "that is not Harness's work in your browser",
|
|
898
|
+
};
|
|
899
|
+
outcome = store.releaseTask(id, "user", expected);
|
|
900
|
+
if (outcome?.ok) {
|
|
901
|
+
store.meta(`harness-browser-allowed:${id}`, "");
|
|
902
|
+
store.meta(
|
|
903
|
+
`harness-browser-stopped:${id}`,
|
|
904
|
+
String(request.why || "a question for you").slice(0, 300)
|
|
905
|
+
);
|
|
906
|
+
}
|
|
907
|
+
} else if (request.command === "board.release")
|
|
864
908
|
outcome = store.releaseTask(id, agent, expected);
|
|
865
909
|
else if (request.command === "board.remove") {
|
|
866
910
|
if (agent !== "user")
|
|
@@ -959,8 +1003,17 @@ export function createTaskCommands({
|
|
|
959
1003
|
store.meta(`machine-step:${id}`, new Date().toISOString());
|
|
960
1004
|
return { ok: true };
|
|
961
1005
|
} else if (request.command === "board.machine.finish") {
|
|
962
|
-
|
|
1006
|
+
const ran = store.getTask(id);
|
|
1007
|
+
if (request.usage && ran?.claimed_machine === machine)
|
|
963
1008
|
store.setRunUsage(id, request.usage);
|
|
1009
|
+
// The run's session, when its own call did not reach home before the finish (machineRuns.mjs).
|
|
1010
|
+
if (
|
|
1011
|
+
typeof request.session === "string" &&
|
|
1012
|
+
ran?.claimed_machine === machine &&
|
|
1013
|
+
ran.holder === agent &&
|
|
1014
|
+
!ran.session_id
|
|
1015
|
+
)
|
|
1016
|
+
store.setRunSession(id, request.session.slice(0, 256));
|
|
964
1017
|
outcome = store.reportTask(
|
|
965
1018
|
id,
|
|
966
1019
|
agent,
|
package/lib/taskRuns.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { scrubValues } from "./vault.mjs";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { ensureDir, readJson, writeJsonAtomic } from "./files.mjs";
|
|
@@ -8,7 +9,36 @@ import { runInT3 } from "./t3.mjs";
|
|
|
8
9
|
|
|
9
10
|
const TASK_LOG_PAGE = 64_000;
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
/**
|
|
13
|
+
* What a run with secrets in its environment says, with their values replaced by markers (vault.mjs). An agent's
|
|
14
|
+
* output arrives in pieces, so each stream holds back the end of what it has seen that could begin a value; it is
|
|
15
|
+
* written once the rest arrives, or when the run ends.
|
|
16
|
+
*/
|
|
17
|
+
function streamScrubber(values) {
|
|
18
|
+
if (!(values instanceof Map) || values.size === 0)
|
|
19
|
+
return { text: (text) => text, stream: (_, raw) => raw, flush: () => [] };
|
|
20
|
+
const longest = Math.max(
|
|
21
|
+
...[...values.values()].map((value) => encodeURIComponent(value).length)
|
|
22
|
+
);
|
|
23
|
+
const held = new Map();
|
|
24
|
+
return {
|
|
25
|
+
text: (text) =>
|
|
26
|
+
typeof text === "string" ? scrubValues(text, values) : text,
|
|
27
|
+
stream: (stream, raw) => {
|
|
28
|
+
const clean = scrubValues((held.get(stream) ?? "") + raw, values);
|
|
29
|
+
const keep = Math.min(clean.length, longest - 1);
|
|
30
|
+
held.set(stream, clean.slice(clean.length - keep));
|
|
31
|
+
return clean.slice(0, clean.length - keep);
|
|
32
|
+
},
|
|
33
|
+
flush: () => {
|
|
34
|
+
const rest = [...held].filter(([, text]) => text);
|
|
35
|
+
held.clear();
|
|
36
|
+
return rest;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function createTaskRuns({ t3Missed, nativeRequests = null }) {
|
|
12
42
|
const taskRuns = new Map();
|
|
13
43
|
const validRunId = (runId) =>
|
|
14
44
|
typeof runId === "string" && /^[a-zA-Z0-9._-]{1,128}$/.test(runId);
|
|
@@ -128,13 +158,27 @@ export function createTaskRuns({ t3Missed }) {
|
|
|
128
158
|
};
|
|
129
159
|
taskRuns.set(message.runId, task);
|
|
130
160
|
persistTask(task);
|
|
131
|
-
const
|
|
161
|
+
const scrub = streamScrubber(message.scrub);
|
|
162
|
+
const appendLog = (stream, text) => {
|
|
163
|
+
try {
|
|
164
|
+
fs.appendFileSync(
|
|
165
|
+
files.log,
|
|
166
|
+
stream === "stderr" ? `\n[stderr] ${text}` : text,
|
|
167
|
+
{ mode: 0o600 }
|
|
168
|
+
);
|
|
169
|
+
} catch {}
|
|
170
|
+
};
|
|
171
|
+
const emit = (kind, rawText, extra) => {
|
|
172
|
+
const text = scrub.text(rawText);
|
|
173
|
+
if (kind === "done" || kind === "failed")
|
|
174
|
+
for (const [stream, rest] of scrub.flush()) appendLog(stream, rest);
|
|
132
175
|
if (kind === "accepted") task.status = "running";
|
|
133
176
|
if (kind === "session") {
|
|
134
177
|
task.sessionId = text || null;
|
|
135
178
|
if (extra?.cwd) task.cwd = extra.cwd;
|
|
136
179
|
}
|
|
137
180
|
if (kind === "done" || kind === "failed") {
|
|
181
|
+
nativeRequests?.finish(message.runId);
|
|
138
182
|
task.status = kind;
|
|
139
183
|
task.finishedAt = new Date().toISOString();
|
|
140
184
|
task.message = text || null;
|
|
@@ -146,14 +190,20 @@ export function createTaskRuns({ t3Missed }) {
|
|
|
146
190
|
report(kind, text, extra);
|
|
147
191
|
};
|
|
148
192
|
const observe = (stream, raw) => {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
files.log,
|
|
152
|
-
stream === "stderr" ? `\n[stderr] ${raw}` : raw,
|
|
153
|
-
{ mode: 0o600 }
|
|
154
|
-
);
|
|
155
|
-
} catch {}
|
|
193
|
+
const text = scrub.stream(stream, raw);
|
|
194
|
+
if (text) appendLog(stream, text);
|
|
156
195
|
};
|
|
196
|
+
const hooks = nativeRequests
|
|
197
|
+
? {
|
|
198
|
+
requestApproval: (approval, signal) =>
|
|
199
|
+
nativeRequests.request({
|
|
200
|
+
runId: message.runId,
|
|
201
|
+
agent: message.agent,
|
|
202
|
+
approval,
|
|
203
|
+
signal,
|
|
204
|
+
}),
|
|
205
|
+
}
|
|
206
|
+
: {};
|
|
157
207
|
if (message.t3)
|
|
158
208
|
runInT3(
|
|
159
209
|
{
|
|
@@ -176,13 +226,13 @@ export function createTaskRuns({ t3Missed }) {
|
|
|
176
226
|
`[${why} This turn runs on this computer instead, in ${checkout}.]\n`
|
|
177
227
|
);
|
|
178
228
|
t3Missed(message.runId, why);
|
|
179
|
-
runAgentTask({ ...message, cwd: checkout }, emit, observe);
|
|
229
|
+
runAgentTask({ ...message, cwd: checkout }, emit, observe, hooks);
|
|
180
230
|
},
|
|
181
231
|
},
|
|
182
232
|
emit,
|
|
183
233
|
observe
|
|
184
234
|
);
|
|
185
|
-
else runAgentTask(message, emit, observe);
|
|
235
|
+
else runAgentTask(message, emit, observe, hooks);
|
|
186
236
|
};
|
|
187
237
|
const requeue = (id, reason) => {
|
|
188
238
|
const record = taskRuns.get(id);
|
package/lib/team.json
CHANGED
|
@@ -16,49 +16,57 @@
|
|
|
16
16
|
"name": "builder",
|
|
17
17
|
"owns": "Doing the piece of work: the change, the fix, the draft or the answer, whole rather than in small chunks.",
|
|
18
18
|
"never": "Calls its own work checked, or reviews its own change.",
|
|
19
|
-
"bringsBack": "What changed and where (files, commit or result), the commands run and what they showed, and what is not covered or not tested yet."
|
|
19
|
+
"bringsBack": "What changed and where (files, commit or result), the commands run and what they showed, and what is not covered or not tested yet.",
|
|
20
|
+
"floor": "middle"
|
|
20
21
|
},
|
|
21
22
|
"checker": {
|
|
22
23
|
"name": "checker",
|
|
23
24
|
"owns": "Comparing what was asked with what was delivered, by running it or opening it, not by reading the author's summary.",
|
|
24
25
|
"never": "Fixes the work itself (that makes it an author), or passes work it did not run or open.",
|
|
25
|
-
"bringsBack": "First line: passed, sent back, or could not tell. Then what was run or opened, what it showed, and for sent back exactly what to fix."
|
|
26
|
+
"bringsBack": "First line: passed, sent back, or could not tell. Then what was run or opened, what it showed, and for sent back exactly what to fix.",
|
|
27
|
+
"floor": "middle"
|
|
26
28
|
},
|
|
27
29
|
"reviewer": {
|
|
28
30
|
"name": "reviewer",
|
|
29
31
|
"owns": "A fresh read of the finished change: whether it does what the goal needs, fits how the code already works, and leaves no second way to do the same thing.",
|
|
30
32
|
"never": "Changes files, reviews its own work, or invents findings: a clean review is a fine result.",
|
|
31
|
-
"bringsBack": "First line: passed, sent back, or could not tell. Then each finding with its severity (must fix, should fix, later), the file and line or a way to reproduce it, and whether you checked it yourself."
|
|
33
|
+
"bringsBack": "First line: passed, sent back, or could not tell. Then each finding with its severity (must fix, should fix, later), the file and line or a way to reproduce it, and whether you checked it yourself.",
|
|
34
|
+
"floor": "top"
|
|
32
35
|
},
|
|
33
36
|
"researcher": {
|
|
34
37
|
"name": "researcher",
|
|
35
38
|
"owns": "One angle of the question, dug into deeply, with sources the others can open.",
|
|
36
39
|
"never": "Repeats another researcher's angle, or turns findings into instructions for the builders.",
|
|
37
|
-
"bringsBack": "Findings with their sources, facts kept apart from inferences, and what this angle could not answer."
|
|
40
|
+
"bringsBack": "Findings with their sources, facts kept apart from inferences, and what this angle could not answer.",
|
|
41
|
+
"floor": "any"
|
|
38
42
|
},
|
|
39
43
|
"synthesizer": {
|
|
40
44
|
"name": "synthesizer",
|
|
41
45
|
"owns": "Turning the researchers' findings into one answer: where they agree (counting methods, not votes), where they contradict and which evidence wins, and what nobody covered.",
|
|
42
46
|
"never": "Just stacks the findings one after another, or drops who found what.",
|
|
43
|
-
"bringsBack": "One answer with each point credited to who found it, the contradictions and how they were settled, a confidence (high, medium or low), and what the team should do next."
|
|
47
|
+
"bringsBack": "One answer with each point credited to who found it, the contradictions and how they were settled, a confidence (high, medium or low), and what the team should do next.",
|
|
48
|
+
"floor": "middle"
|
|
44
49
|
},
|
|
45
50
|
"director": {
|
|
46
51
|
"name": "director",
|
|
47
52
|
"owns": "The creative direction: what to make and why, the brief for the makers, and the judgment of each round against what the person asked for.",
|
|
48
53
|
"never": "Makes the pieces another agent is there to make.",
|
|
49
|
-
"bringsBack": "When directing: what to make, for whom, and what good looks like. When judging: first line passed or sent back, then what to change in the next round."
|
|
54
|
+
"bringsBack": "When directing: what to make, for whom, and what good looks like. When judging: first line passed or sent back, then what to change in the next round.",
|
|
55
|
+
"floor": "middle"
|
|
50
56
|
},
|
|
51
57
|
"maker": {
|
|
52
58
|
"name": "maker",
|
|
53
59
|
"owns": "Generating the pieces the direction asks for: images, video, sound, motion or copy, attached in the thread for everyone.",
|
|
54
60
|
"never": "Changes the direction on its own; it says so in the thread instead.",
|
|
55
|
-
"bringsBack": "The pieces attached in the thread, what each one is, and anything it could not make."
|
|
61
|
+
"bringsBack": "The pieces attached in the thread, what each one is, and anything it could not make.",
|
|
62
|
+
"floor": "any"
|
|
56
63
|
},
|
|
57
64
|
"editor": {
|
|
58
65
|
"name": "editor",
|
|
59
66
|
"owns": "Assembling the makers' pieces into the finished thing: the cut, the layout, the final file.",
|
|
60
67
|
"never": "Remakes pieces another agent made; it asks for a new one instead.",
|
|
61
|
-
"bringsBack": "The assembled result attached in the thread, and what is missing or rough."
|
|
68
|
+
"bringsBack": "The assembled result attached in the thread, and what is missing or rough.",
|
|
69
|
+
"floor": "any"
|
|
62
70
|
}
|
|
63
71
|
},
|
|
64
72
|
"shapes": {
|
|
@@ -182,11 +190,5 @@
|
|
|
182
190
|
"careful": "Someone other than the author checks it by running it, because a mistake would be costly or hard to see.",
|
|
183
191
|
"thorough": "An independent check and a separate review of the finished change, because it is hard to undo, outward-facing or money is involved."
|
|
184
192
|
},
|
|
185
|
-
"sendBackLimit": 3
|
|
186
|
-
"goalLevelModels": [
|
|
187
|
-
"opus",
|
|
188
|
-
"fable",
|
|
189
|
-
"sol",
|
|
190
|
-
"astra"
|
|
191
|
-
]
|
|
193
|
+
"sendBackLimit": 3
|
|
192
194
|
}
|
package/lib/team.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { nameOf } from "./members.mjs";
|
|
3
|
+
import { meetsFloor } from "./modelTiers.mjs";
|
|
3
4
|
|
|
4
5
|
// How the agents in a thread work as a team (team.json, read by the server too through src/shared/team.ts): the team's
|
|
5
6
|
// shape, who holds each role, how careful the work must be, and the route the work takes between the roles. Without one,
|
|
@@ -22,28 +23,35 @@ export const RIGOR_LEVELS = Object.keys(TEAM.rigor);
|
|
|
22
23
|
// Every runner's reported states that end a turn: a question to the person (needs_input) is not the step's end.
|
|
23
24
|
const FINISHED = new Set(["done", "failed", "unknown"]);
|
|
24
25
|
|
|
25
|
-
/** Whether
|
|
26
|
-
export const goalLevel = (
|
|
27
|
-
Boolean(model) &&
|
|
28
|
-
TEAM.goalLevelModels.some((family) =>
|
|
29
|
-
String(model).toLowerCase().includes(family)
|
|
30
|
-
);
|
|
26
|
+
/** Whether an agent takes a goal and finds its own route (the brief gives it intent): a top-tier model. */
|
|
27
|
+
export const goalLevel = (tier) => tier === "top";
|
|
31
28
|
|
|
32
29
|
const stepsOf = (plan) =>
|
|
33
30
|
(SHAPES[plan.shape]?.steps ?? []).filter(
|
|
34
31
|
(step) => (plan.roles[step.role] ?? []).length > 0
|
|
35
32
|
);
|
|
36
33
|
|
|
37
|
-
/**
|
|
38
|
-
|
|
34
|
+
/**
|
|
35
|
+
* A plan as the round proposed it, kept only where it names a known shape, known roles and agents that may hold them:
|
|
36
|
+
* agents of the swarm whose tier meets the role's floor (`tiers`: agent id -> tier, from its card, modelTiers.mjs). Who
|
|
37
|
+
* was left out for the floor comes back in `leftOut`, so the thread says why.
|
|
38
|
+
*/
|
|
39
|
+
export function validPlan(proposed, { members, tiers = {} }) {
|
|
39
40
|
const shape = SHAPES[proposed?.shape];
|
|
40
41
|
if (!shape) return null;
|
|
41
42
|
const allowed = new Set(members);
|
|
42
43
|
const roles = {};
|
|
44
|
+
const leftOut = [];
|
|
43
45
|
for (const role of shape.roles) {
|
|
44
|
-
const
|
|
46
|
+
const named = [
|
|
45
47
|
...new Set((proposed.roles?.[role] ?? []).map(String)),
|
|
46
48
|
].filter((agent) => allowed.has(agent));
|
|
49
|
+
const floor = TEAM.roles[role].floor ?? "any";
|
|
50
|
+
const holders = named.filter((agent) => {
|
|
51
|
+
const fits = meetsFloor(tiers[agent]?.level ?? "unknown", floor);
|
|
52
|
+
if (!fits) leftOut.push({ role, agent, floor, tier: tiers[agent] });
|
|
53
|
+
return fits;
|
|
54
|
+
});
|
|
47
55
|
if (holders.length)
|
|
48
56
|
roles[role] = TEAM.several.includes(role) ? holders : holders.slice(0, 1);
|
|
49
57
|
}
|
|
@@ -56,9 +64,43 @@ export function validPlan(proposed, { members }) {
|
|
|
56
64
|
rigor: RIGOR_LEVELS.includes(proposed.rigor) ? proposed.rigor : "standard",
|
|
57
65
|
roles,
|
|
58
66
|
};
|
|
59
|
-
|
|
67
|
+
// A role of the shape nobody holds because no agent here meets its floor: the thread says so, with who fell short.
|
|
68
|
+
const unfilled = shape.roles
|
|
69
|
+
.filter(
|
|
70
|
+
(role) => !roles[role] && (TEAM.roles[role].floor ?? "any") !== "any"
|
|
71
|
+
)
|
|
72
|
+
.map((role) => ({
|
|
73
|
+
role,
|
|
74
|
+
floor: TEAM.roles[role].floor,
|
|
75
|
+
short: members
|
|
76
|
+
.filter(
|
|
77
|
+
(agent) =>
|
|
78
|
+
!meetsFloor(
|
|
79
|
+
tiers[agent]?.level ?? "unknown",
|
|
80
|
+
TEAM.roles[role].floor
|
|
81
|
+
)
|
|
82
|
+
)
|
|
83
|
+
.map((agent) => ({ agent, level: tiers[agent]?.level ?? "unknown" })),
|
|
84
|
+
}))
|
|
85
|
+
.filter(
|
|
86
|
+
(each) => each.short.length && each.short.length === members.length
|
|
87
|
+
);
|
|
88
|
+
return stepsOf(plan).length ? { ...plan, leftOut, unfilled } : null;
|
|
60
89
|
}
|
|
61
90
|
|
|
91
|
+
// Only the agents whose tier is known are named: an agent with no model on its card (Bankr, Grok Bot) says nothing here.
|
|
92
|
+
const unfilledLine = ({ role, floor, short }) => {
|
|
93
|
+
const known = short.filter(({ level }) => level !== "unknown");
|
|
94
|
+
const named = known.length
|
|
95
|
+
? ` (${known.map(({ agent, level }) => `${nameOf(agent)} ${level}`).join(", ")})`
|
|
96
|
+
: "";
|
|
97
|
+
return `This team has no ${TEAM.roles[role].name}: a ${TEAM.roles[role].name} runs on a ${floor}-tier model, which no agent here does${named}. To change that: npx tryharness agents tier ${known[0]?.agent ?? "<agent>"} ${floor}.`;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// The thread's words for an agent kept off a role by its floor, with what the person can do about it.
|
|
101
|
+
const leftOutLine = ({ role, agent, floor, tier }) =>
|
|
102
|
+
`${nameOf(agent)} is not the ${TEAM.roles[role].name}: a ${TEAM.roles[role].name} runs on a ${floor}-tier model and ${nameOf(agent)}'s is ${tier?.level ?? "unknown"} (${tier?.because ?? "no tier"}). To change that: npx tryharness agents tier ${agent} ${floor}.`;
|
|
103
|
+
|
|
62
104
|
// How old a note is, in the words a brief uses.
|
|
63
105
|
const age = (iso) => {
|
|
64
106
|
const days = Math.floor((Date.now() - Date.parse(iso)) / 86_400_000);
|
|
@@ -106,12 +148,13 @@ export function createTeam({ store, log = () => {} }) {
|
|
|
106
148
|
* Keep the plan the round proposed, starting at its first step. Says in the thread who holds what. Returns the plan
|
|
107
149
|
* kept, or null when the proposal named nothing usable.
|
|
108
150
|
*/
|
|
109
|
-
const set = (goalId, proposed, { members, by, post }) => {
|
|
110
|
-
const
|
|
111
|
-
if (!
|
|
151
|
+
const set = (goalId, proposed, { members, tiers, by, post }) => {
|
|
152
|
+
const checked = validPlan(proposed, { members, tiers });
|
|
153
|
+
if (!checked) {
|
|
112
154
|
log(`team plan for ${goalId} not kept: ${JSON.stringify(proposed)}`);
|
|
113
155
|
return null;
|
|
114
156
|
}
|
|
157
|
+
const { leftOut, unfilled, ...valid } = checked;
|
|
115
158
|
const kept = {
|
|
116
159
|
...valid,
|
|
117
160
|
step: stepsOf(valid)[0].id,
|
|
@@ -122,7 +165,14 @@ export function createTeam({ store, log = () => {} }) {
|
|
|
122
165
|
};
|
|
123
166
|
write(goalId, kept);
|
|
124
167
|
post?.(
|
|
125
|
-
|
|
168
|
+
[
|
|
169
|
+
`The team for this thread (${SHAPES[kept.shape].name}, ${kept.rigor}): ${lineup(kept)}.`,
|
|
170
|
+
// One line per role: why it has no holder at all, else who was kept off it.
|
|
171
|
+
...leftOut
|
|
172
|
+
.filter(({ role }) => !unfilled.some((each) => each.role === role))
|
|
173
|
+
.map(leftOutLine),
|
|
174
|
+
...unfilled.map(unfilledLine),
|
|
175
|
+
].join(" ")
|
|
126
176
|
);
|
|
127
177
|
return kept;
|
|
128
178
|
};
|
|
@@ -343,7 +393,7 @@ export function createTeam({ store, log = () => {} }) {
|
|
|
343
393
|
);
|
|
344
394
|
|
|
345
395
|
/** The brief's section on the team, for an agent woken in a thread with a plan. `model`: the agent's model, if known. */
|
|
346
|
-
const brief = (goalId, agent, {
|
|
396
|
+
const brief = (goalId, agent, { tier = null } = {}) => {
|
|
347
397
|
const current = read(goalId);
|
|
348
398
|
if (!current) return "";
|
|
349
399
|
const steps = stepsOf(current);
|
|
@@ -380,14 +430,14 @@ export function createTeam({ store, log = () => {} }) {
|
|
|
380
430
|
lines.push(
|
|
381
431
|
"You hold no role on this team: do what you were asked and hand anything else to the agent whose role it is."
|
|
382
432
|
);
|
|
383
|
-
//
|
|
384
|
-
if (!goalLevel(
|
|
433
|
+
// Agents on top-tier models get the intent and find the route; others do their best work on smaller checked steps.
|
|
434
|
+
if (!goalLevel(tier))
|
|
385
435
|
lines.push(
|
|
386
436
|
"Work in small steps: do one part, check that it works, then the next, and say which parts are done."
|
|
387
437
|
);
|
|
388
438
|
if (mine.length)
|
|
389
439
|
lines.push(
|
|
390
|
-
`Before you stop: if you learned something about this folder that the next ${TEAM.roles[mine[0]].name} here should know (a trap, a check that matters, how the code really works),
|
|
440
|
+
`Before you stop: if you learned something about this folder that the next ${TEAM.roles[mine[0]].name} here should know (a trap, a check that matters, how the code really works), add it with swarm_memory (remember, why, thread ${goalId}): what you learned and why it holds.`
|
|
391
441
|
);
|
|
392
442
|
return [
|
|
393
443
|
"Your part on the team:",
|