tryharness 0.7.34 → 0.7.36
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/cli.mjs +24 -2
- package/lib/daemon.mjs +41 -8
- package/lib/goalCommands.mjs +5 -0
- package/lib/threadRuns.mjs +11 -2
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -1786,6 +1786,24 @@ async function agents() {
|
|
|
1786
1786
|
ui.outro("Done.");
|
|
1787
1787
|
}
|
|
1788
1788
|
|
|
1789
|
+
// The pairing link carries a public key, so its code is large: drawn two characters per module it
|
|
1790
|
+
// was 130 columns and wrapped into noise. Half blocks put two rows in one line at one column per
|
|
1791
|
+
// module (61 columns), and fixed black and white keep it scannable on light and dark themes.
|
|
1792
|
+
async function terminalQr(text) {
|
|
1793
|
+
const { default: encodeQR } = await import("qr");
|
|
1794
|
+
const rows = encodeQR(text, "raw", { ecc: "low", border: 4 });
|
|
1795
|
+
const lines = [];
|
|
1796
|
+
for (let y = 0; y < rows.length; y += 2) {
|
|
1797
|
+
const cells = rows[y].map((top, x) => {
|
|
1798
|
+
const foreground = top ? 30 : 97;
|
|
1799
|
+
const background = rows[y + 1]?.[x] ? 40 : 107;
|
|
1800
|
+
return `\x1b[${foreground};${background}m▀`;
|
|
1801
|
+
});
|
|
1802
|
+
lines.push(`${cells.join("")}\x1b[0m`);
|
|
1803
|
+
}
|
|
1804
|
+
return { lines, width: rows[0].length };
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1789
1807
|
async function phone() {
|
|
1790
1808
|
const sub = argv[0] || "pair";
|
|
1791
1809
|
if (sub === "pair") {
|
|
@@ -1794,11 +1812,15 @@ async function phone() {
|
|
|
1794
1812
|
throw new Error(
|
|
1795
1813
|
response.error || "the daemon could not make a pairing code"
|
|
1796
1814
|
);
|
|
1797
|
-
const
|
|
1815
|
+
const qr = await terminalQr(response.url);
|
|
1798
1816
|
console.log(
|
|
1799
1817
|
"Scan this with your phone's camera. The code works once, for 10 minutes.\n"
|
|
1800
1818
|
);
|
|
1801
|
-
console.log(
|
|
1819
|
+
console.log(qr.lines.join("\n"));
|
|
1820
|
+
if (process.stdout.columns && process.stdout.columns < qr.width)
|
|
1821
|
+
console.log(
|
|
1822
|
+
`\nThis window is narrower than the code (${qr.width} columns), so it may not scan. Widen it and run this again, or add --link to print the link.`
|
|
1823
|
+
);
|
|
1802
1824
|
if (has("--link"))
|
|
1803
1825
|
console.log(
|
|
1804
1826
|
`\n${response.url}\n\nThis link is the pairing secret: open it only on your own phone.`
|
package/lib/daemon.mjs
CHANGED
|
@@ -776,19 +776,37 @@ export async function startDaemon() {
|
|
|
776
776
|
// for a task's room, their go on that task. Anything else waits for the person's Start like any agent-written run.
|
|
777
777
|
// In such a thread, the person's own agents asking for work carry the person's go, as their @mention does (owner,
|
|
778
778
|
// October 13; docs/member-runs.md): Harness and its agents on its server (Bankr, Quotient), and the coding agents on
|
|
779
|
-
// this computer; full permissions, Stop always there. An agent the person set to wait still waits.
|
|
780
|
-
//
|
|
781
|
-
//
|
|
779
|
+
// this computer; full permissions, Stop always there. An agent the person set to wait still waits. Grok Bot and Muse
|
|
780
|
+
// carry it too for words the injection guard found clean (fromElsewhere, below). Work any other agent asked for
|
|
781
|
+
// (another person's agent, a call through Harness, Grok Bot's or Muse's flagged words) runs on a goal's authority only
|
|
782
|
+
// where it can be held in: Claude Code in restricted mode, in a copy of the folder this daemon made. Anything else waits.
|
|
782
783
|
const worktreeRoot = path.join(paths.home, "worktrees");
|
|
783
784
|
const restrictable = (agent, folder) =>
|
|
784
785
|
agent === "claude-code" && Boolean(folder) && within(folder, worktreeRoot);
|
|
785
786
|
const setToWait = (agent) =>
|
|
786
787
|
standingRules().find((rule) => rule.agent === agent)?.mode === "off";
|
|
787
|
-
|
|
788
|
+
// The person's own agents that run elsewhere (Grok Bot, Muse) carry the go too, for words the injection guard read and
|
|
789
|
+
// found clean (owner, October 18: only what actually needs the person waits for them). Words it flagged, or could not
|
|
790
|
+
// read, wait for the Start, and the thread says why (guardWait).
|
|
791
|
+
const fromElsewhere = (agent) => {
|
|
792
|
+
const entry = member(agent);
|
|
793
|
+
return entry?.road === "hosted" && entry.runs === "self" && entry.target;
|
|
794
|
+
};
|
|
795
|
+
const guardClean = (guard) =>
|
|
796
|
+
guard?.verdict === "clean" && !guard.unavailable;
|
|
797
|
+
const personsGo = (asker, agent, { hosted = false, guard = null } = {}) =>
|
|
788
798
|
asker === "user" ||
|
|
789
799
|
((member(asker)?.runs === "server" ||
|
|
790
|
-
(!hosted && member(asker)?.runs === "machine")
|
|
800
|
+
(!hosted && member(asker)?.runs === "machine") ||
|
|
801
|
+
(fromElsewhere(asker) && guardClean(guard))) &&
|
|
791
802
|
!setToWait(agent));
|
|
803
|
+
const guardWait = (asker, agent, guard) => {
|
|
804
|
+
if (!fromElsewhere(asker) || setToWait(agent) || guardClean(guard))
|
|
805
|
+
return null;
|
|
806
|
+
return !guard || guard.unavailable
|
|
807
|
+
? `The guard that reads ${nameOf(asker)}'s words for planted instructions is not running on this computer, so ${nameOf(agent)} waits for your Start.`
|
|
808
|
+
: `The guard flagged ${nameOf(asker)}'s words as possibly carrying instructions from something it read, so ${nameOf(agent)} waits for your Start. Read them before you start it.`;
|
|
809
|
+
};
|
|
792
810
|
const restrictedWait = (agent) =>
|
|
793
811
|
setToWait(agent)
|
|
794
812
|
? `${nameOf(agent)} is set to wait for your Start.`
|
|
@@ -1177,12 +1195,13 @@ export async function startDaemon() {
|
|
|
1177
1195
|
}
|
|
1178
1196
|
};
|
|
1179
1197
|
// `why`: what the agents are told in place of "mentioned you" (the coordinator's word to everyone in a thread).
|
|
1198
|
+
// `guard`: the injection guard's reading of the words, where the caller had it read (firewall.mjs inspect).
|
|
1180
1199
|
const wakeFor = (
|
|
1181
1200
|
goalId,
|
|
1182
1201
|
post,
|
|
1183
1202
|
author,
|
|
1184
1203
|
names = post.mentions,
|
|
1185
|
-
{ hosted = false, why = null } = {}
|
|
1204
|
+
{ hosted = false, why = null, guard } = {}
|
|
1186
1205
|
) => {
|
|
1187
1206
|
const goal = store.goal(goalId);
|
|
1188
1207
|
const { picks } = picksIn(store, post.text, names);
|
|
@@ -1204,10 +1223,11 @@ export async function startDaemon() {
|
|
|
1204
1223
|
);
|
|
1205
1224
|
else if (RUNNERS.has(agent))
|
|
1206
1225
|
threadRuns.wake(goalId, agent, reason, {
|
|
1207
|
-
go: personsGo(author, agent, { hosted }),
|
|
1226
|
+
go: personsGo(author, agent, { hosted, guard }),
|
|
1208
1227
|
asker: author,
|
|
1209
1228
|
pick: picks.get(agent),
|
|
1210
1229
|
words: post.text,
|
|
1230
|
+
held: guard === undefined ? null : guardWait(author, agent, guard),
|
|
1211
1231
|
});
|
|
1212
1232
|
else if (ASKABLE.has(agent))
|
|
1213
1233
|
told.push(askAgent(goalId, agent, reason, author));
|
|
@@ -1330,7 +1350,15 @@ export async function startDaemon() {
|
|
|
1330
1350
|
status: task.status,
|
|
1331
1351
|
result: task.result || "",
|
|
1332
1352
|
});
|
|
1333
|
-
} else if (goal.status === "open"
|
|
1353
|
+
} else if (goal.status === "open" && fromElsewhere(who) && !flag)
|
|
1354
|
+
// An answer from the person's agents elsewhere wakes its asker on the guard's reading of it, as their posts do.
|
|
1355
|
+
void readByGuard(text).then((guard) => {
|
|
1356
|
+
if (guard?.verdict === "flag" || guard?.verdict === "hold")
|
|
1357
|
+
store.meta(`flagged:${post.id}`, String(guard.score));
|
|
1358
|
+
wakeFor(goal.id, post, who, undefined, { guard });
|
|
1359
|
+
notifyBoard(store.getTask(goal.id));
|
|
1360
|
+
});
|
|
1361
|
+
else if (goal.status === "open") wakeFor(goal.id, post, who);
|
|
1334
1362
|
notifyBoard(store.getTask(goal.id));
|
|
1335
1363
|
};
|
|
1336
1364
|
const endGuestThreads = (goal, outcome) => {
|
|
@@ -1630,6 +1658,11 @@ export async function startDaemon() {
|
|
|
1630
1658
|
},
|
|
1631
1659
|
});
|
|
1632
1660
|
const firewall = createFirewall({ inference, log });
|
|
1661
|
+
// The guard's reading of words an agent hands the swarm, as a post's is read (goalCommands.mjs).
|
|
1662
|
+
const readByGuard = (text) =>
|
|
1663
|
+
localReady(["guard"])
|
|
1664
|
+
? firewall.inspect(text)
|
|
1665
|
+
: Promise.resolve({ score: null, verdict: "clean", unavailable: true });
|
|
1633
1666
|
if (localReady(["credentials"])) scrubber = firewall;
|
|
1634
1667
|
if (localReady(["search"])) contextEngine.start();
|
|
1635
1668
|
// An image leaving this computer readable through Harness (redact.mjs) has every key, private key, seed phrase,
|
package/lib/goalCommands.mjs
CHANGED
|
@@ -270,6 +270,11 @@ export function createGoalCommands({
|
|
|
270
270
|
}
|
|
271
271
|
const told = wakeFor(goal.id, post, agent, wakes, {
|
|
272
272
|
hosted: request.hostedCaller === true,
|
|
273
|
+
guard: verdict ?? {
|
|
274
|
+
score: null,
|
|
275
|
+
verdict: "clean",
|
|
276
|
+
unavailable: true,
|
|
277
|
+
},
|
|
273
278
|
});
|
|
274
279
|
notifyBoard(store.getTask(goal.id));
|
|
275
280
|
// An agent that asks a teammate who can only start once the asker's own turn ends hears so now, so it stops
|
package/lib/threadRuns.mjs
CHANGED
|
@@ -224,6 +224,7 @@ export function createThreadRuns({
|
|
|
224
224
|
pick = null,
|
|
225
225
|
words = null,
|
|
226
226
|
recovering = false,
|
|
227
|
+
held = null,
|
|
227
228
|
} = {}
|
|
228
229
|
) => {
|
|
229
230
|
const task = store.getTask(goalId);
|
|
@@ -248,12 +249,17 @@ export function createThreadRuns({
|
|
|
248
249
|
return;
|
|
249
250
|
}
|
|
250
251
|
if (store.openWake(goalId, agent)) {
|
|
252
|
+
const prior = pendingWakes.get(`${goalId}:${agent}`);
|
|
253
|
+
// Words the guard flagged keep the next turn waiting for the person, whatever go an earlier call carried; the
|
|
254
|
+
// person's own call is their go.
|
|
255
|
+
const flagged = asker === "user" ? null : (held ?? prior?.held ?? null);
|
|
251
256
|
const pending = {
|
|
252
257
|
id: randomUUID(),
|
|
253
258
|
reason,
|
|
254
259
|
asker,
|
|
255
|
-
go: go || Boolean(
|
|
256
|
-
|
|
260
|
+
go: asker === "user" ? go : !flagged && (go || Boolean(prior?.go)),
|
|
261
|
+
held: flagged,
|
|
262
|
+
pick: pick ?? prior?.pick ?? null,
|
|
257
263
|
at: new Date().toISOString(),
|
|
258
264
|
};
|
|
259
265
|
pendingWakes.set(`${goalId}:${agent}`, pending);
|
|
@@ -325,6 +331,8 @@ export function createThreadRuns({
|
|
|
325
331
|
store.meta(`person-wake:${wake.id}`, "1");
|
|
326
332
|
store.authorizeGoalRun(wake.id);
|
|
327
333
|
} else if (restrictable(agent, folder)) store.authorizeGoalRun(wake.id);
|
|
334
|
+
else if (held)
|
|
335
|
+
store.roomPost({ goalId, author: "harness", kind: "note", text: held });
|
|
328
336
|
else if (!store.meta(`restricted-note:${goalId}:${agent}`)) {
|
|
329
337
|
store.meta(`restricted-note:${goalId}:${agent}`, "1");
|
|
330
338
|
store.roomPost({
|
|
@@ -429,6 +437,7 @@ export function createThreadRuns({
|
|
|
429
437
|
go: pending.go,
|
|
430
438
|
asker: pending.asker,
|
|
431
439
|
pick: pending.pick,
|
|
440
|
+
held: pending.held ?? null,
|
|
432
441
|
});
|
|
433
442
|
// Keep the accepted call durable until its replacement wake exists.
|
|
434
443
|
if (next) pendingWakes.delete(key);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tryharness",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.36",
|
|
4
4
|
"description": "Harness Relay: the daemon that turns the agents on this machine into your personal swarm. Memory, history, and work handed between any of them.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tryharness": "cli.mjs"
|