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
|
@@ -17,8 +17,15 @@ const steering = () =>
|
|
|
17
17
|
(queue ??= import(
|
|
18
18
|
pathToFileURL(path.join(RUNTIME, "lib", "steerQueue.mjs")).href
|
|
19
19
|
).catch(() => null));
|
|
20
|
+
// The senses at a tool call (senseCall.mjs): what the session read, and the tripwire on what it writes.
|
|
21
|
+
let senses = null;
|
|
22
|
+
const sensing = () =>
|
|
23
|
+
(senses ??= import(
|
|
24
|
+
pathToFileURL(path.join(RUNTIME, "lib", "senseCall.mjs")).href
|
|
25
|
+
).catch(() => null));
|
|
20
26
|
// When OpenCode's client cannot take the message, a note rides on what the tool returns instead.
|
|
21
27
|
const notes = new Map();
|
|
28
|
+
const args = new Map();
|
|
22
29
|
const socketPath = async () =>
|
|
23
30
|
(await import(pathToFileURL(path.join(RUNTIME, "lib", "paths.mjs")).href))
|
|
24
31
|
.paths.socket;
|
|
@@ -53,35 +60,87 @@ const partId = () => {
|
|
|
53
60
|
);
|
|
54
61
|
};
|
|
55
62
|
|
|
63
|
+
// The person's words for a session, at its next tool call; Harness's own readings (kind "sense") ride on the tool's
|
|
64
|
+
// result instead. A note or a new brief goes in as the person's next message; a stop refuses the call.
|
|
65
|
+
async function steered(client, input) {
|
|
66
|
+
const steer = await steering();
|
|
67
|
+
if (!steer) return;
|
|
68
|
+
const items = steer.takeSteers(
|
|
69
|
+
input.sessionID,
|
|
70
|
+
steer.PARENT,
|
|
71
|
+
{ tool: input.tool ?? null },
|
|
72
|
+
undefined,
|
|
73
|
+
{ only: (item) => item.kind !== steer.SENSE }
|
|
74
|
+
);
|
|
75
|
+
if (!items.length) return;
|
|
76
|
+
const text = steer.steerText(items);
|
|
77
|
+
if (items.some((item) => item.kind === "stop")) throw new Error(text);
|
|
78
|
+
const send =
|
|
79
|
+
client?.session?.promptAsync?.bind(client.session) ??
|
|
80
|
+
client?.session?.prompt?.bind(client.session);
|
|
81
|
+
if (send)
|
|
82
|
+
await send({
|
|
83
|
+
path: { id: input.sessionID },
|
|
84
|
+
body: { parts: [{ type: "text", text }] },
|
|
85
|
+
}).catch(() => notes.set(input.callID, text));
|
|
86
|
+
else notes.set(input.callID, text);
|
|
87
|
+
}
|
|
88
|
+
|
|
56
89
|
export const TryHarnessPlugin = async ({ directory, client }) => ({
|
|
57
90
|
// An OpenCode subagent is a session of its own, so the person's word for it waits under that session. A note or a new
|
|
58
91
|
// brief goes in as the person's next message, which OpenCode queues for a session at work and the model reads as the
|
|
59
92
|
// person's own (words added to a tool's result are read as the tool's, Claude Code showed). A stop refuses every call
|
|
60
93
|
// with the reason until the session goes idle.
|
|
61
|
-
"tool.execute.before": async (input) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
})
|
|
78
|
-
|
|
94
|
+
"tool.execute.before": async (input, output) => {
|
|
95
|
+
if (!input?.sessionID) return;
|
|
96
|
+
// OpenCode hands a call's arguments only before it runs.
|
|
97
|
+
args.set(input.callID, output?.args);
|
|
98
|
+
await steered(client, input);
|
|
99
|
+
// A write that would undo a change the session has not seen is refused, with the change, until it reads it.
|
|
100
|
+
const sense = await sensing();
|
|
101
|
+
let held = null;
|
|
102
|
+
try {
|
|
103
|
+
held = sense?.beforeCall({
|
|
104
|
+
session: input.sessionID,
|
|
105
|
+
cwd: directory,
|
|
106
|
+
tool: input.tool,
|
|
107
|
+
input: output?.args,
|
|
108
|
+
// The call's own id, so two calls at once keep their own start (Harness's sense of time).
|
|
109
|
+
callId: input.callID,
|
|
110
|
+
});
|
|
111
|
+
} catch {}
|
|
112
|
+
if (!held?.hold) return;
|
|
113
|
+
args.delete(input.callID);
|
|
114
|
+
throw new Error(held.hold);
|
|
79
115
|
},
|
|
116
|
+
// After a tool call: a note the client could not take, what the call read and wrote (senseCall.mjs), and what Harness
|
|
117
|
+
// noticed while the session works (steerQueue.mjs "sense"), beside the tool's result, as every agent's own hook after
|
|
118
|
+
// a tool call gives it (senseHook.mjs --after).
|
|
80
119
|
"tool.execute.after": async (input, output) => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
120
|
+
if (!output) return;
|
|
121
|
+
const sense = input?.sessionID ? await sensing() : null;
|
|
122
|
+
const where = {
|
|
123
|
+
session: input?.sessionID,
|
|
124
|
+
agent: AGENT,
|
|
125
|
+
cwd: directory,
|
|
126
|
+
tool: input?.tool,
|
|
127
|
+
input: args.get(input?.callID) ?? input?.args,
|
|
128
|
+
callId: input?.callID,
|
|
129
|
+
// OpenCode is the agent's process here: its MCP server finds the session by it.
|
|
130
|
+
agentPid: process.pid,
|
|
131
|
+
output: output.output,
|
|
132
|
+
};
|
|
133
|
+
args.delete(input?.callID);
|
|
134
|
+
const said = [];
|
|
135
|
+
try {
|
|
136
|
+
said.push(sense?.afterCall(where));
|
|
137
|
+
said.push(sense?.notesAtStep(input?.sessionID, input?.tool ?? null));
|
|
138
|
+
} catch {}
|
|
139
|
+
const text = [notes.get(input?.callID), ...said]
|
|
140
|
+
.filter(Boolean)
|
|
141
|
+
.join("\n\n");
|
|
142
|
+
notes.delete(input?.callID);
|
|
143
|
+
if (text) output.output = `${output.output ?? ""}\n\n${text}`;
|
|
85
144
|
},
|
|
86
145
|
// A session's first message is its start (Claude Code's SessionStart: the whole board); each later one carries the
|
|
87
146
|
// board again only when it changed (UserPromptSubmit).
|
|
@@ -101,10 +160,16 @@ export const TryHarnessPlugin = async ({ directory, client }) => ({
|
|
|
101
160
|
const nudge = first
|
|
102
161
|
? await board.boardNudge(AGENT)
|
|
103
162
|
: await board.boardNudgeIfChanged(AGENT);
|
|
163
|
+
// The edge line waits for the session's pause: its next turn (senseCall.mjs).
|
|
164
|
+
let edge = "";
|
|
165
|
+
try {
|
|
166
|
+
edge = first ? "" : ((await sensing())?.edgeAtPause(sessionId) ?? "");
|
|
167
|
+
} catch {}
|
|
104
168
|
// Marked synthetic: the model reads them, and they are not the words typed here.
|
|
105
169
|
for (const text of [
|
|
106
170
|
messages.length ? board.messagesText(messages) : "",
|
|
107
171
|
nudge,
|
|
172
|
+
edge,
|
|
108
173
|
]) {
|
|
109
174
|
if (text)
|
|
110
175
|
output.parts.push({
|
package/assets/pi-extension.ts
CHANGED
|
@@ -208,6 +208,19 @@ export default function tryHarness(pi) {
|
|
|
208
208
|
const board = await harness().catch(() => null);
|
|
209
209
|
if (!board) return undefined;
|
|
210
210
|
await board.notePrompt(AGENT, where(ctx), pids);
|
|
211
|
+
// The edge line waits for the session's pause, its next turn; as a message after the context, never in the system
|
|
212
|
+
// prompt, so the provider's cache of what came before keeps working (senseCall.mjs).
|
|
213
|
+
try {
|
|
214
|
+
const sense = await sensing();
|
|
215
|
+
const edge = sense?.edgeAtPause(where(ctx).session_id) ?? "";
|
|
216
|
+
// For the model; the person is not shown it (Harness's readings sit behind its optional view).
|
|
217
|
+
if (edge && typeof pi.sendMessage === "function")
|
|
218
|
+
pi.sendMessage({
|
|
219
|
+
customType: "harness-edge",
|
|
220
|
+
content: edge,
|
|
221
|
+
display: false,
|
|
222
|
+
});
|
|
223
|
+
} catch {}
|
|
211
224
|
// What every agent with an MCP client reads in the handshake, then the queue. An older runtime has no
|
|
212
225
|
// HARNESS_INSTRUCTIONS and gives the queue alone.
|
|
213
226
|
const text = [
|
|
@@ -220,10 +233,76 @@ export default function tryHarness(pi) {
|
|
|
220
233
|
if (!text || typeof event?.systemPrompt !== "string") return undefined;
|
|
221
234
|
return { systemPrompt: `${event.systemPrompt}\n\n${text}` };
|
|
222
235
|
});
|
|
223
|
-
//
|
|
236
|
+
// The senses at a tool call (senseCall.mjs): what the session read, and the tripwire on what it writes. Before a call,
|
|
237
|
+
// a write that would undo a change the session has not seen is refused, with the change, until it reads it.
|
|
238
|
+
const sensing = () =>
|
|
239
|
+
import(
|
|
240
|
+
pathToFileURL(path.join(RUNTIME, "lib", "senseCall.mjs")).href
|
|
241
|
+
).catch(() => null);
|
|
242
|
+
pi.on("tool_call", async (event, ctx) => {
|
|
243
|
+
const { session_id: session, cwd } = where(ctx);
|
|
244
|
+
if (!session) return undefined;
|
|
245
|
+
const sense = await sensing();
|
|
246
|
+
let held = null;
|
|
247
|
+
try {
|
|
248
|
+
held = sense?.beforeCall({
|
|
249
|
+
session,
|
|
250
|
+
cwd,
|
|
251
|
+
tool: event?.toolName,
|
|
252
|
+
input: event?.input,
|
|
253
|
+
// The call's own id, so two calls at once keep their own start (Harness's sense of time).
|
|
254
|
+
callId: event?.toolCallId,
|
|
255
|
+
});
|
|
256
|
+
} catch {}
|
|
257
|
+
return held?.hold ? { block: true, reason: held.hold } : undefined;
|
|
258
|
+
});
|
|
259
|
+
// After each tool call: what the call read and wrote, and what Harness noticed while the session works, beside the
|
|
260
|
+
// tool's result, as every agent's own hook after a tool call gives it (senseHook.mjs --after).
|
|
261
|
+
pi.on("tool_result", async (event, ctx) => {
|
|
262
|
+
const { session_id: session, cwd } = where(ctx);
|
|
263
|
+
const sense = session ? await sensing() : null;
|
|
264
|
+
const said = [];
|
|
265
|
+
try {
|
|
266
|
+
said.push(
|
|
267
|
+
sense?.afterCall({
|
|
268
|
+
session,
|
|
269
|
+
agent: AGENT,
|
|
270
|
+
cwd,
|
|
271
|
+
tool: event?.toolName,
|
|
272
|
+
input: event?.input,
|
|
273
|
+
callId: event?.toolCallId,
|
|
274
|
+
// The agent's process is this one: its MCP server finds the session by it.
|
|
275
|
+
agentPid: process.pid,
|
|
276
|
+
output: event?.content,
|
|
277
|
+
failed: event?.isError === true,
|
|
278
|
+
})
|
|
279
|
+
);
|
|
280
|
+
said.push(sense?.notesAtStep(session, event?.toolName ?? null));
|
|
281
|
+
} catch {}
|
|
282
|
+
const text = said.filter(Boolean).join("\n\n");
|
|
283
|
+
if (!text) return undefined;
|
|
284
|
+
// A result given back with new content loses its structured part unless that comes back too (pi's docs).
|
|
285
|
+
return {
|
|
286
|
+
content: [...(event?.content ?? []), { type: "text", text }],
|
|
287
|
+
...(event?.structuredContent !== undefined
|
|
288
|
+
? { structuredContent: event.structuredContent }
|
|
289
|
+
: {}),
|
|
290
|
+
};
|
|
291
|
+
});
|
|
292
|
+
// When a run has settled, a message waiting from Harness starts the next turn (Claude Code's Stop hook does the same),
|
|
293
|
+
// and so do the person's words and a reading that would have woken the session (nudge.mjs steersAtTurnEnd); a
|
|
294
|
+
// reading that only informs waits for its next wake.
|
|
224
295
|
pi.on("agent_settled", async (_event, ctx) => {
|
|
225
296
|
const board = await harness().catch(() => null);
|
|
226
|
-
const
|
|
297
|
+
const sessionId = where(ctx).session_id;
|
|
298
|
+
const text = [
|
|
299
|
+
board ? await said(board, ctx) : "",
|
|
300
|
+
board?.steersAtTurnEnd && sessionId
|
|
301
|
+
? board.steersAtTurnEnd(sessionId)
|
|
302
|
+
: "",
|
|
303
|
+
]
|
|
304
|
+
.filter(Boolean)
|
|
305
|
+
.join("\n\n");
|
|
227
306
|
if (text) pi.sendUserMessage(text);
|
|
228
307
|
else if (board) await board.noteTurn(AGENT, where(ctx), pids);
|
|
229
308
|
});
|