tryharness 0.7.54 → 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 +15 -16
- package/cli.mjs +377 -62
- package/lib/activity.mjs +10 -10
- package/lib/adapters.mjs +16 -0
- package/lib/agentBinaries.mjs +71 -0
- package/lib/agentRuntimeConfig.mjs +1 -1
- package/lib/agentRuntimes.mjs +9 -3
- package/lib/agentSignIn.mjs +271 -41
- 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 +36 -13
- package/lib/backupSetup.mjs +4 -2
- package/lib/boardAccess.mjs +17 -11
- package/lib/boardBackup.mjs +6 -6
- package/lib/boardFileCommands.mjs +6 -6
- package/lib/boardFiles.mjs +13 -12
- package/lib/boardMirror.mjs +82 -47
- package/lib/boardProtocol.json +30 -1
- package/lib/boardWaits.mjs +2 -3
- package/lib/book.mjs +6 -6
- package/lib/bridge.mjs +5 -5
- package/lib/cards.mjs +2 -2
- package/lib/cloudAgents.mjs +216 -0
- package/lib/cloudAi.mjs +1312 -0
- package/lib/cloudAssistants.mjs +242 -0
- package/lib/cloudBoot.mjs +81 -86
- package/lib/cloudSave.mjs +197 -0
- package/lib/cloudSsh.mjs +178 -0
- package/lib/context.mjs +3 -3
- package/lib/contractGate.mjs +34 -12
- package/lib/control-client.mjs +9 -1
- package/lib/controlSocket.mjs +86 -0
- package/lib/coordinator.mjs +103 -101
- package/lib/daemon.mjs +1128 -2865
- package/lib/desk.mjs +7 -6
- package/lib/desktop.mjs +72 -68
- package/lib/directLink.mjs +16 -5
- package/lib/environment.mjs +2 -1
- package/lib/environments.mjs +14 -6
- package/lib/firewall.mjs +9 -9
- package/lib/folders.mjs +18 -14
- package/lib/frames.mjs +2 -3
- package/lib/gitHost.mjs +3 -3
- 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/inference.mjs +26 -8
- package/lib/jobAnswers.mjs +190 -0
- package/lib/landed.mjs +1 -1
- 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/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 +96 -26
- package/lib/mcpRelay.mjs +1 -1
- package/lib/members.json +13 -0
- package/lib/members.mjs +1 -1
- package/lib/models.mjs +77 -23
- package/lib/museSession.mjs +6 -1
- package/lib/nativeHost.mjs +35 -7
- package/lib/network.mjs +50 -5
- package/lib/notify.mjs +7 -5
- package/lib/nudge.mjs +3 -3
- package/lib/ocr.mjs +9 -9
- package/lib/onboard.mjs +26 -20
- package/lib/oneLine.mjs +7 -7
- package/lib/ownMachines.mjs +928 -149
- package/lib/pairing.mjs +33 -6
- package/lib/paths.mjs +15 -1
- package/lib/peerProcess.mjs +124 -0
- package/lib/personModel.mjs +3 -3
- package/lib/personNotices.mjs +151 -0
- package/lib/phones.mjs +490 -38
- package/lib/placeCommands.mjs +4 -4
- package/lib/places.mjs +70 -2
- 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 +12 -7
- package/lib/record.mjs +19 -6
- 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 +14 -5
- package/lib/runner.mjs +215 -25
- 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 +6 -6
- package/lib/specialties.mjs +6 -6
- package/lib/specialtyKeys.js +4 -5
- package/lib/specialtyNotice.mjs +7 -7
- package/lib/specialtySnapshot.mjs +5 -5
- package/lib/speech.mjs +5 -5
- package/lib/store.mjs +140 -39
- package/lib/stuck.mjs +1 -1
- package/lib/swarm.mjs +167 -16
- package/lib/swarmDevices.mjs +319 -0
- package/lib/swarmMemory.mjs +27 -25
- package/lib/t3.mjs +13 -13
- package/lib/taskCommands.mjs +44 -11
- package/lib/taskRooms.mjs +125 -0
- package/lib/taskRuns.mjs +36 -1
- package/lib/team.mjs +41 -18
- package/lib/threadActions.mjs +315 -0
- package/lib/threadAuthority.mjs +101 -0
- package/lib/threadBriefs.mjs +178 -0
- package/lib/threadLine.mjs +2 -2
- package/lib/threadRuns.mjs +138 -43
- package/lib/threadView.mjs +5 -5
- 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 +112 -18
- package/npm-shrinkwrap.json +1093 -0
- package/package.json +11 -10
- package/release.json +220 -0
package/lib/windowAsks.mjs
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
// This computer asking the person's own Harness window for what only it holds (phones.mjs ask): this computer's own
|
|
2
2
|
// windows first, then those linked to each of the person's other computers (ownMachines.mjs). With no Harness window
|
|
3
3
|
// open, the browser that listens for this computer (browserWake.mjs, the extension's native host) is woken: the
|
|
4
|
-
// extension brings up its hidden Harness page, which answers like a tab (
|
|
5
|
-
//
|
|
4
|
+
// extension brings up its hidden Harness page, which answers like a tab (the swarm reads what the person has seen from
|
|
5
|
+
// the hidden page). It is asked again as it comes up, until WAKE_DEADLINE_MS.
|
|
6
6
|
|
|
7
|
-
// How long to keep asking a woken hidden page:
|
|
8
|
-
//
|
|
9
|
-
//
|
|
7
|
+
// How long to keep asking a woken hidden page: one minute, a chosen value. Measured only against a local app on
|
|
8
|
+
// loopback (an end-to-end test: closed page to answer 1.04 to 1.08 s, 5 samples on an M5 Pro), never against
|
|
9
|
+
// tryharness.ai.
|
|
10
10
|
export const WAKE_DEADLINE_MS = 60_000;
|
|
11
|
+
// What home may ask the windows linked to a worker (ownMachines.mjs): the person's screen history, as its agents' tools
|
|
12
|
+
// ask it (boardTools.mjs search_screen, seen.mjs). A worker refuses any other tool home names (security audit
|
|
13
|
+
// 2026-10-25, M6).
|
|
14
|
+
export const WINDOW_TOOLS = new Set([
|
|
15
|
+
"search_screen_text",
|
|
16
|
+
"search_screen_semantic",
|
|
17
|
+
"screen_seen_since",
|
|
18
|
+
]);
|
|
11
19
|
const ASK_EVERY_MS = 1_000;
|
|
12
20
|
|
|
13
21
|
export function createWindowAsks({
|
package/lib/worktrees.mjs
CHANGED
|
@@ -14,9 +14,10 @@ const IDENTITY = [
|
|
|
14
14
|
];
|
|
15
15
|
const PATCH_LIMIT = 200_000;
|
|
16
16
|
|
|
17
|
-
function git(cwd, args) {
|
|
17
|
+
function git(cwd, args, env = process.env) {
|
|
18
18
|
const result = spawnSync("git", [...IDENTITY, ...args], {
|
|
19
19
|
cwd,
|
|
20
|
+
env,
|
|
20
21
|
encoding: "utf8",
|
|
21
22
|
maxBuffer: 16 * 1024 * 1024,
|
|
22
23
|
});
|
|
@@ -27,6 +28,49 @@ function git(cwd, args) {
|
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
// A thread's copy is where an agent's run writes, a restricted one included, so nothing in it decides what git runs
|
|
32
|
+
// when the daemon commits there: the repository is the one the daemon recorded (GIT_DIR), never the copy's own .git
|
|
33
|
+
// file, and no hook or file monitor runs. A copy whose .git file no longer points where the daemon made it is not
|
|
34
|
+
// touched at all (changedGit).
|
|
35
|
+
const NO_HOOKS = [
|
|
36
|
+
"-c",
|
|
37
|
+
"core.hooksPath=/dev/null",
|
|
38
|
+
"-c",
|
|
39
|
+
"core.fsmonitor=false",
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
// git writes every path it records resolved through symlinks (macOS's /var is /private/var), so a path the daemon
|
|
43
|
+
// holds is compared the same way.
|
|
44
|
+
const sameFile = (a, b) => {
|
|
45
|
+
const real = (file) => {
|
|
46
|
+
try {
|
|
47
|
+
return fs.realpathSync(file);
|
|
48
|
+
} catch {
|
|
49
|
+
return path.resolve(file);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return real(a) === real(b);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** The worktree's own folder in its repository's .git, found from the repository the person's checkout uses. */
|
|
56
|
+
function adminDirOf(repo, where) {
|
|
57
|
+
const common = git(repo, [
|
|
58
|
+
"rev-parse",
|
|
59
|
+
"--path-format=absolute",
|
|
60
|
+
"--git-common-dir",
|
|
61
|
+
]).out;
|
|
62
|
+
const admin = path.join(common, "worktrees");
|
|
63
|
+
const target = path.resolve(where, ".git");
|
|
64
|
+
for (const name of fs.existsSync(admin) ? fs.readdirSync(admin) : []) {
|
|
65
|
+
const pointer = path.join(admin, name, "gitdir");
|
|
66
|
+
try {
|
|
67
|
+
if (sameFile(fs.readFileSync(pointer, "utf8").trim(), target))
|
|
68
|
+
return path.join(admin, name);
|
|
69
|
+
} catch {}
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
30
74
|
/** The repository a folder is in, and the folder's place inside it; null when it is not in one. */
|
|
31
75
|
export function repositoryOf(folder) {
|
|
32
76
|
if (!folder || !fs.existsSync(folder)) return null;
|
|
@@ -84,6 +128,33 @@ export function createWorktrees({ store, root }) {
|
|
|
84
128
|
const save = (threadId, value) =>
|
|
85
129
|
store.meta(key(threadId), value ? JSON.stringify(value) : "null");
|
|
86
130
|
|
|
131
|
+
// The copy's repository as the daemon made it; a record from before it was kept is found from the person's checkout.
|
|
132
|
+
const gitDirOf = (tree) => tree.gitDir ?? adminDirOf(tree.repo, tree.path);
|
|
133
|
+
/** Why the daemon will not run git in a thread's copy, or null: its .git no longer points where the daemon made it. */
|
|
134
|
+
const changedGit = (tree) => {
|
|
135
|
+
const gitDir = gitDirOf(tree);
|
|
136
|
+
if (!gitDir)
|
|
137
|
+
return "Harness cannot find the repository it made this copy in";
|
|
138
|
+
let pointer = "";
|
|
139
|
+
try {
|
|
140
|
+
pointer = fs.readFileSync(path.join(tree.path, ".git"), "utf8").trim();
|
|
141
|
+
} catch {}
|
|
142
|
+
const named = /^gitdir: (.+)$/.exec(pointer)?.[1];
|
|
143
|
+
return named && sameFile(path.resolve(tree.path, named), gitDir)
|
|
144
|
+
? null
|
|
145
|
+
: "something in the thread's copy replaced its .git";
|
|
146
|
+
};
|
|
147
|
+
/** git in a thread's copy, on the repository the daemon recorded, with no hooks and no file monitor. */
|
|
148
|
+
const inTree = (tree, args) => {
|
|
149
|
+
if (changedGit(tree)) return { ok: false, out: "", err: changedGit(tree) };
|
|
150
|
+
const env = {
|
|
151
|
+
...process.env,
|
|
152
|
+
GIT_DIR: gitDirOf(tree),
|
|
153
|
+
GIT_WORK_TREE: tree.path,
|
|
154
|
+
};
|
|
155
|
+
return git(tree.path, [...NO_HOOKS, ...args], env);
|
|
156
|
+
};
|
|
157
|
+
|
|
87
158
|
/** Where a thread's coding runs work: its worktree when the folder is in a repository, else the folder itself. */
|
|
88
159
|
const folderFor = (thread) => {
|
|
89
160
|
const folder = thread.goal.workspace;
|
|
@@ -121,6 +192,7 @@ export function createWorktrees({ store, root }) {
|
|
|
121
192
|
path: where,
|
|
122
193
|
branch,
|
|
123
194
|
base,
|
|
195
|
+
gitDir: adminDirOf(repo.root, where),
|
|
124
196
|
});
|
|
125
197
|
return path.join(where, repo.inside);
|
|
126
198
|
};
|
|
@@ -134,7 +206,7 @@ export function createWorktrees({ store, root }) {
|
|
|
134
206
|
const startTurn = (threadId, runId) => {
|
|
135
207
|
const tree = openTree(threadId);
|
|
136
208
|
if (!tree) return;
|
|
137
|
-
store.meta(`turn-from:${runId}`,
|
|
209
|
+
store.meta(`turn-from:${runId}`, inTree(tree, ["rev-parse", "HEAD"]).out);
|
|
138
210
|
};
|
|
139
211
|
|
|
140
212
|
/**
|
|
@@ -144,13 +216,19 @@ export function createWorktrees({ store, root }) {
|
|
|
144
216
|
*/
|
|
145
217
|
const commitTurn = (threadId, runId, message) => {
|
|
146
218
|
const tree = openTree(threadId);
|
|
147
|
-
if (!tree) return null;
|
|
148
|
-
|
|
149
|
-
const staged = !
|
|
219
|
+
if (!tree || changedGit(tree)) return null;
|
|
220
|
+
inTree(tree, ["add", "-A"]);
|
|
221
|
+
const staged = !inTree(tree, ["diff", "--cached", "--quiet"]).ok;
|
|
150
222
|
const committed =
|
|
151
223
|
staged &&
|
|
152
|
-
|
|
153
|
-
|
|
224
|
+
inTree(tree, [
|
|
225
|
+
"commit",
|
|
226
|
+
"-q",
|
|
227
|
+
"--no-verify",
|
|
228
|
+
"-m",
|
|
229
|
+
String(message).slice(0, 200),
|
|
230
|
+
]).ok;
|
|
231
|
+
const sha = inTree(tree, ["rev-parse", "HEAD"]).out;
|
|
154
232
|
// A turn from before turns recorded their start counts only the commit made here.
|
|
155
233
|
const from = store.meta(`turn-from:${runId}`);
|
|
156
234
|
const moved = from ? sha !== from : committed;
|
|
@@ -163,15 +241,17 @@ export function createWorktrees({ store, root }) {
|
|
|
163
241
|
const uncommitted = (threadId) => {
|
|
164
242
|
const tree = openTree(threadId);
|
|
165
243
|
if (!tree) return [];
|
|
166
|
-
const lines = (args) =>
|
|
167
|
-
git(tree.path, args).out.split("\n").filter(Boolean);
|
|
244
|
+
const lines = (args) => inTree(tree, args).out.split("\n").filter(Boolean);
|
|
168
245
|
const changed = lines(["diff", "--name-only", "HEAD"]);
|
|
169
246
|
const added = lines(["ls-files", "--others", "--exclude-standard"]);
|
|
170
247
|
return [...new Set([...changed, ...added])];
|
|
171
248
|
};
|
|
172
249
|
|
|
173
|
-
|
|
174
|
-
|
|
250
|
+
// `where`: a thread's copy (its record) or the person's checkout (a folder).
|
|
251
|
+
const run = (where, args) =>
|
|
252
|
+
typeof where === "string" ? git(where, args) : inTree(where, args);
|
|
253
|
+
const stat = (where, range) => {
|
|
254
|
+
const out = run(where, ["diff", "--numstat", range]).out;
|
|
175
255
|
const files = out
|
|
176
256
|
? out.split("\n").map((line) => {
|
|
177
257
|
const [added, removed, file] = line.split("\t");
|
|
@@ -190,7 +270,7 @@ export function createWorktrees({ store, root }) {
|
|
|
190
270
|
const tree = get(threadId);
|
|
191
271
|
if (!tree)
|
|
192
272
|
return { ok: false, error: "this thread has no copy of a repository" };
|
|
193
|
-
const cwd = fs.existsSync(tree.path) ? tree
|
|
273
|
+
const cwd = fs.existsSync(tree.path) ? tree : tree.repo;
|
|
194
274
|
let range;
|
|
195
275
|
if (runId) {
|
|
196
276
|
const sha = store.meta(`turn:${runId}`);
|
|
@@ -199,7 +279,7 @@ export function createWorktrees({ store, root }) {
|
|
|
199
279
|
range = from ? `${from}..${sha}` : `${sha}~1..${sha}`;
|
|
200
280
|
} else
|
|
201
281
|
range = `${tree.base}..${tree.state === "open" ? "HEAD" : tree.branch}`;
|
|
202
|
-
const patch =
|
|
282
|
+
const patch = run(cwd, ["diff", range]).out;
|
|
203
283
|
return {
|
|
204
284
|
ok: true,
|
|
205
285
|
files: stat(cwd, range),
|
|
@@ -218,13 +298,17 @@ export function createWorktrees({ store, root }) {
|
|
|
218
298
|
if (!tree || tree.state === "in_place" || tree.state === "t3") return null;
|
|
219
299
|
const files =
|
|
220
300
|
tree.state === "open" && fs.existsSync(tree.path)
|
|
221
|
-
? stat(tree
|
|
301
|
+
? stat(tree, `${tree.base}..HEAD`).length
|
|
222
302
|
: 0;
|
|
223
303
|
return { state: tree.state, branch: tree.branch, repo: tree.repo, files };
|
|
224
304
|
};
|
|
225
305
|
|
|
226
306
|
const retire = (tree) => {
|
|
227
|
-
git
|
|
307
|
+
// A copy whose .git was replaced is not one git will remove; it is the daemon's own folder, so it goes as files.
|
|
308
|
+
const ours = path.relative(root, tree.path);
|
|
309
|
+
if (changedGit(tree) && ours && !ours.startsWith(".."))
|
|
310
|
+
fs.rmSync(tree.path, { recursive: true, force: true });
|
|
311
|
+
else git(tree.repo, ["worktree", "remove", "--force", tree.path]);
|
|
228
312
|
git(tree.repo, ["worktree", "prune"]);
|
|
229
313
|
};
|
|
230
314
|
|
|
@@ -233,7 +317,12 @@ export function createWorktrees({ store, root }) {
|
|
|
233
317
|
const tree = get(threadId);
|
|
234
318
|
if (!tree || tree.state !== "open")
|
|
235
319
|
return { ok: false, error: "there is nothing of this thread's to merge" };
|
|
236
|
-
if (
|
|
320
|
+
if (changedGit(tree))
|
|
321
|
+
return {
|
|
322
|
+
ok: false,
|
|
323
|
+
error: `${changedGit(tree)}, so Harness does not merge it; discard it`,
|
|
324
|
+
};
|
|
325
|
+
if (!stat(tree, `${tree.base}..HEAD`).length)
|
|
237
326
|
return { ok: false, error: "this thread has not changed anything" };
|
|
238
327
|
const into = git(tree.repo, ["rev-parse", "--abbrev-ref", "HEAD"]).out;
|
|
239
328
|
const merged = git(tree.repo, [
|
|
@@ -295,7 +384,7 @@ export function createWorktrees({ store, root }) {
|
|
|
295
384
|
const moved = (threadId) => {
|
|
296
385
|
const tree = get(threadId);
|
|
297
386
|
if (tree?.state === "open" && fs.existsSync(tree.path)) {
|
|
298
|
-
if (stat(tree
|
|
387
|
+
if (stat(tree, `${tree.base}..HEAD`).length)
|
|
299
388
|
return {
|
|
300
389
|
ok: false,
|
|
301
390
|
error: `this thread changed files on ${tree.branch}; merge or discard them first`,
|
|
@@ -357,7 +446,7 @@ export function createWorktrees({ store, root }) {
|
|
|
357
446
|
const tree = get(threadId);
|
|
358
447
|
if (!tree || tree.state !== "open" || !fs.existsSync(tree.path))
|
|
359
448
|
return null;
|
|
360
|
-
return
|
|
449
|
+
return inTree(tree, ["rev-parse", "HEAD"]).out || null;
|
|
361
450
|
};
|
|
362
451
|
|
|
363
452
|
return {
|
|
@@ -366,6 +455,11 @@ export function createWorktrees({ store, root }) {
|
|
|
366
455
|
folderFor,
|
|
367
456
|
startTurn,
|
|
368
457
|
commitTurn,
|
|
458
|
+
/** Why the daemon no longer runs git in the thread's copy, or null (a run replaced its .git). */
|
|
459
|
+
changedGit: (threadId) => {
|
|
460
|
+
const tree = openTree(threadId);
|
|
461
|
+
return tree ? changedGit(tree) : null;
|
|
462
|
+
},
|
|
369
463
|
uncommitted,
|
|
370
464
|
head,
|
|
371
465
|
diff,
|