tryharness 0.7.53 → 0.7.57
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 +23 -19
- package/assets/dsh-plugin.mjs +72 -0
- package/assets/opencode-plugin.js +4 -3
- package/cli.mjs +484 -90
- package/lib/activity.mjs +10 -10
- package/lib/adapters.mjs +173 -222
- package/lib/agentBinaries.mjs +71 -0
- package/lib/agentRuntimeConfig.mjs +1 -1
- package/lib/agentRuntimes.mjs +34 -18
- package/lib/agentSignIn.mjs +456 -0
- package/lib/answers.mjs +5 -5
- package/lib/archetypes.d.ts +64 -0
- package/lib/archetypes.js +989 -0
- package/lib/asks.mjs +4 -4
- package/lib/audit.mjs +666 -0
- package/lib/backupSetup.mjs +143 -0
- package/lib/boardAccess.mjs +24 -11
- package/lib/boardBackup.mjs +283 -0
- package/lib/boardFileCommands.mjs +6 -6
- package/lib/boardFiles.mjs +13 -12
- package/lib/boardMirror.mjs +124 -25
- package/lib/boardProtocol.json +88 -2
- package/lib/boardWaits.mjs +101 -0
- package/lib/book.mjs +659 -0
- package/lib/bridge.mjs +6 -6
- package/lib/cards.mjs +138 -28
- package/lib/cloudAgents.mjs +216 -0
- package/lib/cloudAi.mjs +1312 -0
- package/lib/cloudAssistants.mjs +242 -0
- package/lib/cloudBoot.mjs +119 -0
- package/lib/cloudSave.mjs +197 -0
- package/lib/cloudSsh.mjs +178 -0
- package/lib/commands.mjs +7 -2
- package/lib/context.mjs +19 -5
- package/lib/contractGate.mjs +399 -0
- package/lib/control-client.mjs +9 -1
- package/lib/controlSocket.mjs +86 -0
- package/lib/coordinator.mjs +252 -144
- package/lib/daemon.mjs +1351 -2767
- package/lib/desk.mjs +240 -0
- package/lib/desktop.mjs +178 -74
- package/lib/directLink.mjs +16 -5
- package/lib/environment.mjs +2 -1
- package/lib/environments.mjs +247 -9
- package/lib/firewall.mjs +9 -9
- package/lib/folders.mjs +20 -16
- package/lib/frames.mjs +2 -3
- package/lib/gitHost.mjs +174 -0
- package/lib/goalCommands.mjs +25 -7
- package/lib/goals.mjs +7 -7
- package/lib/guestRequests.mjs +94 -0
- package/lib/handoffs.mjs +8 -7
- package/lib/handover.mjs +4 -4
- package/lib/harnessModel.mjs +6 -6
- package/lib/harnessOffers.mjs +266 -0
- package/lib/hookDialects.mjs +298 -0
- package/lib/inference.mjs +26 -8
- package/lib/jobAnswers.mjs +190 -0
- package/lib/landed.mjs +887 -0
- package/lib/lane.mjs +42 -11
- package/lib/lessons.mjs +16 -16
- package/lib/library.mjs +3 -3
- package/lib/lineup.mjs +3 -0
- package/lib/linkRelay.mjs +574 -0
- package/lib/live.mjs +284 -13
- package/lib/localAgentAsk.mjs +74 -0
- package/lib/localStack.mjs +536 -0
- package/lib/localmodels.mjs +6 -4
- package/lib/loopBackstop.mjs +4 -4
- package/lib/machineIdentity.mjs +9 -1
- package/lib/machineRoutes.mjs +181 -2
- package/lib/machineRuns.mjs +76 -1
- package/lib/machineSeal.mjs +39 -12
- package/lib/mcp-stdio.mjs +163 -27
- package/lib/mcpRelay.mjs +1 -1
- package/lib/members.json +29 -2
- package/lib/members.mjs +1 -1
- package/lib/models.mjs +85 -31
- package/lib/museSession.mjs +21 -13
- package/lib/nativeHost.mjs +36 -8
- package/lib/neovim.mjs +126 -0
- package/lib/network.mjs +50 -5
- package/lib/notify.mjs +7 -5
- package/lib/nudge.mjs +50 -19
- package/lib/ocr.mjs +9 -9
- package/lib/onboard.mjs +26 -20
- package/lib/oneLine.mjs +7 -7
- package/lib/ownMachines.mjs +1223 -140
- package/lib/pairing.mjs +60 -16
- package/lib/paths.mjs +19 -1
- package/lib/peerProcess.mjs +124 -0
- package/lib/personModel.mjs +89 -0
- package/lib/personNotices.mjs +151 -0
- package/lib/phones.mjs +538 -31
- package/lib/placeCommands.mjs +4 -4
- package/lib/places.mjs +400 -12
- package/lib/profile.mjs +67 -14
- package/lib/projectGit.mjs +158 -14
- package/lib/projectPieces.mjs +902 -0
- package/lib/projectSettings.mjs +7 -4
- package/lib/projects.mjs +384 -62
- package/lib/provenance.mjs +5 -1
- package/lib/proxyLinks.mjs +267 -0
- package/lib/reactions.mjs +7 -5
- package/lib/readiness.mjs +145 -23
- package/lib/record.mjs +128 -0
- package/lib/redact.mjs +4 -4
- package/lib/relayLimits.mjs +62 -0
- package/lib/release.mjs +170 -0
- package/lib/releaseKeys.json +6 -0
- package/lib/repoLinks.mjs +4 -4
- package/lib/roomChannels.mjs +24 -0
- package/lib/roomPage.mjs +1 -1
- package/lib/runAuthority.mjs +101 -0
- package/lib/runBrief.mjs +19 -8
- package/lib/runWorker.mjs +31 -7
- package/lib/runner.mjs +223 -29
- package/lib/runtime-install.mjs +143 -9
- package/lib/schedules.mjs +2 -2
- package/lib/screens.mjs +1 -1
- package/lib/sealed.mjs +11 -2
- package/lib/sealedThreads.mjs +671 -0
- package/lib/secretPatterns.json +1 -1
- package/lib/secrets.mjs +4 -4
- package/lib/seen.mjs +6 -6
- package/lib/serverWords.mjs +175 -0
- package/lib/service.mjs +22 -12
- package/lib/sessionControl.mjs +378 -90
- package/lib/specialties.json +74 -0
- package/lib/specialties.mjs +477 -0
- package/lib/specialtyKeys.d.ts +3 -0
- package/lib/specialtyKeys.js +57 -0
- package/lib/specialtyNotice.mjs +147 -0
- package/lib/specialtySnapshot.mjs +138 -0
- package/lib/speech.mjs +5 -5
- package/lib/store.mjs +420 -36
- package/lib/stuck.mjs +1 -1
- package/lib/swarm.mjs +304 -37
- package/lib/swarmDevices.mjs +319 -0
- package/lib/swarmMemory.mjs +27 -25
- package/lib/t3.mjs +24 -15
- package/lib/taskCommands.mjs +80 -20
- package/lib/taskRooms.mjs +125 -0
- package/lib/taskRuns.mjs +45 -3
- package/lib/team.json +255 -148
- package/lib/team.mjs +554 -190
- package/lib/threadActions.mjs +315 -0
- package/lib/threadAuthority.mjs +101 -0
- package/lib/threadBriefs.mjs +178 -0
- package/lib/threadLine.mjs +116 -0
- package/lib/threadRuns.mjs +209 -50
- package/lib/threadView.mjs +20 -7
- package/lib/usageTotals.mjs +2 -3
- package/lib/vault.mjs +101 -10
- package/lib/vaultCloud.mjs +2 -2
- package/lib/vaultCommands.mjs +15 -6
- package/lib/vaultTools.js +2 -2
- package/lib/verdicts.mjs +328 -0
- package/lib/wakes.mjs +1 -1
- package/lib/watches.mjs +2 -2
- package/lib/windowAsks.mjs +13 -5
- package/lib/worktrees.mjs +157 -25
- package/npm-shrinkwrap.json +1093 -0
- package/package.json +12 -11
- package/release.json +220 -0
- package/lib/modelTiers.json +0 -1183
- package/lib/modelTiers.mjs +0 -133
package/lib/taskCommands.mjs
CHANGED
|
@@ -22,6 +22,9 @@ import {
|
|
|
22
22
|
} from "./cards.mjs";
|
|
23
23
|
import { PICKABLE, resolvePick, setRunPick } from "./models.mjs";
|
|
24
24
|
import { onMachine, placeTask } from "./machineRoutes.mjs";
|
|
25
|
+
import { within } from "./folders.mjs";
|
|
26
|
+
import { recordClaims } from "./audit.mjs";
|
|
27
|
+
import { limitedCaller, RUN_CALLER } from "./runAuthority.mjs";
|
|
25
28
|
|
|
26
29
|
// An agent working in a thread may bring another agent in for part of the work there, as Harness does when it names
|
|
27
30
|
// one; an agent that moves money or takes positions joins only when the person names it (members.mjs TAGGED_ONLY).
|
|
@@ -30,13 +33,23 @@ const joinsThread = (thread, target, roomAgents) =>
|
|
|
30
33
|
thread.goal.team.includes(String(target)) ||
|
|
31
34
|
(roomAgents.includes(String(target)) &&
|
|
32
35
|
!TAGGED_ONLY.includes(String(target)));
|
|
36
|
+
// Work in another repository is its own thread: an agent's session, and its T3 thread, belong to the folder it ran in,
|
|
37
|
+
// so a thread's turns all run in the thread's folder. A thread with no folder yet takes the work's (daemon.mjs joinRoom).
|
|
38
|
+
const sameFolder = (thread, folder) =>
|
|
39
|
+
!folder ||
|
|
40
|
+
!thread.goal.workspace ||
|
|
41
|
+
within(path.resolve(String(folder)), thread.goal.workspace);
|
|
33
42
|
|
|
34
43
|
export function createTaskCommands({
|
|
35
44
|
CLOUD_TARGETS,
|
|
45
|
+
// The onchain desk (desk.mjs): a Bankr ask in a thread under a strategy carries its instructions, never the book.
|
|
46
|
+
desk = null,
|
|
36
47
|
OPENED,
|
|
37
48
|
machines,
|
|
38
49
|
ROOM_AGENTS,
|
|
39
50
|
getActiveRuns,
|
|
51
|
+
commitRun = () => {},
|
|
52
|
+
startTurn = () => {},
|
|
40
53
|
boardCommand,
|
|
41
54
|
forwardToHarness,
|
|
42
55
|
frames,
|
|
@@ -71,12 +84,16 @@ export function createTaskCommands({
|
|
|
71
84
|
authority,
|
|
72
85
|
actors,
|
|
73
86
|
files: boardFiles,
|
|
87
|
+
// Threads mirrored from another app (environments.mjs), when the person reads them here.
|
|
88
|
+
outside = () => null,
|
|
74
89
|
}) {
|
|
75
90
|
// The one open thread an agent is working in now, when the work it hands on may join it there.
|
|
76
|
-
const soleThreadOf = (agent, target) => {
|
|
91
|
+
const soleThreadOf = (agent, target, folder) => {
|
|
77
92
|
const working = store.threadsWorkedIn(agent);
|
|
78
93
|
const thread = working.length === 1 ? store.getTask(working[0]) : null;
|
|
79
|
-
return thread &&
|
|
94
|
+
return thread &&
|
|
95
|
+
joinsThread(thread, target, ROOM_AGENTS) &&
|
|
96
|
+
sameFolder(thread, folder)
|
|
80
97
|
? thread.id
|
|
81
98
|
: null;
|
|
82
99
|
};
|
|
@@ -139,6 +156,11 @@ export function createTaskCommands({
|
|
|
139
156
|
let outcome;
|
|
140
157
|
// A call from one of the person's other computers, which home answers on its board (ownMachines.mjs).
|
|
141
158
|
const fromElsewhere = Boolean(machine) && machine !== machines.self();
|
|
159
|
+
// An agent's words from another computer carry no go of the person's here, as a call through Harness carries none
|
|
160
|
+
// (security audit 2026-10-25, M1): the work it writes waits for the person's Start.
|
|
161
|
+
const noGo =
|
|
162
|
+
Boolean(request.hostedCaller) ||
|
|
163
|
+
(fromElsewhere && !["user", "harness"].includes(agent));
|
|
142
164
|
if (
|
|
143
165
|
request.command === "board.post" &&
|
|
144
166
|
request.thread &&
|
|
@@ -218,12 +240,12 @@ export function createTaskCommands({
|
|
|
218
240
|
if (!resolved.ok) return { ok: false, error: resolved.error };
|
|
219
241
|
pick = resolved.pick;
|
|
220
242
|
}
|
|
221
|
-
// Work an agent hands on while it works in one thread is placed in that thread,
|
|
222
|
-
//
|
|
223
|
-
// for
|
|
243
|
+
// Work an agent hands on while it works in one thread is placed in that thread, so a hand-off never spins up a
|
|
244
|
+
// new thread. It is placed after it is posted, so whether it waits for the person's Start is decided exactly as
|
|
245
|
+
// for work outside any thread: placing it grants nothing.
|
|
224
246
|
const workingThread =
|
|
225
247
|
!request.parentId && !request.thread && agent !== "user"
|
|
226
|
-
? soleThreadOf(agent, request.targetAgent)
|
|
248
|
+
? soleThreadOf(agent, request.targetAgent, request.runWorkspace)
|
|
227
249
|
: null;
|
|
228
250
|
// Provenance is code's: the local parent's label and what Harness sent from above the poster can only tighten it.
|
|
229
251
|
const parentTask = request.parentId
|
|
@@ -242,7 +264,10 @@ export function createTaskCommands({
|
|
|
242
264
|
}
|
|
243
265
|
: claimed;
|
|
244
266
|
const provenance = provenanceFor(agent, upstream, null, {
|
|
245
|
-
personSession:
|
|
267
|
+
personSession:
|
|
268
|
+
!request[RUN_CALLER] &&
|
|
269
|
+
authority.personSession(agent, request.posterPid),
|
|
270
|
+
viaServer: request.hostedCaller === true,
|
|
246
271
|
});
|
|
247
272
|
const goalParent = parentTask?.kind === "goal" ? parentTask : null;
|
|
248
273
|
if (goalParent) {
|
|
@@ -306,7 +331,10 @@ export function createTaskCommands({
|
|
|
306
331
|
error: `${request.targetAgent} lives in Harness, and the daemon is not connected to it right now`,
|
|
307
332
|
};
|
|
308
333
|
if (goalParent || request.parentId || agent === "user")
|
|
309
|
-
return forwardToHarness({
|
|
334
|
+
return forwardToHarness({
|
|
335
|
+
...(desk ? desk.forBankr(request) : request),
|
|
336
|
+
provenance: upstream,
|
|
337
|
+
});
|
|
310
338
|
return forwardIntoRoom(request, upstream, provenance, {
|
|
311
339
|
agent,
|
|
312
340
|
objective,
|
|
@@ -500,14 +528,23 @@ export function createTaskCommands({
|
|
|
500
528
|
// A job in a goal's room runs on the goal's authority; anywhere else, standing permission decides. The goal covers
|
|
501
529
|
// jobs from the person, Harness and the coding agents on this machine, with the person's go (personsGo) unless an
|
|
502
530
|
// agent's words came from above the poster; a job from a member that runs elsewhere (Grok Bot, Muse, a connected
|
|
503
|
-
// app) waits for the person's Start.
|
|
531
|
+
// app), or any job that came through Harness's server whatever name it carries, waits for the person's Start. A job
|
|
532
|
+
// a restricted run or a review posts carries no go: it runs restricted (a review's job as a review) or waits, as
|
|
533
|
+
// the run that posted it would. Harness's call as a linked window sealed it (phones.mjs fromWindow) is the served
|
|
534
|
+
// page's word, never a go.
|
|
504
535
|
const onGoal =
|
|
505
536
|
agent === "user" ||
|
|
506
|
-
agent === "harness"
|
|
507
|
-
|
|
537
|
+
(agent === "harness" &&
|
|
538
|
+
!request.hostedCaller &&
|
|
539
|
+
request.fromWindow !== true) ||
|
|
540
|
+
(!noGo && member(agent)?.runs === "machine");
|
|
508
541
|
const agentWritten = task.trust !== "user";
|
|
542
|
+
const limited = limitedCaller(request);
|
|
543
|
+
if (limited && request[RUN_CALLER].review)
|
|
544
|
+
store.meta(`review:${task.id}`, "1");
|
|
509
545
|
const go =
|
|
510
546
|
onGoal &&
|
|
547
|
+
!limited &&
|
|
511
548
|
(!agentWritten || (!claimed && !setToWait(String(task.target_agent))));
|
|
512
549
|
const mayStart =
|
|
513
550
|
goalParent &&
|
|
@@ -594,11 +631,14 @@ export function createTaskCommands({
|
|
|
594
631
|
);
|
|
595
632
|
const told = local ? lessons.told() : [];
|
|
596
633
|
// 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.
|
|
634
|
+
// caller is and the computer it runs on, the computer its call came from. Specialties by name here; list_agents
|
|
635
|
+
// gives each one's evidence.
|
|
598
636
|
extra.swarm = {
|
|
599
|
-
text: swarmBlock(cards, Date.now(), told),
|
|
637
|
+
text: swarmBlock(cards, Date.now(), told, { evidence: false }),
|
|
600
638
|
digest: swarmDigest(cards, told),
|
|
601
|
-
cards: cards.map((card) =>
|
|
639
|
+
cards: cards.map((card) =>
|
|
640
|
+
cardLine(card, Date.now(), { evidence: false })
|
|
641
|
+
),
|
|
602
642
|
short: cards.map(shortCardLine),
|
|
603
643
|
told: toldBlock(told),
|
|
604
644
|
you: local ? youLine(agent, machines.whereIs(machine)) : "",
|
|
@@ -843,6 +883,7 @@ export function createTaskCommands({
|
|
|
843
883
|
};
|
|
844
884
|
// The person's own session that took it, so the task opens there (its MCP server is a child of that session).
|
|
845
885
|
const claimed = outcome?.ok ? store.getTask(id) : null;
|
|
886
|
+
if (claimed && !fromElsewhere) startTurn(claimed);
|
|
846
887
|
const reportedBy = (pid) =>
|
|
847
888
|
Object.entries(placesOf(agent)).find(
|
|
848
889
|
([, place]) => place.pid === pid
|
|
@@ -863,7 +904,7 @@ export function createTaskCommands({
|
|
|
863
904
|
store.setRunSession(id, session);
|
|
864
905
|
outcome = { ...outcome, task: store.getTask(id) };
|
|
865
906
|
}
|
|
866
|
-
} else if (request.command === "board.report")
|
|
907
|
+
} else if (request.command === "board.report") {
|
|
867
908
|
outcome = store.reportTask(
|
|
868
909
|
id,
|
|
869
910
|
agent,
|
|
@@ -874,7 +915,14 @@ export function createTaskCommands({
|
|
|
874
915
|
expected,
|
|
875
916
|
machine
|
|
876
917
|
);
|
|
877
|
-
|
|
918
|
+
if (outcome?.ok && !fromElsewhere && request.status === "done")
|
|
919
|
+
commitRun(outcome.task);
|
|
920
|
+
// What the report claims in its structured fields, which the auditor's code compares with the receipts.
|
|
921
|
+
if (outcome?.ok && request.claims) {
|
|
922
|
+
recordClaims(store, id, request.claims);
|
|
923
|
+
outcome = { ...outcome, task: store.getTask(id) };
|
|
924
|
+
}
|
|
925
|
+
} else if (request.command === "board.answer")
|
|
878
926
|
outcome = store.answerTask(
|
|
879
927
|
id,
|
|
880
928
|
agent,
|
|
@@ -912,6 +960,8 @@ export function createTaskCommands({
|
|
|
912
960
|
ok: false,
|
|
913
961
|
error: "only the person removes work from the board",
|
|
914
962
|
};
|
|
963
|
+
// A thread mirrored from T3 Code leaves Harness's list; T3 keeps it.
|
|
964
|
+
if (outside()?.owns(id)) return outside().hide(id);
|
|
915
965
|
const task = store.getTask(id);
|
|
916
966
|
if (!task || task.removed_at)
|
|
917
967
|
return { ok: false, error: "task not found" };
|
|
@@ -977,12 +1027,19 @@ export function createTaskCommands({
|
|
|
977
1027
|
};
|
|
978
1028
|
const claimed = store.claimTask(id, agent, expected, null, machine);
|
|
979
1029
|
outcome = claimed.ok ? store.startRun(id, agent) : claimed;
|
|
980
|
-
// A thread's turn carries the thread as home's run worker would hand it over
|
|
981
|
-
|
|
1030
|
+
// A thread's turn carries the thread as home's run worker would hand it over, and goes on in the session of the
|
|
1031
|
+
// turn the person's steer stopped there (threadRuns.mjs).
|
|
1032
|
+
if (outcome.ok && outcome.task.kind === "wake") {
|
|
1033
|
+
const resumeSession = machines.resumeAfterSteer(outcome.task, machine);
|
|
982
1034
|
outcome = {
|
|
983
1035
|
...outcome,
|
|
984
|
-
task: {
|
|
1036
|
+
task: {
|
|
1037
|
+
...outcome.task,
|
|
1038
|
+
brief: machines.briefOf(outcome.task),
|
|
1039
|
+
...(resumeSession ? { resumeSession } : {}),
|
|
1040
|
+
},
|
|
985
1041
|
};
|
|
1042
|
+
}
|
|
986
1043
|
} else if (request.command === "board.machine.session") {
|
|
987
1044
|
const task = store.getTask(id);
|
|
988
1045
|
if (!task || task.claimed_machine !== machine || task.holder !== agent)
|
|
@@ -1020,7 +1077,10 @@ export function createTaskCommands({
|
|
|
1020
1077
|
{
|
|
1021
1078
|
status: request.status === "done" ? "done" : "failed",
|
|
1022
1079
|
result: String(request.result || "").slice(0, 200000),
|
|
1023
|
-
|
|
1080
|
+
// Stopped there for the person's steer: the person ended it (threadRuns.mjs).
|
|
1081
|
+
failure: store.meta(`steered:${id}`)
|
|
1082
|
+
? "person"
|
|
1083
|
+
: String(request.failure || "exit"),
|
|
1024
1084
|
},
|
|
1025
1085
|
null,
|
|
1026
1086
|
machine
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { offerable } from "./folders.mjs";
|
|
3
|
+
|
|
4
|
+
// What a thread may hold before it pauses: posts, and wakes of any one agent.
|
|
5
|
+
export const DEFAULT_MAX_POSTS = 500;
|
|
6
|
+
export const DEFAULT_MAX_WAKES = 50;
|
|
7
|
+
|
|
8
|
+
// The Harness conversation a task was handed on from, if any.
|
|
9
|
+
export const conversationOf = (task) =>
|
|
10
|
+
task.context_refs?.find((ref) => ref.kind === "conversation")?.ref ?? null;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A task's own room: every task for one of the person's agents opens a thread, and the task is its first job, so the
|
|
14
|
+
* agents on it can post, ask each other by name and be seen working together. The task keeps its own authority.
|
|
15
|
+
*
|
|
16
|
+
* Work Harness hands on from one of the person's Harness conversations goes into one thread while it is open: a build
|
|
17
|
+
* and its review, or two parts of one bug, are one piece of work, not two threads.
|
|
18
|
+
*
|
|
19
|
+
* `runsHere(agent)` says whether an agent is a coding agent this daemon runs (runAuthority.mjs).
|
|
20
|
+
*/
|
|
21
|
+
export function createTaskRooms({ store, worktrees, runsHere, notifyBoard }) {
|
|
22
|
+
const roomOfConversation = (conversation) => {
|
|
23
|
+
const room = store.getTask(
|
|
24
|
+
store.meta(`conversation-room:${conversation}`) || ""
|
|
25
|
+
);
|
|
26
|
+
const filed = store.meta(`thread-filed:${room?.id}`);
|
|
27
|
+
return room?.kind === "goal" &&
|
|
28
|
+
room.status === "open" &&
|
|
29
|
+
!filed?.includes('"done":true')
|
|
30
|
+
? room
|
|
31
|
+
: null;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const postJob = (room, task, poster, machine) => {
|
|
35
|
+
store.setParent(task.id, room.id);
|
|
36
|
+
store.roomPost({
|
|
37
|
+
goalId: room.id,
|
|
38
|
+
author: poster,
|
|
39
|
+
kind: "job",
|
|
40
|
+
text: task.brief ? `${task.objective}\n\n${task.brief}` : task.objective,
|
|
41
|
+
mentions: [task.target_agent],
|
|
42
|
+
machine,
|
|
43
|
+
});
|
|
44
|
+
notifyBoard(store.getTask(room.id));
|
|
45
|
+
return room;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const join = (room, task, poster, machine) => {
|
|
49
|
+
const joining = [task.target_agent, poster].filter(
|
|
50
|
+
(agent) => agent !== "user" && !room.goal.team.includes(agent)
|
|
51
|
+
);
|
|
52
|
+
if (joining.length)
|
|
53
|
+
store.setGoalTeam(room.id, [...room.goal.team, ...joining]);
|
|
54
|
+
// A thread with no folder yet takes the folder of the first coding work handed into it, as a task's own thread
|
|
55
|
+
// does, so that work is a turn in the thread and runs where the agent lives, in T3 Code when that is its home
|
|
56
|
+
// (threadRuns.mjs). Work in another repository never joins a thread that has one (taskCommands.mjs).
|
|
57
|
+
const adopted =
|
|
58
|
+
!room.goal.workspace &&
|
|
59
|
+
runsHere(task.target_agent) &&
|
|
60
|
+
task.run_workspace &&
|
|
61
|
+
offerable(task.run_workspace)
|
|
62
|
+
? path.resolve(task.run_workspace)
|
|
63
|
+
: null;
|
|
64
|
+
if (adopted) {
|
|
65
|
+
store.setGoalFolder(room.id, adopted);
|
|
66
|
+
if (task.trust === "user" && !worktrees.get(room.id))
|
|
67
|
+
worktrees.inPlace(room.id);
|
|
68
|
+
store.roomPost({
|
|
69
|
+
goalId: room.id,
|
|
70
|
+
author: "harness",
|
|
71
|
+
kind: "note",
|
|
72
|
+
text: `Now working in ${adopted}.`,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return postJob(room, task, poster, machine);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The thread `task` is worked in, opened for it or joined. `into`: the thread the poster is working in, which the
|
|
80
|
+
* task joins (taskCommands.mjs). `folder`: where a coding agent that asked works, so its turn on the answer runs
|
|
81
|
+
* there (answers.mjs) when the task names no folder. `machine`: the computer the poster wrote from. `hosted`: posted
|
|
82
|
+
* through Harness.
|
|
83
|
+
*/
|
|
84
|
+
const open = (
|
|
85
|
+
task,
|
|
86
|
+
poster,
|
|
87
|
+
provenance,
|
|
88
|
+
{ hosted = false, into = null, folder = null, machine = null } = {}
|
|
89
|
+
) => {
|
|
90
|
+
const conversation = conversationOf(task);
|
|
91
|
+
const joined = into
|
|
92
|
+
? store.getTask(into)
|
|
93
|
+
: conversation
|
|
94
|
+
? roomOfConversation(conversation)
|
|
95
|
+
: null;
|
|
96
|
+
if (joined) return join(joined, task, poster, machine);
|
|
97
|
+
// The asker is in the room it opened, roster member or not, so it can follow the work it asked for.
|
|
98
|
+
const team = [
|
|
99
|
+
...new Set([
|
|
100
|
+
task.target_agent,
|
|
101
|
+
...(poster !== "user" ? [poster] : []),
|
|
102
|
+
"harness",
|
|
103
|
+
]),
|
|
104
|
+
];
|
|
105
|
+
const room = store.createGoal({
|
|
106
|
+
objective: task.objective,
|
|
107
|
+
brief: task.brief,
|
|
108
|
+
originAgent: poster,
|
|
109
|
+
provenance,
|
|
110
|
+
team,
|
|
111
|
+
facilitator: "harness",
|
|
112
|
+
workspace: task.run_workspace || folder,
|
|
113
|
+
maxPosts: DEFAULT_MAX_POSTS,
|
|
114
|
+
maxWakes: DEFAULT_MAX_WAKES,
|
|
115
|
+
});
|
|
116
|
+
// Its agents work where the task does, as the task would have alone; work another agent asked for gets a copy.
|
|
117
|
+
if (provenance?.trust === "user") worktrees.inPlace(room.id);
|
|
118
|
+
store.meta(`task-room:${room.id}`, task.id);
|
|
119
|
+
if (conversation) store.meta(`conversation-room:${conversation}`, room.id);
|
|
120
|
+
if (hosted) store.meta(`hosted-thread:${room.id}`, "1");
|
|
121
|
+
return postJob(room, task, poster, machine);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return { open };
|
|
125
|
+
}
|
package/lib/taskRuns.mjs
CHANGED
|
@@ -38,7 +38,18 @@ function streamScrubber(values) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
/** `onOutput` hears a run's output reach its log: the steps every surface shows from it moved. */
|
|
42
|
+
export function createTaskRuns({
|
|
43
|
+
t3Missed,
|
|
44
|
+
nativeRequests = null,
|
|
45
|
+
onOutput = () => {},
|
|
46
|
+
// Why an agent's run may not start on this computer's inference as it stands, or null (cloudAi.mjs refusal, the
|
|
47
|
+
// inference boundary): every run starts here, from this computer's board or from home's.
|
|
48
|
+
inferenceRefusal = () => null,
|
|
49
|
+
// What a run ends saying when any of its agent's calls ran on Harness's AI in place of the person's own link or key
|
|
50
|
+
// since it started (cloudAi.mjs noteFor), or null.
|
|
51
|
+
inferenceNote = () => null,
|
|
52
|
+
}) {
|
|
42
53
|
const taskRuns = new Map();
|
|
43
54
|
const validRunId = (runId) =>
|
|
44
55
|
typeof runId === "string" && /^[a-zA-Z0-9._-]{1,128}$/.test(runId);
|
|
@@ -168,8 +179,16 @@ export function createTaskRuns({ t3Missed, nativeRequests = null }) {
|
|
|
168
179
|
);
|
|
169
180
|
} catch {}
|
|
170
181
|
};
|
|
182
|
+
const runStart = Date.now();
|
|
171
183
|
const emit = (kind, rawText, extra) => {
|
|
172
|
-
|
|
184
|
+
// A run any of whose calls went to Harness's AI in place of the person's own link or key ends saying so, once.
|
|
185
|
+
const note =
|
|
186
|
+
kind === "done" || kind === "failed"
|
|
187
|
+
? inferenceNote(message.agent, runStart)
|
|
188
|
+
: null;
|
|
189
|
+
const text = scrub.text(
|
|
190
|
+
note ? [rawText, note].filter(Boolean).join("\n\n") : rawText
|
|
191
|
+
);
|
|
173
192
|
if (kind === "done" || kind === "failed")
|
|
174
193
|
for (const [stream, rest] of scrub.flush()) appendLog(stream, rest);
|
|
175
194
|
if (kind === "accepted") task.status = "running";
|
|
@@ -191,8 +210,17 @@ export function createTaskRuns({ t3Missed, nativeRequests = null }) {
|
|
|
191
210
|
};
|
|
192
211
|
const observe = (stream, raw) => {
|
|
193
212
|
const text = scrub.stream(stream, raw);
|
|
194
|
-
if (text)
|
|
213
|
+
if (!text) return;
|
|
214
|
+
appendLog(stream, text);
|
|
215
|
+
onOutput(message.runId);
|
|
195
216
|
};
|
|
217
|
+
// Checked before T3 Code takes a turn as well: it runs the same agent, on the same settings, on this computer.
|
|
218
|
+
const refused = inferenceRefusal(message.agent);
|
|
219
|
+
if (refused) {
|
|
220
|
+
appendLog("stderr", `${refused}\n`);
|
|
221
|
+
emit("failed", refused, { failure: "start" });
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
196
224
|
const hooks = nativeRequests
|
|
197
225
|
? {
|
|
198
226
|
requestApproval: (approval, signal) =>
|
|
@@ -243,6 +271,19 @@ export function createTaskRuns({ t3Missed, nativeRequests = null }) {
|
|
|
243
271
|
});
|
|
244
272
|
persistTask(record);
|
|
245
273
|
};
|
|
274
|
+
// The runs going on this computer now, newest first: what someone at its terminal (SSH into a cloud computer) sees.
|
|
275
|
+
const running = () =>
|
|
276
|
+
[...taskRuns.values()]
|
|
277
|
+
.filter((task) => task.status === "starting" || task.status === "running")
|
|
278
|
+
.sort((a, b) => b.startedAt.localeCompare(a.startedAt))
|
|
279
|
+
.map(({ runId, agent, title, cwd, startedAt, updatedAt }) => ({
|
|
280
|
+
runId,
|
|
281
|
+
agent,
|
|
282
|
+
title,
|
|
283
|
+
cwd,
|
|
284
|
+
startedAt,
|
|
285
|
+
updatedAt,
|
|
286
|
+
}));
|
|
246
287
|
return {
|
|
247
288
|
validRunId,
|
|
248
289
|
taskFiles,
|
|
@@ -251,5 +292,6 @@ export function createTaskRuns({ t3Missed, nativeRequests = null }) {
|
|
|
251
292
|
lastStepAt,
|
|
252
293
|
startTask,
|
|
253
294
|
requeue,
|
|
295
|
+
running,
|
|
254
296
|
};
|
|
255
297
|
}
|