tryharness 0.7.83 → 0.7.86
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 +21 -19
- package/assets/dsh-plugin.mjs +75 -4
- package/assets/herdr-mod/harness/main.js +367 -0
- package/assets/herdr-mod/harness/mod.json +6 -0
- package/assets/opencode-plugin.js +87 -22
- package/assets/pi-extension.ts +81 -2
- package/cli.mjs +544 -208
- package/lib/adapters.mjs +62 -27
- package/lib/agentBinaries.mjs +6 -8
- package/lib/agentClaims.mjs +168 -0
- package/lib/agentReadTools.json +415 -0
- package/lib/agentSignIn.mjs +17 -18
- package/lib/agentWiring.mjs +114 -0
- package/lib/archetypes.js +10 -11
- package/lib/attention.mjs +100 -0
- package/lib/audit.mjs +1 -1
- package/lib/backupSetup.mjs +6 -28
- package/lib/bankrApprovals.mjs +86 -0
- package/lib/boardAccess.mjs +40 -66
- package/lib/boardBackup.mjs +86 -85
- package/lib/boardCommands.mjs +28 -0
- package/lib/boardFileCommands.mjs +29 -36
- package/lib/boardFiles.mjs +83 -15
- package/lib/boardMirror.mjs +78 -11
- package/lib/boardProtocol.json +191 -123
- package/lib/boardThreads.mjs +19 -37
- package/lib/boardTools.mjs +22 -15
- package/lib/boardWatches.mjs +43 -15
- package/lib/bridge.mjs +7 -3
- package/lib/browserAgentTools.mjs +59 -0
- package/lib/browserWake.mjs +0 -6
- package/lib/cards.mjs +52 -0
- package/lib/circling.mjs +189 -0
- package/lib/cleanup.mjs +234 -0
- package/lib/cloudBoot.mjs +21 -4
- package/lib/cloudSave.mjs +46 -5
- package/lib/compaction.mjs +8 -1
- package/lib/completion.mjs +358 -0
- package/lib/computerDevices.mjs +853 -0
- package/lib/connectionStatus.mjs +34 -0
- package/lib/connectors.mjs +139 -1
- package/lib/coordinator.mjs +108 -14
- package/lib/coreModels.mjs +36 -12
- package/lib/daemon.mjs +2426 -338
- package/lib/daemonLock.mjs +103 -0
- package/lib/deviceDoor.mjs +308 -0
- package/lib/deviceIdentity.mjs +114 -0
- package/lib/deviceList.mjs +172 -0
- package/lib/deviceSeal.mjs +74 -0
- package/lib/dispatcher.mjs +497 -26
- package/lib/dispatches.mjs +3 -3
- package/lib/environment.mjs +2 -1
- package/lib/environments.mjs +67 -41
- package/lib/events.mjs +318 -0
- package/lib/facts.mjs +170 -0
- package/lib/fileSource.mjs +540 -0
- package/lib/files.mjs +47 -2
- package/lib/gitHost.mjs +39 -1
- package/lib/goalCommands.mjs +12 -80
- package/lib/handover.mjs +21 -16
- package/lib/harnessOffers.mjs +140 -15
- package/lib/herdr.mjs +100 -15
- package/lib/herdrAppCall.mjs +19 -0
- package/lib/herdrCore.mjs +59 -0
- package/lib/herdrRuns.mjs +1126 -0
- package/lib/hookDialects.mjs +235 -50
- package/lib/identityLink.mjs +81 -0
- package/lib/inference.mjs +31 -2
- package/lib/jamAccess.mjs +82 -0
- package/lib/{projectBoard.mjs → jamBoard.mjs} +5 -4
- package/lib/{projectGit.mjs → jamGit.mjs} +53 -15
- package/lib/jamKey.mjs +274 -0
- package/lib/{projectPieces.mjs → jamPieces.mjs} +35 -29
- package/lib/{projectSettings.mjs → jamSettings.mjs} +12 -22
- package/lib/jamStore.mjs +973 -0
- package/lib/jamUpgrade.mjs +112 -0
- package/lib/jams.mjs +3079 -0
- package/lib/kanban.mjs +13 -7
- package/lib/landed.mjs +5 -1
- package/lib/library.mjs +41 -22
- package/lib/limits.mjs +91 -0
- package/lib/lineDiff.mjs +97 -0
- package/lib/lineup.mjs +18 -13
- package/lib/link.mjs +584 -0
- package/lib/localStack.mjs +75 -16
- package/lib/localmodels.mjs +58 -78
- package/lib/loopBackstop.mjs +2 -1
- package/lib/machine.mjs +544 -0
- package/lib/machineLink.mjs +446 -0
- package/lib/machineRoutes.mjs +68 -19
- package/lib/machineRuns.mjs +85 -4
- package/lib/machineSeal.mjs +6 -31
- package/lib/manager.mjs +134 -12
- package/lib/mcp-stdio.mjs +492 -215
- package/lib/mcpRelay.mjs +34 -35
- package/lib/members.json +1 -1
- package/lib/modelRoute.mjs +162 -0
- package/lib/nativeHost.mjs +81 -90
- package/lib/nativeSenses.mjs +258 -0
- package/lib/nerves.mjs +523 -0
- package/lib/network.mjs +117 -278
- package/lib/networkPlaces.mjs +578 -0
- package/lib/nextStep.mjs +95 -0
- package/lib/notify.mjs +2 -2
- package/lib/nudge.mjs +116 -10
- package/lib/originals.mjs +216 -0
- package/lib/outsideEvents.mjs +383 -0
- package/lib/outsideRuns.mjs +230 -0
- package/lib/ownMachines.mjs +674 -256
- package/lib/pain.mjs +215 -0
- package/lib/pairing.mjs +91 -11
- package/lib/paths.mjs +42 -3
- package/lib/peerProcess.mjs +21 -7
- package/lib/peopleLink.mjs +268 -0
- package/lib/personNotices.mjs +3 -2
- package/lib/phones.mjs +252 -542
- package/lib/placeCards.mjs +282 -0
- package/lib/placeChecks.mjs +95 -0
- package/lib/placeCommands.mjs +8 -17
- package/lib/placeRequests.mjs +152 -0
- package/lib/placeStore.mjs +295 -0
- package/lib/placeTool.d.ts +12 -0
- package/lib/placeTool.js +40 -0
- package/lib/places.mjs +63 -14
- package/lib/plans.mjs +53 -8
- package/lib/presence.mjs +270 -0
- package/lib/privateNetwork.d.ts +2 -0
- package/lib/privateNetwork.js +93 -0
- package/lib/proposals.mjs +300 -0
- package/lib/publicFetch.d.ts +32 -0
- package/lib/publicFetch.js +248 -0
- package/lib/reach.mjs +128 -0
- package/lib/rebuildable.mjs +72 -0
- package/lib/recall.mjs +216 -0
- package/lib/record.mjs +13 -0
- package/lib/reflexes.mjs +392 -0
- package/lib/relayLimits.mjs +31 -2
- package/lib/releaseNotice.mjs +198 -0
- package/lib/removeHarness.mjs +15 -4
- package/lib/repoLinks.mjs +204 -35
- package/lib/runAuthority.mjs +102 -39
- package/lib/runBrief.mjs +93 -40
- package/lib/runRequests.mjs +52 -14
- package/lib/runUsage.mjs +31 -0
- package/lib/runWorker.mjs +74 -25
- package/lib/runner.mjs +289 -45
- package/lib/runtime-install.mjs +37 -8
- package/lib/schedules.mjs +171 -47
- package/lib/screenWatches.mjs +221 -0
- package/lib/sealed.mjs +12 -30
- package/lib/sealedThreads.mjs +198 -392
- package/lib/secretStore.mjs +178 -0
- package/lib/secrets.mjs +11 -0
- package/lib/seen.mjs +3 -9
- package/lib/selfUpdate.mjs +51 -15
- package/lib/senseCall.mjs +1514 -0
- package/lib/senseHook.mjs +114 -0
- package/lib/senseTools.mjs +1298 -0
- package/lib/sessionBriefs.mjs +87 -0
- package/lib/sessionControl.mjs +63 -13
- package/lib/sessionFiles.mjs +85 -0
- package/lib/setupChoices.mjs +12 -3
- package/lib/setupMode.mjs +70 -25
- package/lib/sharedKeys.mjs +166 -0
- package/lib/sleep.mjs +396 -0
- package/lib/sources.mjs +306 -0
- package/lib/speech.mjs +166 -411
- package/lib/spoken.mjs +210 -0
- package/lib/steerHook.mjs +3 -1
- package/lib/steerQueue.mjs +40 -11
- package/lib/store.mjs +323 -130
- package/lib/stuck.mjs +85 -7
- package/lib/swarm.mjs +157 -49
- package/lib/swarmDevices.mjs +25 -85
- package/lib/swarmMemory.mjs +93 -9
- package/lib/t3.mjs +73 -3
- package/lib/taskCommands.mjs +51 -60
- package/lib/taskRooms.mjs +30 -4
- package/lib/taskRules.json +29 -0
- package/lib/taskRules.mjs +21 -0
- package/lib/taskRuns.mjs +74 -11
- package/lib/team.mjs +2 -1
- package/lib/threadActions.mjs +37 -9
- package/lib/threadAuthority.mjs +4 -4
- package/lib/threadBriefs.mjs +173 -43
- package/lib/threadNotes.mjs +320 -0
- package/lib/threadRecord.mjs +491 -0
- package/lib/threadRuns.mjs +216 -108
- package/lib/threadView.mjs +27 -30
- package/lib/threadWatches.mjs +1962 -0
- package/lib/timeSense.mjs +839 -0
- package/lib/tripwires.mjs +454 -0
- package/lib/ui.mjs +1 -1
- package/lib/vault.mjs +560 -45
- package/lib/vaultCommands.mjs +5 -3
- package/lib/vaultPeers.mjs +165 -0
- package/lib/vaultTools.d.ts +4 -1
- package/lib/vaultTools.js +22 -1
- package/lib/verdicts.mjs +12 -26
- package/lib/versions.mjs +117 -0
- package/lib/waitTool.mjs +278 -0
- package/lib/wakePicture.mjs +268 -0
- package/lib/wakeQueue.mjs +108 -0
- package/lib/watchResponses.mjs +533 -0
- package/lib/watches.mjs +290 -145
- package/lib/windowAsks.mjs +80 -17
- package/lib/worktrees.mjs +159 -9
- package/npm-shrinkwrap.json +138 -631
- package/package.json +7 -6
- package/release.json +211 -129
- package/lib/callSessions.mjs +0 -51
- package/lib/directLink.mjs +0 -349
- package/lib/peopleBoard.mjs +0 -131
- package/lib/projects.mjs +0 -2917
- package/lib/roomChannels.mjs +0 -667
package/README.md
CHANGED
|
@@ -126,7 +126,7 @@ socket and authenticated bridge. Features own their state and command handling:
|
|
|
126
126
|
| `runWorker.mjs` | Authorized board execution, workspace slots, holds, requeues and receipts |
|
|
127
127
|
| `boardFiles.mjs` | File storage, disclosure, redaction and file commands; `boardFileCommands.mjs` is its private command adapter |
|
|
128
128
|
| `goalCommands.mjs`, `taskCommands.mjs` | Goal/room operations and task lifecycle operations |
|
|
129
|
-
| `boardThreads.mjs`, `boardWatches.mjs`, `boardTools.mjs` |
|
|
129
|
+
| `boardThreads.mjs`, `boardWatches.mjs`, `boardTools.mjs` | Messages between friends, watch/digest commands and local tool commands |
|
|
130
130
|
| `boardAccess.mjs` | Plain hosted-call policy and metadata-only responses |
|
|
131
131
|
| `connectors.mjs`, `connectorAuth.mjs` | Local app credentials, OAuth, discovered tools, scoped agent grants and durable operation receipts |
|
|
132
132
|
|
|
@@ -157,6 +157,10 @@ intended surface grants, then exercise that caller's runtime path.
|
|
|
157
157
|
|
|
158
158
|
## Operations
|
|
159
159
|
|
|
160
|
+
When a newer release is published, home tells you once, naming every computer behind it. The buddy's Settings shows
|
|
161
|
+
each computer's version with an Update button under Your devices, and `tryharness status` gives the command. Nothing
|
|
162
|
+
is fetched until you ask: Update runs the signed `tryharness upgrade` on that computer.
|
|
163
|
+
|
|
160
164
|
```sh
|
|
161
165
|
npx tryharness status
|
|
162
166
|
npx tryharness doctor
|
|
@@ -293,8 +297,7 @@ EmbeddingGemma 2's text part (one search space for code, agent sessions and boar
|
|
|
293
297
|
two injection guards (one reads long stretches and holds, one reads short ones and flags), a
|
|
294
298
|
credential detector and a screenshot text reader (PP-OCR), plus llama.cpp's own server build
|
|
295
299
|
(about 860 MB of models). Two more come down the first time they are used: speech for the buddy's
|
|
296
|
-
Talk (
|
|
297
|
-
the buddy; elsewhere NVIDIA's Parakeet TDT 0.6B v3, 672 MB) and the search model's image and audio part
|
|
300
|
+
Talk (on a Mac with macOS 26 Apple's own on-device transcriber through the buddy, which downloads nothing here; elsewhere LFM3-Omni, 1.4 GB, already on the computer holding the board) and the search model's image and audio part
|
|
298
301
|
(555 MB) when you first add a folder of recordings or screenshots. The search model runs on the
|
|
299
302
|
GPU when this machine's check finds it faster, the CPU otherwise; the classifiers run in native
|
|
300
303
|
ONNX Runtime. Background work runs at the OS's background priority and waits in Low Power Mode,
|
|
@@ -310,7 +313,7 @@ What they do:
|
|
|
310
313
|
repository, and each run's receipt. Agents can call `search_code`, `search_files`,
|
|
311
314
|
`compare_screens` (two screenshots of UI work, before and after: what changed and which text)
|
|
312
315
|
and `search_screen` (what you saw in tabs shared with Harness, asked of your own Harness window
|
|
313
|
-
sealed over
|
|
316
|
+
sealed over that browser's line from your device list, so Harness's server carries it unread; your Allow in
|
|
314
317
|
that window comes first).
|
|
315
318
|
- **Checks:** a finished run gets a receipt from its own session file; the coordinator hands an
|
|
316
319
|
untested "tests pass" to an agent to check. An agent's post that reads like orders to the
|
|
@@ -358,7 +361,7 @@ daily cap; instead, past 10 hand-offs in a row between your agents with no word
|
|
|
358
361
|
reads as orders aimed at your agents, or words through Harness's server it could not read, also wait; a flag is only
|
|
359
362
|
a label. A task with no folder runs in its thread's scratch folder, and your Start always works on one that waits.
|
|
360
363
|
Different agents work in one folder side by side; one agent takes one turn at a time there. A task Claude Code or
|
|
361
|
-
Codex posts from a session you typed in counts as yours. Work another person's agents ask for runs held in: Claude
|
|
364
|
+
Codex posts from a session you typed in counts as yours. Work another person's agents ask for in a jam runs held in: Claude
|
|
362
365
|
Code or Codex in restricted mode in a copy of the folder, with none of your credentials, screen, memory,
|
|
363
366
|
conversations, library, wallet or secrets in reach and no network. It reads only its own folder, git's folder for
|
|
364
367
|
its repository and the programs it builds with, nothing else of yours, until you press Start; Pi and OpenCode wait
|
|
@@ -388,7 +391,7 @@ MCP client, gets it from its extension, which launches it and gives pi its tools
|
|
|
388
391
|
Work stays where the agent lives. Bankr, Quotient and Muse live in Harness, not on any machine,
|
|
389
392
|
so a task posted for one of them (`tryharness board post --for bankr`, or `post_task` from any
|
|
390
393
|
agent here) goes up the bridge and waits on the server, where Bankr takes it under the limits
|
|
391
|
-
the user set in Harness and Quotient answers it with
|
|
394
|
+
the user set in Harness and Quotient answers it with research over its tracked markets, assets and forecasts; the
|
|
392
395
|
daemon must be connected to post it, and `get_task` (or `tryharness board show <id>`) with its
|
|
393
396
|
id reads it back. A task for a coding agent or Grok Bot waits here. A task for several agents
|
|
394
397
|
at once is for agents in one place.
|
|
@@ -420,20 +423,22 @@ waits on the worker and reaches home when it is back. Only the computer holding
|
|
|
420
423
|
tasks, rounds and sweeps. When the copy has to start over, the old one is kept in
|
|
421
424
|
`~/.harness/board-backups`.
|
|
422
425
|
|
|
423
|
-
Once home confirms a worker, the two
|
|
424
|
-
|
|
425
|
-
|
|
426
|
+
Once home confirms a worker, the two link over WebRTC, introduced through Harness and each
|
|
427
|
+
admitting only the other's key. Their calls, questions and views go over that channel alone, so a
|
|
428
|
+
worker's agents reach home's board even when its line to Harness is down. Harness carries only the
|
|
429
|
+
introduction and, for a worker with no channel, home's notices, which it keeps while the worker is
|
|
430
|
+
away and which wake a cloud computer that sleeps. The worker dials again when its channel ends.
|
|
426
431
|
|
|
427
432
|
A worker can stand in for home when home has been away past `standInAfterMs` in
|
|
428
433
|
`~/.harness/config.json`. That is unset, so off, until its deadline is measured. While it stands in,
|
|
429
434
|
the worker holds the board; once home is back it takes the board back with the stand-in's changes
|
|
430
435
|
and the worker follows it again.
|
|
431
436
|
|
|
432
|
-
The browser you use Harness in
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
Settings lists
|
|
437
|
+
The browser you use Harness in reaches this computer end to end once the browser is approved on
|
|
438
|
+
your device list: you open Harness in it and approve it from a device you already use, and every
|
|
439
|
+
computer on the list answers it. Setup also installs a native messaging host
|
|
440
|
+
(`ai.tryharness.daemon`) so the Harness extension hears this computer and can open a Harness page
|
|
441
|
+
for work that waits on one. Settings lists your devices and removes any of them.
|
|
437
442
|
|
|
438
443
|
Each agent's card names its model and effort and its specialties on that model, each with its
|
|
439
444
|
evidence: a specialist agent's fixed role (Bankr, Quotient), benchmarks, its record on this board and
|
|
@@ -448,9 +453,6 @@ standing functions, held by Harness or by the agent the person appoints.
|
|
|
448
453
|
room. Agents read and post in the room with `read_room` and `post_to_room`, and search it, the whole swarm's memory or add to it with `swarm_memory`; mentioning `@codex` or
|
|
449
454
|
`@claude` wakes that agent with a run in the goal's folder, and jobs they post with the goal as parent run without a
|
|
450
455
|
Start. Harness facilitates and answers once. `tryharness goal show <id>` prints the room, `goal stop <id>` ends
|
|
451
|
-
everything, `goal resume <id>` reopens a room that paused at a backstop
|
|
452
|
-
|
|
456
|
+
everything, and `goal resume <id>` reopens a room that paused at a backstop. `tryharness room post <goal> <text>` posts as you.
|
|
457
|
+
Work with other people's agents happens only in a jam (PRODUCT.md, "Working with other people").
|
|
453
458
|
|
|
454
|
-
Parakeet TDT 0.6B v3 is by NVIDIA, licensed under CC BY 4.0
|
|
455
|
-
(https://creativecommons.org/licenses/by/4.0/); the relay uses the 8-bit ONNX export by
|
|
456
|
-
istupakov (https://huggingface.co/istupakov/parakeet-tdt-0.6b-v3-onnx), unmodified.
|
package/assets/dsh-plugin.mjs
CHANGED
|
@@ -15,6 +15,12 @@ const harness = () =>
|
|
|
15
15
|
() => null
|
|
16
16
|
);
|
|
17
17
|
|
|
18
|
+
// The senses at a tool call (senseCall.mjs): what the session read, and the tripwire on what it writes.
|
|
19
|
+
const sensing = () =>
|
|
20
|
+
import(pathToFileURL(path.join(RUNTIME, "lib", "senseCall.mjs")).href).catch(
|
|
21
|
+
() => null
|
|
22
|
+
);
|
|
23
|
+
|
|
18
24
|
export const name = "tryharness";
|
|
19
25
|
|
|
20
26
|
const pids = [process.pid, process.ppid];
|
|
@@ -51,9 +57,15 @@ export function apply(ctx) {
|
|
|
51
57
|
if (!board || !where(agent).session_id) return downstream;
|
|
52
58
|
await board.notePrompt(AGENT, where(agent), pids);
|
|
53
59
|
const waiting = await board.takeMessages(AGENT, where(agent).session_id);
|
|
60
|
+
let edge = "";
|
|
61
|
+
try {
|
|
62
|
+
edge = (await sensing())?.edgeAtPause(where(agent).session_id) ?? "";
|
|
63
|
+
} catch {}
|
|
54
64
|
const text = [
|
|
55
65
|
waiting.length ? board.messagesText(waiting) : "",
|
|
56
66
|
await board.boardNudgeIfChanged(AGENT),
|
|
67
|
+
// The edge line waits for the session's pause: its next turn (senseCall.mjs).
|
|
68
|
+
edge,
|
|
57
69
|
]
|
|
58
70
|
.filter(Boolean)
|
|
59
71
|
.join("\n\n");
|
|
@@ -61,12 +73,71 @@ export function apply(ctx) {
|
|
|
61
73
|
? { ...downstream, messages: [...downstream.messages, message(text)] }
|
|
62
74
|
: downstream;
|
|
63
75
|
});
|
|
64
|
-
//
|
|
76
|
+
// Before a tool call: a write that would undo a change the session has not seen is denied, with the change, until it
|
|
77
|
+
// reads it. Another policy's denial stands.
|
|
78
|
+
ctx.on("tools/pre-execute", async (exec, next) => {
|
|
79
|
+
const downstream = await next();
|
|
80
|
+
const session = exec?.agent?.session?.header?.id;
|
|
81
|
+
if (downstream?.kind !== "allow" || !session) return downstream;
|
|
82
|
+
const sense = await sensing();
|
|
83
|
+
let held = null;
|
|
84
|
+
try {
|
|
85
|
+
held = sense?.beforeCall({
|
|
86
|
+
session,
|
|
87
|
+
cwd: process.cwd(),
|
|
88
|
+
tool: exec?.name,
|
|
89
|
+
input: exec?.arguments,
|
|
90
|
+
});
|
|
91
|
+
} catch {}
|
|
92
|
+
return held?.hold ? { kind: "deny", reason: held.hold } : downstream;
|
|
93
|
+
});
|
|
94
|
+
// After a tool call: what it read and wrote, and what Harness noticed for this session while it works, read with the
|
|
95
|
+
// tool's result, as every other agent's after-call hook gives it (senseHook.mjs --after). DeepSeek Harness adds it
|
|
96
|
+
// before the next request.
|
|
97
|
+
ctx.on("tools/post-execute", async (exec, _result, next) => {
|
|
98
|
+
const downstream = await next();
|
|
99
|
+
const session = exec?.agent?.session?.header?.id;
|
|
100
|
+
const sense = session ? await sensing() : null;
|
|
101
|
+
const said = [];
|
|
102
|
+
try {
|
|
103
|
+
said.push(
|
|
104
|
+
sense?.afterCall({
|
|
105
|
+
session,
|
|
106
|
+
agent: AGENT,
|
|
107
|
+
cwd: process.cwd(),
|
|
108
|
+
tool: exec?.name,
|
|
109
|
+
input: exec?.arguments,
|
|
110
|
+
// The agent's process is this one: its MCP server finds the session by it.
|
|
111
|
+
agentPid: process.pid,
|
|
112
|
+
output: _result?.content ?? _result,
|
|
113
|
+
})
|
|
114
|
+
);
|
|
115
|
+
said.push(sense?.notesAtStep(session, exec?.name ?? null));
|
|
116
|
+
} catch {}
|
|
117
|
+
const text = said.filter(Boolean).join("\n\n");
|
|
118
|
+
if (!text) return downstream;
|
|
119
|
+
return {
|
|
120
|
+
...downstream,
|
|
121
|
+
additionalContexts: [
|
|
122
|
+
message(text),
|
|
123
|
+
...(downstream?.additionalContexts ?? []),
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
// A turn about to end: a message waiting from Harness, the person's words or a reading that would have woken it keep
|
|
128
|
+
// it going (nudge.mjs steersAtTurnEnd); otherwise the session waits for the person.
|
|
65
129
|
ctx.on("agent/turn-stopping", async ({ agent }) => {
|
|
66
130
|
const board = await harness();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
131
|
+
const session = where(agent).session_id;
|
|
132
|
+
if (!board || !session) return;
|
|
133
|
+
const waiting = await board.takeMessages(AGENT, session);
|
|
134
|
+
const text = [
|
|
135
|
+
waiting.length ? board.messagesText(waiting) : "",
|
|
136
|
+
board.steersAtTurnEnd(session),
|
|
137
|
+
]
|
|
138
|
+
.filter(Boolean)
|
|
139
|
+
.join("\n\n");
|
|
140
|
+
if (text) agent.steer(message(text));
|
|
70
141
|
else await board.noteTurn(AGENT, where(agent), pids);
|
|
71
142
|
});
|
|
72
143
|
}
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
// Harness inside Herdr: your swarm's threads beside your agents. Each thread says who works, what it is on, and what
|
|
2
|
+
// waits on you; clicking one goes to its Herdr space, where its agents' turns run. Asking here starts a thread in the
|
|
3
|
+
// focused terminal's folder. Everything comes from `tryharness herdr` (Harness's CLI), so the panel holds no logic.
|
|
4
|
+
import { View, div, svg } from "gpui-kit";
|
|
5
|
+
import { v_flex, h_flex, InputState, Input } from "gpui-base";
|
|
6
|
+
import { exec, focused, nextCommand, notify, run, spaces, theme } from "herdr";
|
|
7
|
+
|
|
8
|
+
// Threads change at the speed of agents' turns: a read every few seconds is enough, and costs one CLI call.
|
|
9
|
+
const READ_EVERY_MS = 4000;
|
|
10
|
+
|
|
11
|
+
/** Where a thread asked here works: the focused terminal's folder, else the shown space's (the panel itself focused). */
|
|
12
|
+
const askFolder = () =>
|
|
13
|
+
focused()?.cwd || spaces().find((space) => space.active)?.folder || null;
|
|
14
|
+
|
|
15
|
+
const order = (a, b) =>
|
|
16
|
+
b.needsYou - a.needsYou ||
|
|
17
|
+
b.working.length - a.working.length ||
|
|
18
|
+
String(b.at ?? "").localeCompare(String(a.at ?? ""));
|
|
19
|
+
|
|
20
|
+
export default class Harness extends View {
|
|
21
|
+
init(_props, cx) {
|
|
22
|
+
this.threads = [];
|
|
23
|
+
this.problem = null;
|
|
24
|
+
this.sending = false;
|
|
25
|
+
this.needs = new Map();
|
|
26
|
+
this.showing = new Set();
|
|
27
|
+
this.posts = new Map();
|
|
28
|
+
this.input = InputState.new({ placeholder: "Ask your swarm…" });
|
|
29
|
+
this.input.on("submit", (_e, cx) => this.ask(cx));
|
|
30
|
+
this.replyTo = null;
|
|
31
|
+
cx.timer.every(READ_EVERY_MS, (cx) => this.read(cx));
|
|
32
|
+
this.read(cx);
|
|
33
|
+
// Its commands, for keys bound in Herdr's keys.json ("harness.next", "harness.ask") or `herdr-app do harness.next`.
|
|
34
|
+
cx.spawn(async (cx) => {
|
|
35
|
+
for (;;) {
|
|
36
|
+
const command = await nextCommand();
|
|
37
|
+
if (command === "next") this.next();
|
|
38
|
+
if (command === "ask") this.input.focus();
|
|
39
|
+
cx.notify();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
replying() {
|
|
45
|
+
return this.threads.find((thread) => thread.id === this.replyTo) ?? null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** To the space of the thread that most wants the person: waiting on them, else working, else the latest. */
|
|
49
|
+
next() {
|
|
50
|
+
const shown = this.threads.find((thread) => thread.space);
|
|
51
|
+
if (shown) this.open(shown);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
read(cx) {
|
|
55
|
+
cx.spawn(async (cx) => {
|
|
56
|
+
try {
|
|
57
|
+
const out = await exec("tryharness", ["herdr", "board"]);
|
|
58
|
+
if (out.code !== 0)
|
|
59
|
+
throw new Error(out.stderr.trim().split("\n").at(-1) || "no answer");
|
|
60
|
+
this.threads = JSON.parse(out.stdout).threads.sort(order);
|
|
61
|
+
for (const id of this.showing) this.readPosts(id, cx);
|
|
62
|
+
this.problem = null;
|
|
63
|
+
this.tell();
|
|
64
|
+
} catch {
|
|
65
|
+
// What failed is in Harness's own logs; here, what to do about it.
|
|
66
|
+
this.problem =
|
|
67
|
+
"Harness isn't running on this computer. Start it with: npx tryharness";
|
|
68
|
+
}
|
|
69
|
+
cx.notify();
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** A thread that starts waiting on you says so once, with a way to its space. */
|
|
74
|
+
tell() {
|
|
75
|
+
for (const thread of this.threads) {
|
|
76
|
+
const before = this.needs.get(thread.id) ?? 0;
|
|
77
|
+
if (thread.needsYou > before)
|
|
78
|
+
notify({
|
|
79
|
+
title: `${thread.title} needs you`,
|
|
80
|
+
body: thread.line ?? undefined,
|
|
81
|
+
level: "warning",
|
|
82
|
+
...(thread.space
|
|
83
|
+
? { action: { name: "space.select", args: { id: thread.space } } }
|
|
84
|
+
: {}),
|
|
85
|
+
});
|
|
86
|
+
this.needs.set(thread.id, thread.needsYou);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Enter: into the thread being replied to, else a new thread in the shown folder. */
|
|
91
|
+
ask(cx) {
|
|
92
|
+
const text = this.input.value().trim();
|
|
93
|
+
if (!text || this.sending) return;
|
|
94
|
+
const reply = this.threads.find((thread) => thread.id === this.replyTo);
|
|
95
|
+
const folder = askFolder();
|
|
96
|
+
if (!reply && !folder) {
|
|
97
|
+
this.problem =
|
|
98
|
+
"Open a space in the folder the thread should work in, then ask.";
|
|
99
|
+
return cx.notify();
|
|
100
|
+
}
|
|
101
|
+
this.sending = true;
|
|
102
|
+
cx.notify();
|
|
103
|
+
const args = reply
|
|
104
|
+
? ["herdr", "post", reply.id, text]
|
|
105
|
+
: ["herdr", "start", folder, text];
|
|
106
|
+
cx.spawn(async (cx) => {
|
|
107
|
+
const out = await exec("tryharness", args).catch((error) => ({
|
|
108
|
+
code: 1,
|
|
109
|
+
stderr: String(error.message ?? error),
|
|
110
|
+
}));
|
|
111
|
+
this.sending = false;
|
|
112
|
+
if (out.code === 0) this.input.set_value("");
|
|
113
|
+
else
|
|
114
|
+
this.problem = `Harness didn't take it: ${out.stderr.trim().split("\n").at(-1)}`;
|
|
115
|
+
this.read(cx);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** A thread clicked: its space shown, and what is typed next goes into it. */
|
|
120
|
+
open(thread) {
|
|
121
|
+
this.replyTo = thread.id;
|
|
122
|
+
if (thread.space) run("space.select", { id: thread.space });
|
|
123
|
+
else exec("tryharness", ["desktop"]).catch(() => null);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
mark(thread, t) {
|
|
127
|
+
if (thread.needsYou)
|
|
128
|
+
return div()
|
|
129
|
+
.flex_none()
|
|
130
|
+
.px(6)
|
|
131
|
+
.h(18)
|
|
132
|
+
.rounded(5)
|
|
133
|
+
.bg(t.blocked + "26")
|
|
134
|
+
.text_size(10.5)
|
|
135
|
+
.font_semibold()
|
|
136
|
+
.text_color(t.blocked)
|
|
137
|
+
.flex()
|
|
138
|
+
.items_center()
|
|
139
|
+
.child("Needs you");
|
|
140
|
+
if (thread.working.length)
|
|
141
|
+
return svg("mods/workspace-chrome/spinner.svg")
|
|
142
|
+
.size(12)
|
|
143
|
+
.mx(1)
|
|
144
|
+
.flex_none()
|
|
145
|
+
.text_color(t.working)
|
|
146
|
+
.spin(900);
|
|
147
|
+
return div()
|
|
148
|
+
.size(7)
|
|
149
|
+
.mx(3)
|
|
150
|
+
.flex_none()
|
|
151
|
+
.rounded(4)
|
|
152
|
+
.border(1.5)
|
|
153
|
+
.border_color(t.idle ?? t.dim);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
render() {
|
|
157
|
+
const t = theme();
|
|
158
|
+
const rows = this.threads.map((thread) =>
|
|
159
|
+
v_flex().child(this.row(thread, t)).child(this.shown(thread, t))
|
|
160
|
+
);
|
|
161
|
+
return this.frame(rows, t);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** A thread's line: click to go to its space and reply into it. */
|
|
165
|
+
row(thread, t) {
|
|
166
|
+
return v_flex()
|
|
167
|
+
.id(`hs-${thread.id}`)
|
|
168
|
+
.gap(2)
|
|
169
|
+
.px(10)
|
|
170
|
+
.py(7)
|
|
171
|
+
.rounded(7)
|
|
172
|
+
.cursor_pointer()
|
|
173
|
+
.hover((s) => s.bg(t.hover ?? t.raised))
|
|
174
|
+
.on_click(() => this.open(thread))
|
|
175
|
+
.child(
|
|
176
|
+
h_flex()
|
|
177
|
+
.gap(7)
|
|
178
|
+
.items_center()
|
|
179
|
+
.child(this.mark(thread, t))
|
|
180
|
+
.child(
|
|
181
|
+
div()
|
|
182
|
+
.flex_1()
|
|
183
|
+
.min_w(0)
|
|
184
|
+
.truncate()
|
|
185
|
+
.text_size(12.5)
|
|
186
|
+
.text_color(t.foreground)
|
|
187
|
+
.child(thread.title)
|
|
188
|
+
)
|
|
189
|
+
)
|
|
190
|
+
.when(Boolean(thread.line), (el) =>
|
|
191
|
+
el.child(
|
|
192
|
+
div()
|
|
193
|
+
.pl(20)
|
|
194
|
+
.truncate()
|
|
195
|
+
.text_size(11.5)
|
|
196
|
+
.text_color(t.muted)
|
|
197
|
+
.child(thread.line)
|
|
198
|
+
)
|
|
199
|
+
)
|
|
200
|
+
.when(thread.working.length > 0, (el) =>
|
|
201
|
+
el.child(
|
|
202
|
+
div()
|
|
203
|
+
.pl(20)
|
|
204
|
+
.truncate()
|
|
205
|
+
.text_size(11)
|
|
206
|
+
.text_color(t.dim)
|
|
207
|
+
.child(`${thread.working.join(", ")} working`)
|
|
208
|
+
)
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Under a thread: its latest posts when shown, read through tryharness herdr read. */
|
|
213
|
+
shown(thread, t) {
|
|
214
|
+
const open = this.showing.has(thread.id);
|
|
215
|
+
const posts = this.posts.get(thread.id) ?? [];
|
|
216
|
+
return v_flex()
|
|
217
|
+
.pl(30)
|
|
218
|
+
.pr(10)
|
|
219
|
+
.pb(6)
|
|
220
|
+
.gap(4)
|
|
221
|
+
.child(
|
|
222
|
+
div()
|
|
223
|
+
.id(`hs-show-${thread.id}`)
|
|
224
|
+
.text_size(11)
|
|
225
|
+
.text_color(t.accent)
|
|
226
|
+
.cursor_pointer()
|
|
227
|
+
.on_click((_e, cx) => this.toggle(thread, cx))
|
|
228
|
+
.child(open ? "Hide posts" : "Show latest posts")
|
|
229
|
+
)
|
|
230
|
+
.when(open, (el) =>
|
|
231
|
+
el.children(
|
|
232
|
+
posts.map((post, index) =>
|
|
233
|
+
v_flex()
|
|
234
|
+
.id(`hs-post-${thread.id}-${index}`)
|
|
235
|
+
.gap(1)
|
|
236
|
+
.child(div().text_size(11).text_color(t.dim).child(post.by))
|
|
237
|
+
.child(
|
|
238
|
+
div().text_size(12).text_color(t.foreground).child(post.text)
|
|
239
|
+
)
|
|
240
|
+
)
|
|
241
|
+
)
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
toggle(thread, cx) {
|
|
246
|
+
if (this.showing.has(thread.id)) this.showing.delete(thread.id);
|
|
247
|
+
else {
|
|
248
|
+
this.showing.add(thread.id);
|
|
249
|
+
this.readPosts(thread.id, cx);
|
|
250
|
+
}
|
|
251
|
+
cx.notify();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** A shown thread's posts, read again with the board. */
|
|
255
|
+
readPosts(id, cx) {
|
|
256
|
+
cx.spawn(async (cx) => {
|
|
257
|
+
const out = await exec("tryharness", ["herdr", "read", id]).catch(
|
|
258
|
+
() => null
|
|
259
|
+
);
|
|
260
|
+
try {
|
|
261
|
+
if (out?.code === 0) this.posts.set(id, JSON.parse(out.stdout).posts);
|
|
262
|
+
} catch {}
|
|
263
|
+
cx.notify();
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
frame(rows, t) {
|
|
268
|
+
return v_flex()
|
|
269
|
+
.id("harness")
|
|
270
|
+
.size_full()
|
|
271
|
+
.min_h(0)
|
|
272
|
+
.bg(t.chrome ?? t.surface)
|
|
273
|
+
.text_color(t.foreground)
|
|
274
|
+
.child(
|
|
275
|
+
h_flex()
|
|
276
|
+
.px(12)
|
|
277
|
+
.pt(12)
|
|
278
|
+
.pb(8)
|
|
279
|
+
.items_center()
|
|
280
|
+
.child(div().flex_1().text_size(13).font_semibold().child("Harness"))
|
|
281
|
+
.child(
|
|
282
|
+
div()
|
|
283
|
+
.text_size(11)
|
|
284
|
+
.text_color(t.dim)
|
|
285
|
+
.child(
|
|
286
|
+
`${this.threads.length} ${this.threads.length === 1 ? "thread" : "threads"}`
|
|
287
|
+
)
|
|
288
|
+
)
|
|
289
|
+
)
|
|
290
|
+
.child(
|
|
291
|
+
div()
|
|
292
|
+
.px(10)
|
|
293
|
+
.pb(8)
|
|
294
|
+
.child(
|
|
295
|
+
Input.new(this.input)
|
|
296
|
+
.h(32)
|
|
297
|
+
.px(9)
|
|
298
|
+
.rounded(8)
|
|
299
|
+
.border_1()
|
|
300
|
+
.border_color(t.input)
|
|
301
|
+
.bg(t.background)
|
|
302
|
+
.text_size(12.5)
|
|
303
|
+
.text_color(t.foreground)
|
|
304
|
+
)
|
|
305
|
+
)
|
|
306
|
+
.child(
|
|
307
|
+
div()
|
|
308
|
+
.px(12)
|
|
309
|
+
.pb(6)
|
|
310
|
+
.text_size(11)
|
|
311
|
+
.text_color(t.dim)
|
|
312
|
+
.child(
|
|
313
|
+
this.sending
|
|
314
|
+
? "Sending…"
|
|
315
|
+
: this.replying()
|
|
316
|
+
? `Enter posts to ${this.replying().title}.`
|
|
317
|
+
: `Enter starts a thread in ${askFolder() ?? "this space's folder"}.`
|
|
318
|
+
)
|
|
319
|
+
)
|
|
320
|
+
.when(Boolean(this.replying()) && !this.sending, (el) =>
|
|
321
|
+
el.child(
|
|
322
|
+
div()
|
|
323
|
+
.id("hs-new-thread")
|
|
324
|
+
.px(12)
|
|
325
|
+
.pb(8)
|
|
326
|
+
.text_size(11)
|
|
327
|
+
.text_color(t.accent)
|
|
328
|
+
.cursor_pointer()
|
|
329
|
+
.on_click((_e, cx) => {
|
|
330
|
+
this.replyTo = null;
|
|
331
|
+
cx.notify();
|
|
332
|
+
})
|
|
333
|
+
.child("Start a new thread instead")
|
|
334
|
+
)
|
|
335
|
+
)
|
|
336
|
+
.when(Boolean(this.problem), (el) =>
|
|
337
|
+
el.child(
|
|
338
|
+
div()
|
|
339
|
+
.px(12)
|
|
340
|
+
.pb(8)
|
|
341
|
+
.text_size(11.5)
|
|
342
|
+
.text_color(t.blocked)
|
|
343
|
+
.child(this.problem)
|
|
344
|
+
)
|
|
345
|
+
)
|
|
346
|
+
.when(!this.problem && this.threads.length === 0, (el) =>
|
|
347
|
+
el.child(
|
|
348
|
+
div()
|
|
349
|
+
.px(12)
|
|
350
|
+
.text_size(12)
|
|
351
|
+
.text_color(t.dim)
|
|
352
|
+
.child(
|
|
353
|
+
"No threads yet. Ask above, and your agents take it from there."
|
|
354
|
+
)
|
|
355
|
+
)
|
|
356
|
+
)
|
|
357
|
+
.child(
|
|
358
|
+
v_flex()
|
|
359
|
+
.id("hs-list")
|
|
360
|
+
.flex_1()
|
|
361
|
+
.min_h(0)
|
|
362
|
+
.px(4)
|
|
363
|
+
.overflow_y_scrollbar()
|
|
364
|
+
.children(rows)
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
}
|