tryharness 0.7.45 → 0.7.54
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 +239 -14
- package/assets/dsh-plugin.mjs +72 -0
- package/assets/opencode-plugin.js +4 -3
- package/cli.mjs +497 -196
- package/lib/actorRoster.mjs +28 -5
- package/lib/adapters.mjs +165 -222
- package/lib/agentRuntimeConfig.mjs +36 -0
- package/lib/agentRuntimes.mjs +570 -0
- package/lib/agentSignIn.mjs +226 -0
- package/lib/atlas.mjs +7 -2
- package/lib/audit.mjs +643 -0
- package/lib/backupSetup.mjs +141 -0
- package/lib/boardAccess.mjs +8 -1
- package/lib/boardBackup.mjs +283 -0
- package/lib/boardCommands.mjs +5 -10
- package/lib/boardFileCommands.mjs +2 -1
- package/lib/boardMirror.mjs +523 -0
- package/lib/boardProtocol.json +263 -6
- package/lib/boardTools.mjs +2 -6
- package/lib/boardWaits.mjs +102 -0
- package/lib/book.mjs +659 -0
- package/lib/bridge.mjs +26 -4
- package/lib/browserWake.mjs +60 -0
- package/lib/cards.mjs +159 -16
- package/lib/cloudBoot.mjs +124 -0
- package/lib/commands.mjs +25 -5
- package/lib/connectionTools.d.ts +13 -0
- package/lib/connectionTools.js +45 -0
- package/lib/connectorAuth.mjs +309 -0
- package/lib/connectorCatalog.json +41 -0
- package/lib/connectorCommands.mjs +121 -0
- package/lib/connectorGoogle.mjs +513 -0
- package/lib/connectors.mjs +805 -0
- package/lib/context.mjs +18 -4
- package/lib/contractGate.mjs +377 -0
- package/lib/coordinator.mjs +152 -39
- package/lib/coreModels.mjs +78 -0
- package/lib/daemon.mjs +973 -54
- package/lib/desk.mjs +239 -0
- package/lib/desktop.mjs +113 -8
- package/lib/digest.mjs +32 -0
- package/lib/directLink.mjs +283 -0
- package/lib/environments.mjs +825 -0
- package/lib/folders.mjs +4 -4
- package/lib/gitHost.mjs +174 -0
- package/lib/goalCommands.mjs +58 -14
- package/lib/hookDialects.mjs +298 -0
- package/lib/inference.mjs +263 -152
- package/lib/landed.mjs +887 -0
- package/lib/lessons.mjs +6 -0
- package/lib/lineup.mjs +324 -0
- package/lib/live.mjs +284 -13
- package/lib/localmodels.mjs +10 -0
- package/lib/machineIdentity.mjs +3 -0
- package/lib/machineRoutes.mjs +40 -2
- package/lib/machineRuns.mjs +30 -3
- package/lib/machineSeal.mjs +69 -10
- package/lib/mcp-stdio.mjs +189 -120
- package/lib/mcpRelay.mjs +119 -0
- package/lib/members.json +26 -0
- package/lib/members.mjs +33 -0
- package/lib/modelMemory.mjs +100 -0
- package/lib/models.mjs +48 -15
- package/lib/museSession.mjs +122 -0
- package/lib/nativeHost.mjs +203 -0
- package/lib/neovim.mjs +126 -0
- package/lib/network.mjs +7 -2
- package/lib/nudge.mjs +57 -18
- package/lib/onboard.mjs +430 -1
- package/lib/oneclawLocal.mjs +150 -0
- package/lib/ownMachines.mjs +828 -39
- package/lib/pairing.mjs +182 -0
- package/lib/paths.mjs +8 -0
- package/lib/personModel.mjs +89 -0
- package/lib/phones.mjs +119 -3
- package/lib/placeCommands.mjs +27 -0
- package/lib/places.mjs +337 -9
- package/lib/plans.mjs +151 -27
- package/lib/profile.mjs +152 -0
- package/lib/projects.mjs +624 -137
- package/lib/readiness.mjs +400 -0
- package/lib/record.mjs +115 -0
- package/lib/repoLinks.mjs +354 -0
- package/lib/roomChannels.mjs +641 -0
- package/lib/runBrief.mjs +32 -2
- package/lib/runRequests.mjs +157 -0
- package/lib/runWorker.mjs +37 -9
- package/lib/runner.mjs +74 -11
- package/lib/secretPatterns.json +55 -0
- package/lib/secrets.mjs +10 -27
- package/lib/seen.mjs +102 -0
- package/lib/service.mjs +11 -6
- package/lib/sessionControl.mjs +386 -96
- package/lib/sessionIndex.mjs +5 -3
- package/lib/specialties.json +74 -0
- package/lib/specialties.mjs +477 -0
- package/lib/specialtyKeys.d.ts +3 -0
- package/lib/specialtyKeys.js +58 -0
- package/lib/specialtyNotice.mjs +147 -0
- package/lib/specialtySnapshot.mjs +138 -0
- package/lib/store.mjs +829 -29
- package/lib/subagents.mjs +8 -4
- package/lib/swarm.mjs +483 -37
- package/lib/swarmMemory.mjs +947 -0
- package/lib/t3.mjs +56 -17
- package/lib/taskCommands.mjs +91 -13
- package/lib/taskRuns.mjs +68 -11
- package/lib/team.json +253 -144
- package/lib/team.mjs +538 -147
- package/lib/threadLine.mjs +116 -0
- package/lib/threadRuns.mjs +78 -12
- package/lib/threadView.mjs +66 -16
- package/lib/tokenizer.mjs +405 -0
- package/lib/ui.mjs +16 -2
- package/lib/usageTotals.mjs +148 -0
- package/lib/vault.mjs +1144 -0
- package/lib/vaultCloud.mjs +117 -0
- package/lib/vaultCommands.mjs +201 -0
- package/lib/vaultTools.d.ts +12 -0
- package/lib/vaultTools.js +42 -0
- package/lib/windowAsks.mjs +42 -0
- package/lib/workFocus.mjs +59 -0
- package/lib/workLinks.mjs +90 -0
- package/lib/worktrees.mjs +51 -13
- package/package.json +10 -5
package/lib/neovim.mjs
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
import { hostApp, processTable, tmuxPlace } from "./live.mjs";
|
|
6
|
+
|
|
7
|
+
// A session in a Neovim terminal (:terminal), opened inside that Neovim. Neovim gives everything it runs in a terminal
|
|
8
|
+
// its own server's address ($NVIM), and answers there: any nvim can send it an expression (nvim --server <address>
|
|
9
|
+
// --remote-expr), which is how the session's terminal buffer is brought up, or a session resumed in a new tab. Neovim
|
|
10
|
+
// itself runs in a terminal app, whose tab (or tmux, WezTerm or kitty pane) then comes forward like any other's.
|
|
11
|
+
|
|
12
|
+
/** An nvim to speak to a server with: one running now (the daemon's PATH may not have it), else a usual install. */
|
|
13
|
+
function nvimBinary(table) {
|
|
14
|
+
const running = [...table.values()]
|
|
15
|
+
.map((row) => row.comm)
|
|
16
|
+
.filter((comm) => path.isAbsolute(comm) && path.basename(comm) === "nvim");
|
|
17
|
+
const usual = [
|
|
18
|
+
...(process.env.PATH || "").split(path.delimiter),
|
|
19
|
+
"/opt/homebrew/bin",
|
|
20
|
+
"/usr/local/bin",
|
|
21
|
+
"/usr/bin",
|
|
22
|
+
"/snap/bin",
|
|
23
|
+
path.join(os.homedir(), ".local", "bin"),
|
|
24
|
+
path.join(os.homedir(), "bin"),
|
|
25
|
+
]
|
|
26
|
+
.filter(Boolean)
|
|
27
|
+
.map((dir) => path.join(dir, "nvim"));
|
|
28
|
+
return [...running, ...usual].find((file) => fs.existsSync(file)) ?? null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Runs a Lua chunk in the Neovim at `server`, with `data` as its argument; its answer as text, or null when no Neovim
|
|
33
|
+
* answers there. The chunk and data travel as one JSON value, which Vim script reads as its own list.
|
|
34
|
+
*/
|
|
35
|
+
function inNeovim(server, code, data, table) {
|
|
36
|
+
if (typeof server !== "string" || !server) return null;
|
|
37
|
+
// A socket that is gone means a Neovim that closed: no nvim started to find that out.
|
|
38
|
+
if (path.isAbsolute(server) && !fs.existsSync(server)) return null;
|
|
39
|
+
const nvim = nvimBinary(table);
|
|
40
|
+
if (!nvim) return null;
|
|
41
|
+
const expr = `luaeval('(loadstring or load)(_A[1])(_A[2])', ${JSON.stringify([code, data])})`;
|
|
42
|
+
const ran = spawnSync(nvim, ["--server", server, "--remote-expr", expr], {
|
|
43
|
+
encoding: "utf8",
|
|
44
|
+
timeout: 3_000,
|
|
45
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
46
|
+
});
|
|
47
|
+
return ran.status === 0 ? ran.stdout.trim() : null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The terminal Neovim shows in, from its server's process: the first process up from it on a terminal device (Neovim's
|
|
52
|
+
* own interface, since 0.10 a process of its own), with the app around it, or tmux's client for a Neovim in tmux.
|
|
53
|
+
*/
|
|
54
|
+
function terminalOf(serverPid, table) {
|
|
55
|
+
for (let pid = serverPid, steps = 0; pid > 1 && steps < 8; steps++) {
|
|
56
|
+
const row = table.get(pid);
|
|
57
|
+
if (!row) return null;
|
|
58
|
+
if (row.tty)
|
|
59
|
+
return {
|
|
60
|
+
pid,
|
|
61
|
+
tty: row.tty,
|
|
62
|
+
host:
|
|
63
|
+
hostApp(table, pid) ??
|
|
64
|
+
tmuxPlace(table, row.tty)?.client?.host ??
|
|
65
|
+
null,
|
|
66
|
+
};
|
|
67
|
+
pid = row.ppid;
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// The terminal buffer whose job is the session's process or one it runs under (a shell started with :terminal), shown
|
|
73
|
+
// in its window, else in a new tab, ready to type in.
|
|
74
|
+
const SHOW = `
|
|
75
|
+
local pids = ...
|
|
76
|
+
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
|
77
|
+
local job = vim.bo[buf].buftype == "terminal" and vim.b[buf].terminal_job_pid
|
|
78
|
+
if job and pids[tostring(job)] then
|
|
79
|
+
local win = vim.fn.win_findbuf(buf)[1]
|
|
80
|
+
if win then vim.fn.win_gotoid(win) else vim.cmd("tab sbuffer " .. buf) end
|
|
81
|
+
vim.cmd.startinsert()
|
|
82
|
+
return vim.fn.getpid()
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
return 0`;
|
|
86
|
+
|
|
87
|
+
// A new tab on the folder, with the command in a terminal there, run by the person's own shell.
|
|
88
|
+
const RESUME = `
|
|
89
|
+
local command, cwd = (...)[1], (...)[2]
|
|
90
|
+
vim.cmd.tabnew()
|
|
91
|
+
if cwd ~= "" then vim.cmd.tcd(vim.fn.fnameescape(cwd)) end
|
|
92
|
+
if vim.fn.has("nvim-0.11") == 1 then vim.fn.jobstart(command, { term = true }) else vim.fn.termopen(command) end
|
|
93
|
+
vim.cmd.startinsert()
|
|
94
|
+
return vim.fn.getpid()`;
|
|
95
|
+
|
|
96
|
+
const shownAt = (answer, table) => {
|
|
97
|
+
const pid = Number(answer);
|
|
98
|
+
return Number.isInteger(pid) && pid > 1 ? terminalOf(pid, table) : null;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Brings up the terminal buffer a running session is in, in the Neovim at `server`: the terminal Neovim runs in
|
|
103
|
+
* ({ pid, tty, host }, to come forward as any terminal does), or null when that Neovim does not answer or has no such
|
|
104
|
+
* buffer.
|
|
105
|
+
*/
|
|
106
|
+
export function showInNeovim(server, sessionPid, table = processTable()) {
|
|
107
|
+
const pids = {};
|
|
108
|
+
for (let pid = sessionPid, steps = 0; pid > 1 && steps < 16; steps++) {
|
|
109
|
+
pids[String(pid)] = 1;
|
|
110
|
+
pid = table.get(pid)?.ppid ?? 0;
|
|
111
|
+
}
|
|
112
|
+
return shownAt(inNeovim(server, SHOW, pids, table), table);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Runs `command` (a session's resume) in a new terminal tab of the Neovim at `server`; as showInNeovim. */
|
|
116
|
+
export function resumeInNeovim(
|
|
117
|
+
server,
|
|
118
|
+
command,
|
|
119
|
+
folder,
|
|
120
|
+
table = processTable()
|
|
121
|
+
) {
|
|
122
|
+
return shownAt(
|
|
123
|
+
inNeovim(server, RESUME, [command, folder ?? ""], table),
|
|
124
|
+
table
|
|
125
|
+
);
|
|
126
|
+
}
|
package/lib/network.mjs
CHANGED
|
@@ -67,9 +67,14 @@ export function createNetwork({
|
|
|
67
67
|
thread.role === "target" &&
|
|
68
68
|
thread.status === "requested"
|
|
69
69
|
)
|
|
70
|
-
invited.push({
|
|
70
|
+
invited.push({
|
|
71
|
+
id: thread.id,
|
|
72
|
+
project,
|
|
73
|
+
sender: peer.handle,
|
|
74
|
+
fingerprint: keyPrint,
|
|
75
|
+
});
|
|
71
76
|
if (thread.role === "asker")
|
|
72
|
-
sent.push({ id: thread.id, status: thread.status });
|
|
77
|
+
sent.push({ id: thread.id, status: thread.status, project });
|
|
73
78
|
continue;
|
|
74
79
|
}
|
|
75
80
|
items.push(
|
package/lib/nudge.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { placeEnv } from "./places.mjs";
|
|
|
8
8
|
import { fitSections } from "./fit.mjs";
|
|
9
9
|
import { oneLine } from "./oneLine.mjs";
|
|
10
10
|
import { SWARM_HEADER } from "./cards.mjs";
|
|
11
|
+
import { hookDialect, hookInput } from "./hookDialects.mjs";
|
|
11
12
|
|
|
12
13
|
// The session-start nudge: what an interactive agent is told when a session opens, so work
|
|
13
14
|
// waiting on the board is not silent until someone asks. Claude Code runs this as a
|
|
@@ -89,8 +90,9 @@ const shorterLists = (render, count, from) =>
|
|
|
89
90
|
);
|
|
90
91
|
|
|
91
92
|
// The session start as sections (fit.mjs): the queue first and always; the goal rooms, newest first, down to a count
|
|
92
|
-
// and list_tasks;
|
|
93
|
-
//
|
|
93
|
+
// and list_tasks; who this agent is and the computer it runs on, always; the swarm's cards whole, then short, then
|
|
94
|
+
// list_agents; what the person told the swarm, then list_agents. `swarm` is the daemon's block
|
|
95
|
+
// ({ text, cards, short, told, you }), or its text alone from an older daemon.
|
|
94
96
|
function sessionSections(agent, tasks, unread, goals, swarm) {
|
|
95
97
|
const queue = {
|
|
96
98
|
waiting: (tasks || []).filter(
|
|
@@ -143,6 +145,13 @@ function sessionSections(agent, tasks, unread, goals, swarm) {
|
|
|
143
145
|
},
|
|
144
146
|
]
|
|
145
147
|
: [];
|
|
148
|
+
if (swarm?.you)
|
|
149
|
+
sections.push({
|
|
150
|
+
name: "you",
|
|
151
|
+
priority: "core",
|
|
152
|
+
source: "board",
|
|
153
|
+
text: swarm.you,
|
|
154
|
+
});
|
|
146
155
|
if (typeof swarm === "string")
|
|
147
156
|
return [
|
|
148
157
|
...sections,
|
|
@@ -319,11 +328,37 @@ export async function boardNudgeIfChanged(agent, homeDir = paths.home) {
|
|
|
319
328
|
).text;
|
|
320
329
|
}
|
|
321
330
|
|
|
331
|
+
// Other agents read Claude Code's own config files: Devin CLI, Grok Build, Cursor, Cortex Code and Continue's cn run the
|
|
332
|
+
// hooks in ~/.claude/settings.json, and Devin, Cortex Code and Warp start the MCP servers in ~/.claude.json (their
|
|
333
|
+
// docs, October 23, 2026). The entries setup writes there would run inside them under Claude Code's name, so they carry
|
|
334
|
+
// --check-host and stand down unless Claude Code started them: Claude Code 2.1.309 sets CLAUDECODE=1 for every process
|
|
335
|
+
// it starts (hooks, MCP servers, shells). Grok Build likewise runs Cursor's hooks and starts the servers in Cursor's
|
|
336
|
+
// config: it marks every hook it runs (GROK_HOOK_EVENT), and a server it starts is its child. Harness's own runs name
|
|
337
|
+
// the agent they start and are not checked.
|
|
338
|
+
export const startedByAnother = (
|
|
339
|
+
agent,
|
|
340
|
+
env = process.env,
|
|
341
|
+
parent = () => processName(process.ppid)
|
|
342
|
+
) => {
|
|
343
|
+
if (agent === "claude-code") return env.CLAUDECODE !== "1";
|
|
344
|
+
if (agent === "cursor")
|
|
345
|
+
return Boolean(env.GROK_HOOK_EVENT) || parent() === "grok";
|
|
346
|
+
return false;
|
|
347
|
+
};
|
|
348
|
+
|
|
322
349
|
// The prompt hook also tells the daemon the person typed in this session: the agent process is the hook's parent, or
|
|
323
350
|
// its grandparent when the hook runs through a shell.
|
|
324
351
|
export const PS =
|
|
325
352
|
["/bin/ps", "/usr/bin/ps"].find((file) => fs.existsSync(file)) || "ps";
|
|
326
353
|
|
|
354
|
+
function processName(pid) {
|
|
355
|
+
return path.basename(
|
|
356
|
+
spawnSync(PS, ["-o", "comm=", "-p", String(pid)], {
|
|
357
|
+
encoding: "utf8",
|
|
358
|
+
}).stdout?.trim() ?? ""
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
327
362
|
function agentPids() {
|
|
328
363
|
const pids = [process.ppid];
|
|
329
364
|
try {
|
|
@@ -417,8 +452,8 @@ export function messagesText(messages) {
|
|
|
417
452
|
.join("\n\n");
|
|
418
453
|
}
|
|
419
454
|
|
|
420
|
-
// The JSON the agent hands every hook on stdin (
|
|
421
|
-
async function
|
|
455
|
+
// The JSON the agent hands every hook on stdin, in its own words (hookDialects.mjs hookInput); null when there is none.
|
|
456
|
+
async function readHookInput() {
|
|
422
457
|
if (process.stdin.isTTY) return null;
|
|
423
458
|
let text = "";
|
|
424
459
|
process.stdin.setEncoding("utf8");
|
|
@@ -435,7 +470,7 @@ async function hookInput() {
|
|
|
435
470
|
]);
|
|
436
471
|
process.stdin.destroy();
|
|
437
472
|
try {
|
|
438
|
-
return JSON.parse(text);
|
|
473
|
+
return hookInput(JSON.parse(text));
|
|
439
474
|
} catch {
|
|
440
475
|
return null;
|
|
441
476
|
}
|
|
@@ -444,34 +479,38 @@ async function hookInput() {
|
|
|
444
479
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
445
480
|
const index = process.argv.indexOf("--agent");
|
|
446
481
|
const agent = index >= 0 ? process.argv[index + 1] : "claude-code";
|
|
447
|
-
|
|
482
|
+
if (process.argv.includes("--check-host") && startedByAnother(agent))
|
|
483
|
+
process.exit(0);
|
|
484
|
+
const dialect = hookDialect(agent);
|
|
485
|
+
const input = await readHookInput();
|
|
448
486
|
const sessionId = input?.session_id;
|
|
487
|
+
const prompted = process.argv.includes("--if-changed");
|
|
449
488
|
if (process.argv.includes("--stop")) {
|
|
489
|
+
// A stop that is not a turn ending (Grok's as a session closes) cannot keep anything going: a message taken then
|
|
490
|
+
// would be lost.
|
|
491
|
+
if (input && !input.endsTurn) process.exit(0);
|
|
450
492
|
// The Stop hook: a message waiting for this session keeps the agent going with it.
|
|
451
493
|
const messages = await takeMessages(agent, sessionId);
|
|
452
494
|
if (messages.length)
|
|
453
|
-
process.stdout.write(
|
|
454
|
-
JSON.stringify({ decision: "block", reason: messagesText(messages) }) +
|
|
455
|
-
"\n"
|
|
456
|
-
);
|
|
495
|
+
process.stdout.write(dialect.block(messagesText(messages)) + "\n");
|
|
457
496
|
else await noteTurn(agent, input);
|
|
458
497
|
} else {
|
|
459
|
-
if (
|
|
498
|
+
if (prompted) await notePrompt(agent, input);
|
|
460
499
|
else await notePlace(agent, input);
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
:
|
|
500
|
+
// An agent that does not read what this hook prints: nothing is taken or marked as told.
|
|
501
|
+
const speak =
|
|
502
|
+
dialect.context[prompted ? "UserPromptSubmit" : "SessionStart"];
|
|
503
|
+
if (!speak) process.exit(0);
|
|
504
|
+
const messages = prompted ? await takeMessages(agent, sessionId) : [];
|
|
464
505
|
const compacted =
|
|
465
506
|
input?.source === "compact" ? await compactionNote(agent, sessionId) : "";
|
|
466
507
|
const text = [
|
|
467
508
|
compacted,
|
|
468
509
|
messages.length ? messagesText(messages) : "",
|
|
469
|
-
|
|
470
|
-
? await boardNudgeIfChanged(agent)
|
|
471
|
-
: await boardNudge(agent),
|
|
510
|
+
prompted ? await boardNudgeIfChanged(agent) : await boardNudge(agent),
|
|
472
511
|
]
|
|
473
512
|
.filter(Boolean)
|
|
474
513
|
.join("\n\n");
|
|
475
|
-
if (text) process.stdout.write(text + "\n");
|
|
514
|
+
if (text) process.stdout.write(speak(text) + "\n");
|
|
476
515
|
}
|
|
477
516
|
}
|