tryharness 0.7.68 → 0.7.69
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/lib/boardProtocol.json +47 -64
- package/lib/cards.mjs +13 -1
- package/lib/comfyExecution.mjs +545 -0
- package/lib/coordinator.mjs +201 -13
- package/lib/daemon.mjs +142 -6
- package/lib/dispatchContract.json +313 -0
- package/lib/dispatchTools.js +87 -0
- package/lib/dispatches.mjs +975 -0
- package/lib/localAgentAsk.mjs +27 -4
- package/lib/machineRoutes.mjs +5 -0
- package/lib/machineRuns.mjs +2 -1
- package/lib/mcp-stdio.mjs +41 -0
- package/lib/ownMachines.mjs +177 -23
- package/lib/promptDecider.mjs +471 -0
- package/lib/promptFlow.mjs +562 -0
- package/lib/promptScopes.mjs +670 -0
- package/lib/provenance.mjs +3 -2
- package/lib/runAuthority.mjs +14 -2
- package/lib/runBrief.mjs +1 -1
- package/lib/runWorker.mjs +25 -5
- package/lib/runner.mjs +62 -6
- package/lib/store.mjs +225 -13
- package/lib/taskCommands.mjs +125 -1
- package/lib/team.json +10 -0
- package/lib/team.mjs +270 -14
- package/lib/threadBriefs.mjs +30 -29
- package/lib/threadRuns.mjs +47 -3
- package/npm-shrinkwrap.json +10 -10
- package/package.json +3 -3
- package/release.json +31 -24
package/lib/localAgentAsk.mjs
CHANGED
|
@@ -8,26 +8,37 @@ export const LOCAL_DECIDERS = ["claude-code", "codex"];
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* One question to `agent`, answered with one JSON object. It runs in the system's temporary folder, away from any
|
|
11
|
-
* repository, and has no deadline of its own: it ends when the agent answers or exits.
|
|
11
|
+
* repository, and has no deadline of its own: it ends when the agent answers or exits. `model` names the agent's own
|
|
12
|
+
* model; without it the agent uses its default.
|
|
12
13
|
*/
|
|
13
|
-
export function askLocalAgent(
|
|
14
|
+
export function askLocalAgent(
|
|
15
|
+
agent,
|
|
16
|
+
prompt,
|
|
17
|
+
{
|
|
18
|
+
executable = null,
|
|
19
|
+
isolated = false,
|
|
20
|
+
model = null,
|
|
21
|
+
onResponse = () => {},
|
|
22
|
+
} = {}
|
|
23
|
+
) {
|
|
14
24
|
return new Promise((resolve, reject) => {
|
|
15
25
|
const invocation =
|
|
16
26
|
agent === "codex"
|
|
17
27
|
? {
|
|
18
|
-
command: "codex",
|
|
28
|
+
command: executable ?? "codex",
|
|
19
29
|
args: [
|
|
20
30
|
"exec",
|
|
21
31
|
"--json",
|
|
22
32
|
"--sandbox",
|
|
23
33
|
"read-only",
|
|
24
34
|
"--skip-git-repo-check",
|
|
35
|
+
...(model ? ["--model", model] : []),
|
|
25
36
|
"-",
|
|
26
37
|
],
|
|
27
38
|
stdin: prompt,
|
|
28
39
|
}
|
|
29
40
|
: {
|
|
30
|
-
command: "claude",
|
|
41
|
+
command: executable ?? "claude",
|
|
31
42
|
// Only the model reads: the person's MCP servers, hooks and settings made each reading take ~15 s instead
|
|
32
43
|
// of ~2 s, and a question with no tools uses none of them.
|
|
33
44
|
args: [
|
|
@@ -40,6 +51,8 @@ export function askLocalAgent(agent, prompt) {
|
|
|
40
51
|
"--strict-mcp-config",
|
|
41
52
|
"--setting-sources",
|
|
42
53
|
"",
|
|
54
|
+
...(isolated ? ["--bare", "--restricted"] : []),
|
|
55
|
+
...(model ? ["--model", model] : []),
|
|
43
56
|
],
|
|
44
57
|
};
|
|
45
58
|
let child;
|
|
@@ -53,11 +66,21 @@ export function askLocalAgent(agent, prompt) {
|
|
|
53
66
|
child.stdin.on("error", () => {});
|
|
54
67
|
child.stdin.end(invocation.stdin ?? "");
|
|
55
68
|
let out = "";
|
|
69
|
+
let errors = "";
|
|
56
70
|
child.stdout.on("data", (chunk) => {
|
|
57
71
|
out += chunk;
|
|
58
72
|
});
|
|
73
|
+
child.stderr.on("data", (chunk) => {
|
|
74
|
+
errors += chunk;
|
|
75
|
+
});
|
|
59
76
|
child.on("error", reject);
|
|
60
77
|
child.on("close", (code) => {
|
|
78
|
+
try {
|
|
79
|
+
onResponse({ code, stdout: out, stderr: errors });
|
|
80
|
+
} catch (error) {
|
|
81
|
+
reject(error);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
61
84
|
if (code !== 0) {
|
|
62
85
|
reject(new Error(`${agent} exited with code ${code}`));
|
|
63
86
|
return;
|
package/lib/machineRoutes.mjs
CHANGED
|
@@ -46,6 +46,7 @@ const QUEUEABLE = new Set([
|
|
|
46
46
|
"board.thread.post",
|
|
47
47
|
"board.context.add",
|
|
48
48
|
"board.machine.finish",
|
|
49
|
+
"board.prompt.receipt",
|
|
49
50
|
]);
|
|
50
51
|
export const queueable = (command) => QUEUEABLE.has(String(command));
|
|
51
52
|
|
|
@@ -148,6 +149,7 @@ export function withComputer(post, computerOf) {
|
|
|
148
149
|
// A worker's own upkeep with home, whoever it names: telling home its folders, taking and reporting the runs home keeps
|
|
149
150
|
// for its agents, the environment grants home's vault lends a run there (vault.mjs checks those itself).
|
|
150
151
|
const UPKEEP = new Set([
|
|
152
|
+
"board.prompt.receipt",
|
|
151
153
|
"board.machine.info",
|
|
152
154
|
"board.machine.runnable",
|
|
153
155
|
"board.machine.take",
|
|
@@ -222,6 +224,9 @@ const AGENT_WORK = new Set([
|
|
|
222
224
|
// threads. How the swarm is set up (standing permission, spend ceilings, connectors' grants, the vault, the relay
|
|
223
225
|
// network, the desk's book, partners on projects, offices) is changed only on home itself or a phone paired with it.
|
|
224
226
|
const PERSON_WORK = new Set([
|
|
227
|
+
"board.prompt.start",
|
|
228
|
+
"board.prompt.status",
|
|
229
|
+
"board.prompt.cancel",
|
|
225
230
|
...AGENT_WORK,
|
|
226
231
|
"board.run",
|
|
227
232
|
"board.remove",
|
package/lib/machineRuns.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { within } from "./folders.mjs";
|
|
4
4
|
import { provenanceLine } from "./provenance.mjs";
|
|
5
|
+
import { readProfile } from "./profile.mjs";
|
|
5
6
|
import { prepareScratch, threadScratch } from "./scratch.mjs";
|
|
6
7
|
|
|
7
8
|
// On a worker: the work home keeps for this computer's agents, run here. The person's Start (or a thread's authority)
|
|
@@ -94,7 +95,7 @@ export function createMachineRuns({
|
|
|
94
95
|
(ref) => `- ${ref.kind}: ${ref.ref}${ref.note ? ` (${ref.note})` : ""}`
|
|
95
96
|
)
|
|
96
97
|
.join("\n");
|
|
97
|
-
const notice = provenanceLine(task);
|
|
98
|
+
const notice = provenanceLine(task, readProfile()?.displayName);
|
|
98
99
|
return [notice, task.objective, task.brief, refs ? `Context:\n${refs}` : ""]
|
|
99
100
|
.filter(Boolean)
|
|
100
101
|
.join("\n\n");
|
package/lib/mcp-stdio.mjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs from "node:fs";
|
|
3
|
+
import {
|
|
4
|
+
DISPATCH_WORK_TOOL,
|
|
5
|
+
SCOPE_WORKSPACE_TOOL,
|
|
6
|
+
dispatchWorkRequest,
|
|
7
|
+
} from "./dispatchTools.js";
|
|
3
8
|
import { CONNECTION_TOOL, connectionRequest } from "./connectionTools.js";
|
|
4
9
|
import { USE_SECRET_TOOL, secretToolRequest } from "./vaultTools.js";
|
|
5
10
|
import { paths } from "./paths.mjs";
|
|
@@ -31,11 +36,15 @@ if (process.argv.includes("--check-host") && startedByAnother(agent)) {
|
|
|
31
36
|
// (`tryharness connections on`), and never to a restricted run: work another agent or another person's swarm asked
|
|
32
37
|
// for runs without the person's apps (runner.mjs restrictedMcpConfig).
|
|
33
38
|
const restricted = process.argv.includes("--restricted");
|
|
39
|
+
const scopeIndex = process.argv.indexOf("--scope");
|
|
40
|
+
const dispatchScope = scopeIndex >= 0 ? process.argv[scopeIndex + 1] : null;
|
|
34
41
|
const appsOn = !restricted && readJson(paths.config, {}).connectedApps === true;
|
|
35
42
|
let input = "";
|
|
36
43
|
let chain = Promise.resolve();
|
|
37
44
|
|
|
38
45
|
const LOCAL_TOOLS = [
|
|
46
|
+
DISPATCH_WORK_TOOL,
|
|
47
|
+
...(dispatchScope ? [SCOPE_WORKSPACE_TOOL] : []),
|
|
39
48
|
ARCHETYPE_TOOL,
|
|
40
49
|
...(appsOn ? [CONNECTION_TOOL] : []),
|
|
41
50
|
{
|
|
@@ -825,6 +834,15 @@ const postTask = (args) => ({
|
|
|
825
834
|
});
|
|
826
835
|
|
|
827
836
|
const BOARD_CALLS = {
|
|
837
|
+
dispatch_work: dispatchWorkRequest,
|
|
838
|
+
scope_workspace: (args) => ({
|
|
839
|
+
command: "board.dispatch.workspace",
|
|
840
|
+
scopeRef: dispatchScope,
|
|
841
|
+
operation: args.operation,
|
|
842
|
+
path: args.path,
|
|
843
|
+
text: args.text,
|
|
844
|
+
expectedSha256: args.expected_sha256,
|
|
845
|
+
}),
|
|
828
846
|
connection: connectionRequest,
|
|
829
847
|
list_agents: () => ({ command: "board.swarm.agents" }),
|
|
830
848
|
list_models: (args) => ({
|
|
@@ -1367,6 +1385,29 @@ async function relay(line) {
|
|
|
1367
1385
|
return;
|
|
1368
1386
|
}
|
|
1369
1387
|
|
|
1388
|
+
if (dispatchScope) {
|
|
1389
|
+
const names = new Set(["dispatch_work", "scope_workspace"]);
|
|
1390
|
+
if (request.method === "initialize") write(localInitialize(request));
|
|
1391
|
+
else if (request.method === "tools/list")
|
|
1392
|
+
write({
|
|
1393
|
+
jsonrpc: "2.0",
|
|
1394
|
+
id: request.id,
|
|
1395
|
+
result: { tools: LOCAL_TOOLS.filter((tool) => names.has(tool.name)) },
|
|
1396
|
+
});
|
|
1397
|
+
else if (request.method === "tools/call" && names.has(request.params?.name))
|
|
1398
|
+
write(await localCall(request));
|
|
1399
|
+
else if (request.id !== undefined)
|
|
1400
|
+
write({
|
|
1401
|
+
jsonrpc: "2.0",
|
|
1402
|
+
id: request.id,
|
|
1403
|
+
error: {
|
|
1404
|
+
code: -32601,
|
|
1405
|
+
message: "This scope exposes only dispatch and workspace-file tools.",
|
|
1406
|
+
},
|
|
1407
|
+
});
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1370
1411
|
if (
|
|
1371
1412
|
request.method === "tools/call" &&
|
|
1372
1413
|
LOCAL_TOOLS.some((tool) => tool.name === request.params?.name)
|
package/lib/ownMachines.mjs
CHANGED
|
@@ -145,8 +145,10 @@ export function createOwnMachines({
|
|
|
145
145
|
changed = () => {},
|
|
146
146
|
onNotice = () => {},
|
|
147
147
|
// The folders worked in here with the repository each holds: [{ path, repository }].
|
|
148
|
+
// `fresh: true` rereads their current repository identities for an inventory request.
|
|
148
149
|
folders = () => [],
|
|
149
150
|
repositoryOf = () => null,
|
|
151
|
+
inventoryChanged = () => {},
|
|
150
152
|
homeBack = () => {},
|
|
151
153
|
// On home: a worker's call for the board's changes (boardMirror.mjs since).
|
|
152
154
|
answerMirror = null,
|
|
@@ -186,11 +188,27 @@ export function createOwnMachines({
|
|
|
186
188
|
// A proxy link's model call from one of the person's cloud computers, on the computer holding the link
|
|
187
189
|
// (proxyLinks.mjs answer); null where none is held.
|
|
188
190
|
answerLink = null,
|
|
191
|
+
// Bounded GPU operations, admitted only over the pinned Home's sealed ask.
|
|
192
|
+
answerPrompt = null,
|
|
189
193
|
// A cloud computer's own SSH keys (cloudSsh.mjs allow): { key, by } in, null on a computer that takes none.
|
|
190
194
|
ownSsh = null,
|
|
191
195
|
}) {
|
|
192
196
|
// On home: each worker's folders and the repository each holds, as it said them.
|
|
193
197
|
const infos = new Map();
|
|
198
|
+
const inventoryRequests = new Map();
|
|
199
|
+
// Previous folders help diagnose a reconnect, never authorize placement.
|
|
200
|
+
const inventoryOf = (id) => {
|
|
201
|
+
const info = infos.get(id);
|
|
202
|
+
return {
|
|
203
|
+
state: info?.current ? "ready" : info ? "stale" : "unknown",
|
|
204
|
+
receivedAt: info?.receivedAt ?? null,
|
|
205
|
+
repositories: [
|
|
206
|
+
...new Set((info?.folders ?? []).map((folder) => folder.repository)),
|
|
207
|
+
],
|
|
208
|
+
pending: Boolean(inventoryRequests.get(id)?.pending),
|
|
209
|
+
error: inventoryRequests.get(id)?.error ?? null,
|
|
210
|
+
};
|
|
211
|
+
};
|
|
194
212
|
// The account's other computers as Harness last listed them: { id, label, role, connected, agents, publicKey,
|
|
195
213
|
// standInFor }, and this one as Harness lists it.
|
|
196
214
|
let siblings = [];
|
|
@@ -302,6 +320,8 @@ export function createOwnMachines({
|
|
|
302
320
|
const leftHome = machine.role === "home" && role === "worker";
|
|
303
321
|
// A stand-in going back hands over what it wrote (boardMirror.mjs handOver); it brings no board of its own.
|
|
304
322
|
const wasStandIn = Boolean(store.meta("standing-in-for"));
|
|
323
|
+
for (const info of infos.values()) info.current = false;
|
|
324
|
+
inventoryRequests.clear();
|
|
305
325
|
machine.role = role;
|
|
306
326
|
// Setup's code is never a home's join code: a home is not waiting to join anything (M4).
|
|
307
327
|
if (role === "home") machine.joinCode = null;
|
|
@@ -347,6 +367,27 @@ export function createOwnMachines({
|
|
|
347
367
|
if (someoneStandsIn()) returning();
|
|
348
368
|
if (!homeListed()?.connected) toldHome = false;
|
|
349
369
|
else if (!isHome()) void flush();
|
|
370
|
+
if (isHome()) {
|
|
371
|
+
for (const sibling of siblings) {
|
|
372
|
+
const prior = before.get(sibling.id);
|
|
373
|
+
if (
|
|
374
|
+
!sibling.connected ||
|
|
375
|
+
!prior?.connected ||
|
|
376
|
+
prior.publicKey !== sibling.publicKey
|
|
377
|
+
) {
|
|
378
|
+
const info = infos.get(sibling.id);
|
|
379
|
+
if (info) info.current = false;
|
|
380
|
+
inventoryRequests.delete(sibling.id);
|
|
381
|
+
}
|
|
382
|
+
if (
|
|
383
|
+
sibling.connected &&
|
|
384
|
+
confirmed(sibling) &&
|
|
385
|
+
inventoryOf(sibling.id).state !== "ready"
|
|
386
|
+
)
|
|
387
|
+
void refreshInventory(sibling.id);
|
|
388
|
+
}
|
|
389
|
+
inventoryChanged();
|
|
390
|
+
}
|
|
350
391
|
};
|
|
351
392
|
|
|
352
393
|
const rename = async (label) => {
|
|
@@ -1200,7 +1241,7 @@ export function createOwnMachines({
|
|
|
1200
1241
|
if (session?.id === "none") session = null;
|
|
1201
1242
|
try {
|
|
1202
1243
|
for (;;) {
|
|
1203
|
-
const [next
|
|
1244
|
+
const [next] = outbox();
|
|
1204
1245
|
if (!next) break;
|
|
1205
1246
|
const key = await keyFor(pinned.public_key, machine.id);
|
|
1206
1247
|
const answered = await deliverSealed(
|
|
@@ -1219,7 +1260,9 @@ export function createOwnMachines({
|
|
|
1219
1260
|
break;
|
|
1220
1261
|
}
|
|
1221
1262
|
const result = answered.result;
|
|
1222
|
-
|
|
1263
|
+
// A receipt can be queued while this delivery is awaiting its answer.
|
|
1264
|
+
// Remove only the delivered item, preserving concurrently appended work.
|
|
1265
|
+
keepOut(outbox().filter((item) => item.requestId !== next.requestId));
|
|
1223
1266
|
log(
|
|
1224
1267
|
`sent ${next.command} to your home computer: ${result?.ok === false && result.code !== "replayed" ? result.error : "taken"}`
|
|
1225
1268
|
);
|
|
@@ -1425,6 +1468,9 @@ export function createOwnMachines({
|
|
|
1425
1468
|
// Kept, sealed, until home is back; the call carries when it was written.
|
|
1426
1469
|
const { requestId, envelope } = await send(pinned, call, { queued: true });
|
|
1427
1470
|
keepOut([...outbox(), { requestId, envelope, command: call.command }]);
|
|
1471
|
+
// Home may have reconnected during the failed call, after its connection
|
|
1472
|
+
// notification already drained the queue. Give this newly queued item a turn.
|
|
1473
|
+
if (homeListed()?.connected) void flush();
|
|
1428
1474
|
return {
|
|
1429
1475
|
ok: true,
|
|
1430
1476
|
queued: true,
|
|
@@ -1757,6 +1803,62 @@ export function createOwnMachines({
|
|
|
1757
1803
|
}).catch(() => null);
|
|
1758
1804
|
};
|
|
1759
1805
|
|
|
1806
|
+
// Home can restart without breaking the worker's connection to Harness.
|
|
1807
|
+
// Ask explicitly instead of relying on that worker noticing a goodbye.
|
|
1808
|
+
const refreshInventory = async (workerId, { force = false } = {}) => {
|
|
1809
|
+
const sibling = siblings.find((peer) => peer.id === workerId);
|
|
1810
|
+
if (!isHome() || !sibling?.connected || !confirmed(sibling))
|
|
1811
|
+
return {
|
|
1812
|
+
ok: false,
|
|
1813
|
+
error: "inventory needs a connected, confirmed worker",
|
|
1814
|
+
};
|
|
1815
|
+
if (!force && inventoryRequests.has(workerId))
|
|
1816
|
+
return { ok: true, inventory: inventoryOf(workerId) };
|
|
1817
|
+
const request = { id: randomUUID(), pending: true, error: null };
|
|
1818
|
+
inventoryRequests.set(workerId, request);
|
|
1819
|
+
const info = infos.get(workerId);
|
|
1820
|
+
if (info) info.current = false;
|
|
1821
|
+
changed();
|
|
1822
|
+
// A sealed answer completes the snapshot, rather than acknowledging only
|
|
1823
|
+
// its notice. Old workers refuse the unknown question. A missing transport
|
|
1824
|
+
// answer gets one retry; no separate deadline or timer is introduced here.
|
|
1825
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
1826
|
+
const answer = await askWorker(workerId, { inventory: true }).catch(
|
|
1827
|
+
() => null
|
|
1828
|
+
);
|
|
1829
|
+
if (inventoryRequests.get(workerId) !== request) break;
|
|
1830
|
+
if (
|
|
1831
|
+
answer?.ok === true &&
|
|
1832
|
+
learn(workerId, { request: request.id, folders: answer.folders })
|
|
1833
|
+
)
|
|
1834
|
+
break;
|
|
1835
|
+
if (answer) break;
|
|
1836
|
+
}
|
|
1837
|
+
if (inventoryRequests.get(workerId) === request) {
|
|
1838
|
+
request.pending = false;
|
|
1839
|
+
request.error = "Repository inventory did not arrive";
|
|
1840
|
+
changed();
|
|
1841
|
+
inventoryChanged(workerId);
|
|
1842
|
+
}
|
|
1843
|
+
return {
|
|
1844
|
+
ok: inventoryOf(workerId).state === "ready",
|
|
1845
|
+
inventory: inventoryOf(workerId),
|
|
1846
|
+
};
|
|
1847
|
+
};
|
|
1848
|
+
|
|
1849
|
+
const reportInventory = async (request) => {
|
|
1850
|
+
const home = pinnedHome();
|
|
1851
|
+
if (isHome() || !home) return;
|
|
1852
|
+
const here = folders({ fresh: true });
|
|
1853
|
+
const reported = await callOnce(home, {
|
|
1854
|
+
command: "board.machine.info",
|
|
1855
|
+
agent: "user",
|
|
1856
|
+
folders: here,
|
|
1857
|
+
inventoryRequest: request,
|
|
1858
|
+
});
|
|
1859
|
+
if (reported?.ok === true) toldHome = JSON.stringify(here);
|
|
1860
|
+
};
|
|
1861
|
+
|
|
1760
1862
|
// A notice is sealed by the computer that sent it as home: the home this computer follows, or another it confirmed (one
|
|
1761
1863
|
// that moved home to itself, or stands in), tried in turn. Harness's word on who sent it counts for nothing.
|
|
1762
1864
|
const openNoticeFromAny = async (body) => {
|
|
@@ -1793,6 +1895,12 @@ export function createOwnMachines({
|
|
|
1793
1895
|
}
|
|
1794
1896
|
// Everything else is the word of the home this computer follows; another's is heard and set aside.
|
|
1795
1897
|
if (from !== acceptedHome()) return { ok: true };
|
|
1898
|
+
if (!isHome() && typeof notice.inventoryRequest === "string") {
|
|
1899
|
+
void reportInventory(notice.inventoryRequest).catch((error) =>
|
|
1900
|
+
log(`repository inventory was not reported: ${error.message}`)
|
|
1901
|
+
);
|
|
1902
|
+
return { ok: true };
|
|
1903
|
+
}
|
|
1796
1904
|
if (typeof notice.removed === "string") {
|
|
1797
1905
|
removedByHome(notice.removed);
|
|
1798
1906
|
return { ok: true };
|
|
@@ -1990,22 +2098,26 @@ export function createOwnMachines({
|
|
|
1990
2098
|
// a question for the windows only from the few they answer for home (M6).
|
|
1991
2099
|
// A cloud home's call through a proxy link this computer holds is answered for that home alone (proxyLinks.mjs).
|
|
1992
2100
|
const answer =
|
|
1993
|
-
call.
|
|
1994
|
-
? await
|
|
1995
|
-
: call.
|
|
1996
|
-
?
|
|
1997
|
-
: call.
|
|
1998
|
-
? await
|
|
1999
|
-
: call.
|
|
2000
|
-
? await
|
|
2001
|
-
: call.
|
|
2002
|
-
?
|
|
2003
|
-
:
|
|
2004
|
-
? await
|
|
2005
|
-
:
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2101
|
+
call.prompt && answerPrompt
|
|
2102
|
+
? await answerPrompt(call.prompt, pinned.machine_id)
|
|
2103
|
+
: call.inventory === true
|
|
2104
|
+
? { ok: true, folders: folders({ fresh: true }) }
|
|
2105
|
+
: call.home === true
|
|
2106
|
+
? await becomeHome(call.computers)
|
|
2107
|
+
: call.link && answerLink
|
|
2108
|
+
? await answerLink(pinned.machine_id, call.link)
|
|
2109
|
+
: call.models
|
|
2110
|
+
? await ownModels(call.models)
|
|
2111
|
+
: call.live
|
|
2112
|
+
? await ownLive(call.live)
|
|
2113
|
+
: call.ssh
|
|
2114
|
+
? ownSshAllow(call.ssh)
|
|
2115
|
+
: WINDOW_TOOLS.has(call.tool)
|
|
2116
|
+
? await askOwnWindows(call)
|
|
2117
|
+
: {
|
|
2118
|
+
ok: false,
|
|
2119
|
+
error: `home cannot ask this computer's windows for ${call.tool}`,
|
|
2120
|
+
};
|
|
2009
2121
|
return {
|
|
2010
2122
|
envelope: await sealAskAnswer(
|
|
2011
2123
|
key,
|
|
@@ -2072,6 +2184,7 @@ export function createOwnMachines({
|
|
|
2072
2184
|
connected: sibling.connected,
|
|
2073
2185
|
agents: sibling.agents,
|
|
2074
2186
|
confirmed: confirmed(sibling),
|
|
2187
|
+
...(isHome() ? { inventory: inventoryOf(sibling.id) } : {}),
|
|
2075
2188
|
// Harness runs it (a cloud computer): what home lets it do is an agents' computer's, never the person's.
|
|
2076
2189
|
hosted: store.ownMachine(sibling.id)?.hosted === true,
|
|
2077
2190
|
standsInForThis: sibling.standInFor === machine.id,
|
|
@@ -2572,20 +2685,23 @@ export function createOwnMachines({
|
|
|
2572
2685
|
|
|
2573
2686
|
/**
|
|
2574
2687
|
* For the coordinator: the person's computers with this agent, each with whether it is online and has the thread's
|
|
2575
|
-
* repository
|
|
2688
|
+
* repository, including an agent installed on this computer alone.
|
|
2576
2689
|
*/
|
|
2577
2690
|
const computersFor = (agent, workspace) => {
|
|
2578
2691
|
const computers = computersWith(agent);
|
|
2579
|
-
if (!computers.some((computer) => !computer.here)) return undefined;
|
|
2580
2692
|
const repository = workspace ? repositoryOf(workspace) : null;
|
|
2581
2693
|
return computers.map(({ id, label, online, here }) => ({
|
|
2694
|
+
id,
|
|
2582
2695
|
label,
|
|
2583
2696
|
online,
|
|
2697
|
+
...(!here ? { inventory: inventoryOf(id) } : {}),
|
|
2584
2698
|
...(repository
|
|
2585
2699
|
? {
|
|
2586
2700
|
thread_repository: here
|
|
2587
2701
|
? true
|
|
2588
|
-
:
|
|
2702
|
+
: inventoryOf(id).state === "ready"
|
|
2703
|
+
? namesOf(infos.get(id).folders).includes(repository)
|
|
2704
|
+
: null,
|
|
2589
2705
|
}
|
|
2590
2706
|
: {}),
|
|
2591
2707
|
}));
|
|
@@ -2593,7 +2709,33 @@ export function createOwnMachines({
|
|
|
2593
2709
|
|
|
2594
2710
|
/** On home: what a worker said it has (its folders and their repositories), sealed, so work can go to it. */
|
|
2595
2711
|
const learn = (id, info) => {
|
|
2596
|
-
|
|
2712
|
+
id = String(id);
|
|
2713
|
+
if (!store.ownMachine(id)) return false;
|
|
2714
|
+
if (info.request && inventoryRequests.get(id)?.id !== info.request)
|
|
2715
|
+
return false;
|
|
2716
|
+
if (
|
|
2717
|
+
!Array.isArray(info.folders) ||
|
|
2718
|
+
info.folders.some(
|
|
2719
|
+
(folder) =>
|
|
2720
|
+
typeof folder?.path !== "string" ||
|
|
2721
|
+
!path.isAbsolute(folder.path) ||
|
|
2722
|
+
typeof folder.repository !== "string"
|
|
2723
|
+
)
|
|
2724
|
+
)
|
|
2725
|
+
return false;
|
|
2726
|
+
const folders = info.folders.slice(0, 200).map((folder) => ({
|
|
2727
|
+
path: folder.path.slice(0, 1024),
|
|
2728
|
+
repository: folder.repository.slice(0, 300),
|
|
2729
|
+
}));
|
|
2730
|
+
const receivedAt = new Date().toISOString();
|
|
2731
|
+
infos.set(id, { folders, receivedAt, current: true });
|
|
2732
|
+
inventoryRequests.delete(id);
|
|
2733
|
+
log(
|
|
2734
|
+
`repository inventory received from ${labelOf(id) ?? id}: ${info.folders.length} folders`
|
|
2735
|
+
);
|
|
2736
|
+
changed();
|
|
2737
|
+
inventoryChanged(id);
|
|
2738
|
+
return true;
|
|
2597
2739
|
};
|
|
2598
2740
|
const namesOf = (list) => [
|
|
2599
2741
|
...new Set(list.map((folder) => folder.repository).filter(Boolean)),
|
|
@@ -2618,6 +2760,7 @@ export function createOwnMachines({
|
|
|
2618
2760
|
for (const sibling of siblings) {
|
|
2619
2761
|
if (!sibling.agents.includes(agent) || !store.ownMachine(sibling.id))
|
|
2620
2762
|
continue;
|
|
2763
|
+
if (inventoryOf(sibling.id).state !== "ready") continue;
|
|
2621
2764
|
const folder = infos
|
|
2622
2765
|
.get(sibling.id)
|
|
2623
2766
|
?.folders.find((each) => each.repository === repository)?.path;
|
|
@@ -2635,9 +2778,12 @@ export function createOwnMachines({
|
|
|
2635
2778
|
const label = labelOf(id) ?? "that computer";
|
|
2636
2779
|
if (!sibling || !store.ownMachine(id))
|
|
2637
2780
|
return { error: `${label} is not connected` };
|
|
2781
|
+
if (!sibling.connected) return { error: `${label} is offline` };
|
|
2638
2782
|
if (!sibling.agents.includes(agent))
|
|
2639
2783
|
return { error: `${nameOf(agent)} is not on ${label}` };
|
|
2640
2784
|
if (!workspace) return { machine: id, folder: null };
|
|
2785
|
+
if (inventoryOf(id).state !== "ready")
|
|
2786
|
+
return { error: `${label}'s repository inventory is not ready` };
|
|
2641
2787
|
const repository = repositoryOf(workspace);
|
|
2642
2788
|
const folder = repository
|
|
2643
2789
|
? infos.get(id)?.folders.find((each) => each.repository === repository)
|
|
@@ -2661,7 +2807,10 @@ export function createOwnMachines({
|
|
|
2661
2807
|
},
|
|
2662
2808
|
...siblings.map((sibling) => ({
|
|
2663
2809
|
...sibling,
|
|
2664
|
-
repositories:
|
|
2810
|
+
repositories:
|
|
2811
|
+
inventoryOf(sibling.id).state === "ready"
|
|
2812
|
+
? namesOf(infos.get(sibling.id).folders)
|
|
2813
|
+
: [],
|
|
2665
2814
|
})),
|
|
2666
2815
|
];
|
|
2667
2816
|
|
|
@@ -2771,6 +2920,10 @@ export function createOwnMachines({
|
|
|
2771
2920
|
answerAs,
|
|
2772
2921
|
pushViews,
|
|
2773
2922
|
askWorkerWindows,
|
|
2923
|
+
promptTo: (workerId, call) =>
|
|
2924
|
+
isHome() && store.ownMachine(workerId)?.hosted !== true
|
|
2925
|
+
? askWorker(workerId, { prompt: call })
|
|
2926
|
+
: Promise.resolve(null),
|
|
2774
2927
|
linkCall,
|
|
2775
2928
|
tellWorkers,
|
|
2776
2929
|
fromLink,
|
|
@@ -2803,6 +2956,7 @@ export function createOwnMachines({
|
|
|
2803
2956
|
status,
|
|
2804
2957
|
all,
|
|
2805
2958
|
learn,
|
|
2959
|
+
refreshInventory,
|
|
2806
2960
|
placeElsewhere,
|
|
2807
2961
|
placeOn,
|
|
2808
2962
|
computerNamed,
|