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/vault.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// The swarm's secrets, kept by the relay on the person's own computer.
|
|
2
|
-
//
|
|
3
|
-
// to 1claw
|
|
1
|
+
// The swarm's secrets, kept by the relay on the person's own computer. The relay holds the secrets and agents in the
|
|
2
|
+
// swarm use them from it, always through one daemon key; the person may also grant one to an agent's run as an
|
|
3
|
+
// environment variable; a backup to 1claw creates the person's 1claw account. The vault is a 1claw local vault (oneclawLocal.mjs) in
|
|
4
4
|
// <home>/vault.enc, sealed with a random key in <home>/vault-key (both owner-only), so `1claw local` and 1claw's
|
|
5
5
|
// daemon open the same file. Who may use what, the agents' requests and the backup's state live in the store
|
|
6
6
|
// (`vault:v1`); no value ever does.
|
|
@@ -50,11 +50,46 @@ const METHODS = new Set(["GET", "POST", "PUT", "PATCH", "DELETE"]);
|
|
|
50
50
|
const BODYLESS = new Set(["GET", "DELETE"]);
|
|
51
51
|
const REDIRECTS = new Set([301, 302, 303, 307, 308]);
|
|
52
52
|
const LOOPBACK = new Set(["127.0.0.1", "localhost", "[::1]"]);
|
|
53
|
-
// What use_secret gives back,
|
|
53
|
+
// What use_secret gives back, as Harness's earlier browser path gave it: enough of an answer for an
|
|
54
54
|
// agent to act on, never a whole download.
|
|
55
55
|
const RESPONSE_CAP = 8_000;
|
|
56
56
|
const MAX_REDIRECTS = 3;
|
|
57
57
|
const OWNER_ONLY = "Only the person can do that, on their home computer.";
|
|
58
|
+
// Where in a request a secret may go. A header is the default: a website keeps what is sent in an address or a body
|
|
59
|
+
// (a gist, an issue, a search log) and anyone who reads it there has the secret. A secret's own setting widens it.
|
|
60
|
+
const PLACES = ["header", "url", "body"];
|
|
61
|
+
// Websites whose APIs take a key in the address itself. A secret kept for one of them before placements existed may go
|
|
62
|
+
// in the URL there, so it keeps working; every other secret kept before then goes in headers only.
|
|
63
|
+
const KEY_IN_URL = [
|
|
64
|
+
"api.telegram.org",
|
|
65
|
+
"*.alchemy.com",
|
|
66
|
+
"*.infura.io",
|
|
67
|
+
"*.quiknode.pro",
|
|
68
|
+
"api.etherscan.io",
|
|
69
|
+
"api.basescan.org",
|
|
70
|
+
"api.arbiscan.io",
|
|
71
|
+
"api-optimistic.etherscan.io",
|
|
72
|
+
"api.polygonscan.com",
|
|
73
|
+
"generativelanguage.googleapis.com",
|
|
74
|
+
"maps.googleapis.com",
|
|
75
|
+
"www.googleapis.com",
|
|
76
|
+
"api.openweathermap.org",
|
|
77
|
+
];
|
|
78
|
+
const takesKeyInUrl = (host) => {
|
|
79
|
+
const name = String(host).toLowerCase().replace(/^\*\./, "").split(":")[0];
|
|
80
|
+
return KEY_IN_URL.some((known) =>
|
|
81
|
+
known.startsWith("*.")
|
|
82
|
+
? name === known.slice(2) || name.endsWith(known.slice(1))
|
|
83
|
+
: name === known
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
/** Where a secret kept before placements may go: headers, and the URL for a website that takes its key there. */
|
|
87
|
+
export const placesNeededFor = (hosts) =>
|
|
88
|
+
(hosts ?? []).some(takesKeyInUrl) ? ["header", "url"] : ["header"];
|
|
89
|
+
const placesOf = (written) =>
|
|
90
|
+
PLACES.filter((place) =>
|
|
91
|
+
(Array.isArray(written) ? written : []).map(String).includes(place)
|
|
92
|
+
);
|
|
58
93
|
|
|
59
94
|
/** Every value in `text` (and its URL-encoded form) replaced by its name's marker. */
|
|
60
95
|
export function scrubValues(text, values) {
|
|
@@ -119,6 +154,7 @@ export function createVault({
|
|
|
119
154
|
grants: [],
|
|
120
155
|
requests: [],
|
|
121
156
|
shares: [],
|
|
157
|
+
policies: {},
|
|
122
158
|
backup: { status: "off" },
|
|
123
159
|
...JSON.parse(store.meta(STATE) ?? "{}"),
|
|
124
160
|
};
|
|
@@ -127,6 +163,7 @@ export function createVault({
|
|
|
127
163
|
grants: [],
|
|
128
164
|
requests: [],
|
|
129
165
|
shares: [],
|
|
166
|
+
policies: {},
|
|
130
167
|
backup: { status: "off" },
|
|
131
168
|
};
|
|
132
169
|
}
|
|
@@ -142,6 +179,19 @@ export function createVault({
|
|
|
142
179
|
: emptyVault();
|
|
143
180
|
vault.harness ??= {};
|
|
144
181
|
vault.harness.removed ??= [];
|
|
182
|
+
// Each secret's websites and places as this computer keeps them, apart from the vault file and from 1claw: what a
|
|
183
|
+
// restore brings back takes its websites from here, never from the copy it came from (provision).
|
|
184
|
+
state.policies ??= {};
|
|
185
|
+
let kept = false;
|
|
186
|
+
for (const [name, secret] of Object.entries(vault.secrets))
|
|
187
|
+
if (!state.policies[name]) {
|
|
188
|
+
state.policies[name] = {
|
|
189
|
+
hosts: secret.allowed_hosts ?? [],
|
|
190
|
+
places: placesNeededFor(secret.allowed_hosts),
|
|
191
|
+
};
|
|
192
|
+
kept = true;
|
|
193
|
+
}
|
|
194
|
+
if (kept) saveState();
|
|
145
195
|
})().catch((error) => {
|
|
146
196
|
log(`vault: could not open ${file}: ${error.message}`);
|
|
147
197
|
throw error;
|
|
@@ -162,10 +212,16 @@ export function createVault({
|
|
|
162
212
|
const live = (grant) =>
|
|
163
213
|
!grant.expiresAt || Date.parse(grant.expiresAt) > Date.now();
|
|
164
214
|
const hostsOf = (name) => vault.secrets[name]?.allowed_hosts ?? [];
|
|
215
|
+
const secretPlaces = (name) => state.policies[name]?.places ?? ["header"];
|
|
216
|
+
const keepPolicy = (name, fields) => {
|
|
217
|
+
state.policies[name] = { ...state.policies[name], ...fields };
|
|
218
|
+
saveState();
|
|
219
|
+
};
|
|
165
220
|
const publicSecret = ([name, secret]) => ({
|
|
166
221
|
name,
|
|
167
222
|
type: secret.type,
|
|
168
223
|
hosts: secret.allowed_hosts ?? [],
|
|
224
|
+
places: secretPlaces(name),
|
|
169
225
|
updatedAt: secret.updated_at,
|
|
170
226
|
backedUp: secret.synced_to_cloud === true,
|
|
171
227
|
});
|
|
@@ -315,7 +371,7 @@ export function createVault({
|
|
|
315
371
|
return {
|
|
316
372
|
ok: false,
|
|
317
373
|
error:
|
|
318
|
-
"Put the secret where it goes as {{secret:name}} in
|
|
374
|
+
"Put the secret where it goes as {{secret:name}}, in a header (or the url or the body where that secret may go there).",
|
|
319
375
|
};
|
|
320
376
|
let target;
|
|
321
377
|
try {
|
|
@@ -325,6 +381,9 @@ export function createVault({
|
|
|
325
381
|
}
|
|
326
382
|
const values = new Map();
|
|
327
383
|
const runId = runOf(agent, from, request.runId);
|
|
384
|
+
const namedIn = (text) =>
|
|
385
|
+
new Set([...String(text ?? "").matchAll(REF)].map((match) => match[1]));
|
|
386
|
+
const where = { url: namedIn(url), body: namedIn(body) };
|
|
328
387
|
for (const name of names) {
|
|
329
388
|
const secret = vault.secrets[name];
|
|
330
389
|
if (!secret) {
|
|
@@ -334,6 +393,14 @@ export function createVault({
|
|
|
334
393
|
error: `${name} is not in the person's vault. Harness asked them to add it; try again once they have.`,
|
|
335
394
|
};
|
|
336
395
|
}
|
|
396
|
+
const misplaced = ["url", "body"].find(
|
|
397
|
+
(place) => where[place].has(name) && !secretPlaces(name).includes(place)
|
|
398
|
+
);
|
|
399
|
+
if (misplaced)
|
|
400
|
+
return {
|
|
401
|
+
ok: false,
|
|
402
|
+
error: `${name} goes only in a request's ${secretPlaces(name).join(" or ")}, not its ${misplaced === "url" ? "URL" : "body"}: a website can keep what is sent there. Put it in a header (Authorization: Bearer {{secret:${name}}}, for example), or the person can allow it with: npx tryharness vault places ${name} ${[...secretPlaces(name), misplaced].join(",")}`,
|
|
403
|
+
};
|
|
337
404
|
if (
|
|
338
405
|
!grantFor(agent, name, "use", { hosted, fromElsewhere, task: runId })
|
|
339
406
|
) {
|
|
@@ -457,7 +524,7 @@ export function createVault({
|
|
|
457
524
|
return `1claw's plan is full: ${error.message}`;
|
|
458
525
|
if (error instanceof OneclawError && error.status === 401)
|
|
459
526
|
return "1claw no longer accepts this computer's key; it may have been removed in 1claw. Turn backup on again.";
|
|
460
|
-
// 1claw answered, with an error of its own (
|
|
527
|
+
// 1claw answered, with an error of its own (for one, a share link on a secret the agent may write).
|
|
461
528
|
if (error instanceof OneclawError)
|
|
462
529
|
return `1claw refused (${error.status}): ${error.message}`;
|
|
463
530
|
return `1claw could not be reached: ${error.message}`;
|
|
@@ -572,9 +639,11 @@ export function createVault({
|
|
|
572
639
|
entry.path,
|
|
573
640
|
secret.value,
|
|
574
641
|
TYPES.has(secret.type) ? secret.type : "generic",
|
|
642
|
+
// Its websites as this computer kept them, never as the backup's copy says: whoever can write the backup
|
|
643
|
+
// could otherwise name where the value goes. One this computer never knew waits for the person to name them.
|
|
575
644
|
{
|
|
576
|
-
allowed_hosts: (
|
|
577
|
-
HOST.test(String(host))
|
|
645
|
+
allowed_hosts: (state.policies[entry.path]?.hosts ?? []).filter(
|
|
646
|
+
(host) => HOST.test(String(host))
|
|
578
647
|
),
|
|
579
648
|
}
|
|
580
649
|
);
|
|
@@ -685,7 +754,12 @@ export function createVault({
|
|
|
685
754
|
"board.vault.save": async (request) => {
|
|
686
755
|
const name = String(request.name ?? "").trim();
|
|
687
756
|
const value = typeof request.value === "string" ? request.value : "";
|
|
688
|
-
|
|
757
|
+
// Websites unnamed in the call stay as they are (a change of places alone).
|
|
758
|
+
const hosts = (
|
|
759
|
+
Array.isArray(request.hosts)
|
|
760
|
+
? request.hosts
|
|
761
|
+
: (vault.secrets[name]?.allowed_hosts ?? [])
|
|
762
|
+
)
|
|
689
763
|
.map((host) => String(host).trim().toLowerCase())
|
|
690
764
|
.filter(Boolean);
|
|
691
765
|
const type = TYPES.has(request.type)
|
|
@@ -705,6 +779,14 @@ export function createVault({
|
|
|
705
779
|
ok: false,
|
|
706
780
|
error: `${badHost} is not a website's address (for example api.fly.io).`,
|
|
707
781
|
};
|
|
782
|
+
const places =
|
|
783
|
+
request.places === undefined ? null : placesOf(request.places);
|
|
784
|
+
if (places && !places.includes("header"))
|
|
785
|
+
return {
|
|
786
|
+
ok: false,
|
|
787
|
+
error:
|
|
788
|
+
"A secret may always go in a header; name header with the others.",
|
|
789
|
+
};
|
|
708
790
|
if (value) putSecret(vault, name, value, type, { allowed_hosts: hosts });
|
|
709
791
|
else
|
|
710
792
|
Object.assign(vault.secrets[name], {
|
|
@@ -713,6 +795,10 @@ export function createVault({
|
|
|
713
795
|
synced_to_cloud: false,
|
|
714
796
|
updated_at: now(),
|
|
715
797
|
});
|
|
798
|
+
keepPolicy(name, {
|
|
799
|
+
hosts,
|
|
800
|
+
places: places ?? state.policies[name]?.places ?? ["header"],
|
|
801
|
+
});
|
|
716
802
|
vault.harness.removed = vault.harness.removed.filter(
|
|
717
803
|
(entry) => entry !== name
|
|
718
804
|
);
|
|
@@ -734,6 +820,7 @@ export function createVault({
|
|
|
734
820
|
if (vault.secrets[name].cloud_path || vault.harness.cloud)
|
|
735
821
|
vault.harness.removed.push(name);
|
|
736
822
|
delete vault.secrets[name];
|
|
823
|
+
delete state.policies[name];
|
|
737
824
|
state.grants = state.grants.filter((grant) => grant.secret !== name);
|
|
738
825
|
saveState();
|
|
739
826
|
await persist();
|
|
@@ -1062,7 +1149,11 @@ export function createVault({
|
|
|
1062
1149
|
.filter((name) =>
|
|
1063
1150
|
grantFor(agent, name, "use", { hosted, fromElsewhere })
|
|
1064
1151
|
)
|
|
1065
|
-
.map((name) => ({
|
|
1152
|
+
.map((name) => ({
|
|
1153
|
+
name,
|
|
1154
|
+
hosts: hostsOf(name),
|
|
1155
|
+
places: secretPlaces(name),
|
|
1156
|
+
})),
|
|
1066
1157
|
};
|
|
1067
1158
|
};
|
|
1068
1159
|
|
package/lib/vaultCloud.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The 1claw API, as the relay's vault uses it for the person's backup (vault.mjs). Shapes from @1claw/openapi-spec
|
|
2
2
|
// 0.61.76 and the 1claw CLI's own sign-in and provisioning (src/auth.ts loginWithDevice, src/lib/provisioning.ts).
|
|
3
|
-
// No request here has a deadline of its own: none of these endpoints has been measured
|
|
4
|
-
// until 1claw answers or the caller gives up.
|
|
3
|
+
// No request here has a deadline of its own: none of these endpoints has been measured, and no deadline is set
|
|
4
|
+
// unmeasured, so a call lasts until 1claw answers or the caller gives up.
|
|
5
5
|
|
|
6
6
|
export const ONECLAW_API = "https://api.1claw.co";
|
|
7
7
|
|
package/lib/vaultCommands.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { daemonRequest } from "./control-client.mjs";
|
|
2
|
+
import { relayCommand } from "./runtime-install.mjs";
|
|
2
3
|
|
|
3
4
|
// `npx tryharness vault`: the person's vault in this computer's relay (vault.mjs), from the terminal. A value is
|
|
4
5
|
// typed at a hidden prompt, piped in, or named by an environment variable; never written on the command line, where
|
|
@@ -7,6 +8,7 @@ import { daemonRequest } from "./control-client.mjs";
|
|
|
7
8
|
const USAGE = `vault what is kept, who is asking, who may use what, and the backup
|
|
8
9
|
vault add <name> --hosts api.fly.io[,...] [--value-env NAME] keep a secret (typed hidden, piped, or from NAME)
|
|
9
10
|
vault hosts <name> <host,...> change where it may be sent
|
|
11
|
+
vault places <name> header[,url][,body] where in a request it may go (a header unless you allow more)
|
|
10
12
|
vault remove <name>
|
|
11
13
|
vault allow <agent> <name> let an agent use it (the relay sends it; the agent never sees it)
|
|
12
14
|
vault runs <agent> <name> <VARIABLE> [--elsewhere] put it in the agent's runs (it can read it there)
|
|
@@ -75,13 +77,13 @@ export async function vaultCommands(argv) {
|
|
|
75
77
|
for (const request of vault.requests)
|
|
76
78
|
console.log(
|
|
77
79
|
request.why === "missing"
|
|
78
|
-
? `${request.agent} needs ${request.secret}${request.host ? ` for ${request.host}` : ""}:
|
|
79
|
-
: `${request.agent} asks to use ${request.secret}:
|
|
80
|
+
? `${request.agent} needs ${request.secret}${request.host ? ` for ${request.host}` : ""}: ${relayCommand()} vault add ${request.secret} --hosts ${request.host ?? "<website>"}`
|
|
81
|
+
: `${request.agent} asks to use ${request.secret}: ${relayCommand()} vault allow ${request.agent} ${request.secret}`
|
|
80
82
|
);
|
|
81
83
|
if (!vault.secrets.length) console.log("Nothing kept yet.");
|
|
82
84
|
for (const secret of vault.secrets)
|
|
83
85
|
console.log(
|
|
84
|
-
`${secret.name} ${secret.hosts.length ? `only sent to ${secret.hosts.join(", ")}` : "no website yet, so no agent can use it"}`
|
|
86
|
+
`${secret.name} ${secret.hosts.length ? `only sent to ${secret.hosts.join(", ")}, in a request's ${(secret.places ?? ["header"]).join(" or ")}` : "no website yet, so no agent can use it"}`
|
|
85
87
|
);
|
|
86
88
|
for (const grant of vault.grants)
|
|
87
89
|
console.log(
|
|
@@ -109,10 +111,17 @@ export async function vaultCommands(argv) {
|
|
|
109
111
|
: await hiddenValue(`Value for ${name} (hidden): `);
|
|
110
112
|
await call("save", { name, value, hosts: hostsOf(option("--hosts")) });
|
|
111
113
|
console.log(
|
|
112
|
-
`Kept ${name} on this computer${option("--hosts") ? `, only sent to ${hostsOf(option("--hosts")).join(", ")}` :
|
|
114
|
+
`Kept ${name} on this computer${option("--hosts") ? `, only sent to ${hostsOf(option("--hosts")).join(", ")}` : `. Name its website before an agent uses it: ${relayCommand()} vault hosts ` + name + " <host>"}.`
|
|
113
115
|
);
|
|
114
116
|
return;
|
|
115
117
|
}
|
|
118
|
+
// A website keeps what it is sent in an address or a body; only a header is allowed until the person says more.
|
|
119
|
+
if (action === "places") {
|
|
120
|
+
const places = hostsOf(second);
|
|
121
|
+
await call("save", { name: first, value: "", places });
|
|
122
|
+
console.log(`${first} may go in a request's ${places.join(", ")}.`);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
116
125
|
if (action === "hosts") {
|
|
117
126
|
await call("save", { name: first, value: "", hosts: hostsOf(second) });
|
|
118
127
|
console.log(`${first} is only sent to ${hostsOf(second).join(", ")}.`);
|
|
@@ -165,7 +174,7 @@ export async function vaultCommands(argv) {
|
|
|
165
174
|
bringIn: argv.includes("--bring-in"),
|
|
166
175
|
});
|
|
167
176
|
console.log(
|
|
168
|
-
`Approve code ${started.code} in 1claw: ${started.verifyUrl}\nWith no 1claw account, signing up with ${first} makes one. Then:
|
|
177
|
+
`Approve code ${started.code} in 1claw: ${started.verifyUrl}\nWith no 1claw account, signing up with ${first} makes one. Then: ${relayCommand()} vault`
|
|
169
178
|
);
|
|
170
179
|
return;
|
|
171
180
|
}
|
|
@@ -178,7 +187,7 @@ export async function vaultCommands(argv) {
|
|
|
178
187
|
const { imported } = await call("import", { apiKey: process.env[name] });
|
|
179
188
|
console.log(
|
|
180
189
|
imported.length
|
|
181
|
-
? `Brought in ${imported.join(", ")}. Name each one's website:
|
|
190
|
+
? `Brought in ${imported.join(", ")}. Name each one's website: ${relayCommand()} vault hosts <name> <host>`
|
|
182
191
|
: "Nothing new to bring in."
|
|
183
192
|
);
|
|
184
193
|
return;
|
package/lib/vaultTools.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// use_secret, one definition for every agent: the swarm's agents through their stdio MCP (mcp-stdio.mjs) and Harness's
|
|
2
|
-
// own chat through the person's browser (
|
|
2
|
+
// own chat through the person's browser (the Harness app's copy of this tool). The daemon's vault (vault.mjs)
|
|
3
3
|
// answers it; plain JavaScript so the app and the published cli/ share it.
|
|
4
4
|
export const USE_SECRET_TOOL = {
|
|
5
5
|
name: "use_secret",
|
|
6
6
|
description:
|
|
7
|
-
"Call a website's API with one of the person's secrets (an API key, a token, a password) without ever seeing it. Write {{secret:name}} where it goes in
|
|
7
|
+
"Call a website's API with one of the person's secrets (an API key, a token, a password) without ever seeing it. Write {{secret:name}} where it goes: in a header, or in the url or the body only where that secret may go there (list shows each one's places); Harness Relay on the person's computer puts the value in, sends the request only to the websites the person allowed for that secret, and gives you the answer with the value replaced by [secret:name]. If the secret is missing or you may not use it yet, the person is asked: tell them, and try again once they have. list: true shows the secrets you may use and where. Never ask the person to paste a secret into the chat.",
|
|
8
8
|
inputSchema: {
|
|
9
9
|
type: "object",
|
|
10
10
|
properties: {
|
package/lib/verdicts.mjs
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { laneHead, containsCommit, personChanges } from "./projectGit.mjs";
|
|
3
|
+
import { verdictEntriesByRun } from "./record.mjs";
|
|
4
|
+
import { nameOf } from "./members.mjs";
|
|
5
|
+
|
|
6
|
+
const reasonLine = (value) => {
|
|
7
|
+
const reason = typeof value === "string" ? value.trim() : "";
|
|
8
|
+
if (!reason || /[\r\n]/.test(reason))
|
|
9
|
+
throw new Error("Say what should change in one line.");
|
|
10
|
+
return reason;
|
|
11
|
+
};
|
|
12
|
+
const acceptance = (verdict) =>
|
|
13
|
+
verdict === "approves" || verdict === "approves_with_changes";
|
|
14
|
+
|
|
15
|
+
/** Returned results, their judgments and return to Make. Counts stay in board_reactions on this person's computer. */
|
|
16
|
+
export function createVerdicts({
|
|
17
|
+
store,
|
|
18
|
+
log = () => {},
|
|
19
|
+
projects,
|
|
20
|
+
team,
|
|
21
|
+
wakeRun,
|
|
22
|
+
}) {
|
|
23
|
+
const context = (request) => projects()?.verdictContext(request);
|
|
24
|
+
const own = (entry) => Boolean(entry) && entry.work.side === entry.project.me;
|
|
25
|
+
const belongs = (entry, task) =>
|
|
26
|
+
own(entry) &&
|
|
27
|
+
(!entry.where ||
|
|
28
|
+
(task.run_workspace &&
|
|
29
|
+
path.resolve(task.run_workspace) === path.resolve(entry.where)));
|
|
30
|
+
const runsOf = (entry) => store.threadRuns(entry.project.roomId);
|
|
31
|
+
const runOf = (entry) => {
|
|
32
|
+
const id = entry.work.body.returned?.run;
|
|
33
|
+
return id ? store.getTask(id) : null;
|
|
34
|
+
};
|
|
35
|
+
const changesOf = (entry) => {
|
|
36
|
+
const returned = entry.work.body.returned;
|
|
37
|
+
if (!entry.where || !returned?.commit) return [];
|
|
38
|
+
return personChanges(entry.where, returned.commit, runsOf(entry));
|
|
39
|
+
};
|
|
40
|
+
const latest = (run) =>
|
|
41
|
+
run ? (verdictEntriesByRun(store).get(run.id) ?? null) : null;
|
|
42
|
+
|
|
43
|
+
const started = (task) => {
|
|
44
|
+
if (!task.parent_id || store.meta(`review:${task.id}`) === "1") return;
|
|
45
|
+
const previous = store.getTask(task.id)?.returned;
|
|
46
|
+
const start = previous?.start ?? laneHead(task.run_workspace);
|
|
47
|
+
const entry = context({
|
|
48
|
+
id: task.parent_id,
|
|
49
|
+
agent: task.target_agent,
|
|
50
|
+
run: task.id,
|
|
51
|
+
before: store.getTask(task.id)?.claimed_at,
|
|
52
|
+
});
|
|
53
|
+
store.setRunReturned(task.id, {
|
|
54
|
+
start,
|
|
55
|
+
commit: null,
|
|
56
|
+
work: belongs(entry, task) ? entry.work.id : null,
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// Called after landing at report_task and at run end. An agent's own commits count even when landing had no diff.
|
|
61
|
+
const returned = (task) => {
|
|
62
|
+
if (!task.parent_id || store.meta(`review:${task.id}`) === "1") return;
|
|
63
|
+
const previous = store.getTask(task.id)?.returned;
|
|
64
|
+
const entry = context({
|
|
65
|
+
id: task.parent_id,
|
|
66
|
+
work: previous?.work,
|
|
67
|
+
agent: task.target_agent,
|
|
68
|
+
run: task.id,
|
|
69
|
+
before: store.getTask(task.id)?.claimed_at,
|
|
70
|
+
});
|
|
71
|
+
const commit = laneHead(task.run_workspace);
|
|
72
|
+
const span = { ...previous, commit };
|
|
73
|
+
store.setRunReturned(task.id, span);
|
|
74
|
+
if (!belongs(entry, task)) return;
|
|
75
|
+
const old = entry.work.body.returned;
|
|
76
|
+
if (old?.run === task.id && old.commit === commit) return;
|
|
77
|
+
entry.update({
|
|
78
|
+
returned: { run: task.id, commit },
|
|
79
|
+
...(old?.run === task.id ? {} : { verdict: null }),
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const judge = (entry, action, reason, source) => {
|
|
84
|
+
if (!own(entry)) throw new Error("You judge only your own agents' work.");
|
|
85
|
+
if (entry.project.status !== "open")
|
|
86
|
+
throw new Error("This shared room is not open.");
|
|
87
|
+
const run = runOf(entry);
|
|
88
|
+
if (!run?.reported_at || !["done", "failed"].includes(run.status))
|
|
89
|
+
throw new Error("Wait for the agent to return the result.");
|
|
90
|
+
if (action !== "accept" && action !== "send_back")
|
|
91
|
+
throw new Error("Choose Accept or Send back.");
|
|
92
|
+
const prior = latest(run);
|
|
93
|
+
if (source === "detected" && prior && prior.source !== "detected")
|
|
94
|
+
return { ok: true };
|
|
95
|
+
if (
|
|
96
|
+
source === "detected" &&
|
|
97
|
+
prior &&
|
|
98
|
+
acceptance(prior.verdict) &&
|
|
99
|
+
action === "accept"
|
|
100
|
+
)
|
|
101
|
+
return { ok: true };
|
|
102
|
+
const why = action === "send_back" ? reasonLine(reason) : null;
|
|
103
|
+
const changed = action === "accept" ? changesOf(entry) : [];
|
|
104
|
+
const verdict =
|
|
105
|
+
action === "send_back"
|
|
106
|
+
? "rejects"
|
|
107
|
+
: changed.length
|
|
108
|
+
? "approves_with_changes"
|
|
109
|
+
: "approves";
|
|
110
|
+
if (
|
|
111
|
+
source === "detected" &&
|
|
112
|
+
prior?.verdict === verdict &&
|
|
113
|
+
prior.reason === why
|
|
114
|
+
)
|
|
115
|
+
return { ok: true };
|
|
116
|
+
store.recordReaction({
|
|
117
|
+
postId: `verdict:${source}:${run.id}`,
|
|
118
|
+
goalId: entry.project.roomId,
|
|
119
|
+
postSeq: 0,
|
|
120
|
+
aboutSeq: null,
|
|
121
|
+
agent: run.claimed_by ?? run.target_agent,
|
|
122
|
+
verdict,
|
|
123
|
+
judgments: null,
|
|
124
|
+
runId: run.id,
|
|
125
|
+
source,
|
|
126
|
+
reason: why,
|
|
127
|
+
});
|
|
128
|
+
entry.update({
|
|
129
|
+
verdict: {
|
|
130
|
+
state: acceptance(verdict) ? "accepted" : "sent_back",
|
|
131
|
+
verdict,
|
|
132
|
+
reason: why,
|
|
133
|
+
source,
|
|
134
|
+
run: run.id,
|
|
135
|
+
changedFiles: changed.length,
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
if (
|
|
139
|
+
action === "send_back" &&
|
|
140
|
+
!(prior?.verdict === "rejects" && prior.reason === why)
|
|
141
|
+
) {
|
|
142
|
+
team?.sendBack(entry.project.roomId, run.id);
|
|
143
|
+
entry.update({ status: "checking" });
|
|
144
|
+
// A detected review does not grant execution authority. The existing wake policy still decides whether it runs.
|
|
145
|
+
const next = wakeRun(
|
|
146
|
+
entry.project.roomId,
|
|
147
|
+
entry.work.body.agent,
|
|
148
|
+
`Return the result to Make. What should change: ${why}\n\nThe result: ${entry.work.body.summary}`,
|
|
149
|
+
{
|
|
150
|
+
asker: source === "explicit" ? "user" : "harness",
|
|
151
|
+
go: source === "explicit",
|
|
152
|
+
words: entry.work.body.summary,
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
if (typeof next === "string" && store.getTask(next))
|
|
156
|
+
store.setRunStep(next, { step: "make", specialty: run.specialty });
|
|
157
|
+
}
|
|
158
|
+
return { ok: true, verdict };
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const publishJudgment = (entry) => {
|
|
162
|
+
const run = runOf(entry);
|
|
163
|
+
const said = latest(run);
|
|
164
|
+
if (!said) return;
|
|
165
|
+
const verdict = {
|
|
166
|
+
state: acceptance(said.verdict) ? "accepted" : "sent_back",
|
|
167
|
+
verdict: said.verdict,
|
|
168
|
+
reason: said.reason ?? null,
|
|
169
|
+
source: said.source ?? "said",
|
|
170
|
+
run: run.id,
|
|
171
|
+
};
|
|
172
|
+
if (
|
|
173
|
+
Object.entries(verdict).some(
|
|
174
|
+
([key, value]) => entry.work.body.verdict?.[key] !== value
|
|
175
|
+
)
|
|
176
|
+
)
|
|
177
|
+
entry.update({ verdict: { ...entry.work.body.verdict, ...verdict } });
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const detect = async (request) => {
|
|
181
|
+
const entry = context(request);
|
|
182
|
+
if (
|
|
183
|
+
!own(entry) ||
|
|
184
|
+
!entry.work.body.returned ||
|
|
185
|
+
entry.project.status !== "open"
|
|
186
|
+
)
|
|
187
|
+
return;
|
|
188
|
+
publishJudgment(entry);
|
|
189
|
+
const run = runOf(entry);
|
|
190
|
+
if (!run?.reported_at || latest(run)?.source === "explicit") return;
|
|
191
|
+
const { pr, returned: result } = entry.work.body;
|
|
192
|
+
const fixedBy =
|
|
193
|
+
entry.where &&
|
|
194
|
+
result.commit &&
|
|
195
|
+
runsOf(entry).find(
|
|
196
|
+
(other) =>
|
|
197
|
+
other.id !== run.id &&
|
|
198
|
+
other.target_agent !== run.target_agent &&
|
|
199
|
+
other.returned?.commit &&
|
|
200
|
+
other.returned?.start &&
|
|
201
|
+
containsCommit(entry.where, result.commit, other.returned.start) &&
|
|
202
|
+
other.returned.start !== other.returned.commit &&
|
|
203
|
+
containsCommit(
|
|
204
|
+
entry.where,
|
|
205
|
+
other.returned.commit,
|
|
206
|
+
laneHead(entry.where)
|
|
207
|
+
)
|
|
208
|
+
);
|
|
209
|
+
if (fixedBy) {
|
|
210
|
+
judge(
|
|
211
|
+
entry,
|
|
212
|
+
"send_back",
|
|
213
|
+
`${nameOf(fixedBy.target_agent)} changed the returned result.`,
|
|
214
|
+
"detected"
|
|
215
|
+
);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const merged =
|
|
219
|
+
entry.work.body.status === "merged" ||
|
|
220
|
+
(result.commit &&
|
|
221
|
+
result.commit !== entry.work.body.base &&
|
|
222
|
+
containsCommit(
|
|
223
|
+
entry.project.folder,
|
|
224
|
+
result.commit,
|
|
225
|
+
entry.project.repo.head
|
|
226
|
+
));
|
|
227
|
+
const reviewed =
|
|
228
|
+
!pr?.review?.commit ||
|
|
229
|
+
pr.review.commit === result.commit ||
|
|
230
|
+
containsCommit(entry.where, result.commit, pr.review.commit);
|
|
231
|
+
if (merged || (reviewed && pr?.reviewDecision === "APPROVED")) {
|
|
232
|
+
judge(entry, "accept", null, "detected");
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (
|
|
236
|
+
reviewed &&
|
|
237
|
+
pr?.reviewDecision === "CHANGES_REQUESTED" &&
|
|
238
|
+
pr.review?.body?.trim()
|
|
239
|
+
) {
|
|
240
|
+
judge(
|
|
241
|
+
entry,
|
|
242
|
+
"send_back",
|
|
243
|
+
pr.review.body.replace(/\s+/g, " ").trim(),
|
|
244
|
+
"detected"
|
|
245
|
+
);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const heard = (goalId, agents) => {
|
|
251
|
+
const reports = store.threadReports();
|
|
252
|
+
for (const agent of agents) {
|
|
253
|
+
const run = reports.findLast(
|
|
254
|
+
(run) => run.goal_id === goalId && run.agent === agent
|
|
255
|
+
);
|
|
256
|
+
const entry = context({ id: goalId, agent, run: run?.id });
|
|
257
|
+
if (own(entry)) publishJudgment(entry);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
const command = (request, agent) => {
|
|
262
|
+
if (agent !== "user")
|
|
263
|
+
return { ok: false, error: "Only the person gives a verdict." };
|
|
264
|
+
try {
|
|
265
|
+
const entry = context(request);
|
|
266
|
+
if (!entry) throw new Error("That result was not found.");
|
|
267
|
+
// A stale button must never judge a newer result by the same agent.
|
|
268
|
+
if (request.run !== entry.work.body.returned?.run)
|
|
269
|
+
throw new Error(
|
|
270
|
+
"The result changed. Read it again before giving a verdict."
|
|
271
|
+
);
|
|
272
|
+
return judge(entry, request.action, request.reason, "explicit");
|
|
273
|
+
} catch (error) {
|
|
274
|
+
log(`verdict: ${error.message}`);
|
|
275
|
+
return { ok: false, error: error.message };
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const view = (p, work, where) => {
|
|
280
|
+
const result = work.body.returned;
|
|
281
|
+
if (!result) return {};
|
|
282
|
+
const mine = work.side === p.me;
|
|
283
|
+
const run = mine ? store.getTask(result.run) : null;
|
|
284
|
+
if (mine && !run?.reported_at) return {};
|
|
285
|
+
const judgment = mine ? latest(run) : null;
|
|
286
|
+
const verdict =
|
|
287
|
+
mine && judgment
|
|
288
|
+
? {
|
|
289
|
+
state: acceptance(judgment.verdict) ? "accepted" : "sent_back",
|
|
290
|
+
verdict: judgment.verdict,
|
|
291
|
+
reason: judgment.reason,
|
|
292
|
+
source: judgment.source,
|
|
293
|
+
run: run.id,
|
|
294
|
+
}
|
|
295
|
+
: work.body.verdict;
|
|
296
|
+
const posts = mine ? store.roomPosts(p.roomId, 0, 500) : [];
|
|
297
|
+
const post = posts.findLast(
|
|
298
|
+
(post) =>
|
|
299
|
+
post.author === work.body.agent &&
|
|
300
|
+
["post", "result"].includes(post.kind) &&
|
|
301
|
+
post.created_at >= (run?.claimed_at ?? run?.created_at ?? "") &&
|
|
302
|
+
post.created_at <=
|
|
303
|
+
new Date(Date.parse(run.reported_at) + 5_000).toISOString()
|
|
304
|
+
);
|
|
305
|
+
const checked = run?.checked;
|
|
306
|
+
const different =
|
|
307
|
+
checked?.outcome &&
|
|
308
|
+
run?.run_model?.model &&
|
|
309
|
+
checked.by?.some((checker) => checker.model) &&
|
|
310
|
+
!checked.by.some((checker) => checker.model === run.run_model.model);
|
|
311
|
+
return {
|
|
312
|
+
returned: { run: result.run, reportSeq: post?.seq ?? null },
|
|
313
|
+
verdict: verdict ?? null,
|
|
314
|
+
changedFiles:
|
|
315
|
+
mine && where ? changesOf({ project: p, work, where }).length : 0,
|
|
316
|
+
checkedBy: different
|
|
317
|
+
? {
|
|
318
|
+
who: checked.by
|
|
319
|
+
.map((checker) => nameOf(checker.agent))
|
|
320
|
+
.join(" and "),
|
|
321
|
+
outcome: checked.outcome,
|
|
322
|
+
}
|
|
323
|
+
: null,
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
return { command, started, returned, detect, heard, view };
|
|
328
|
+
}
|
package/lib/wakes.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { paths } from "./paths.mjs";
|
|
|
11
11
|
// one's MCP servers and turns on its own local webhook with a secret made here; the daemon then wakes it when work is
|
|
12
12
|
// posted for it. The wake is fixed text: it names no task and grants nothing, and the agent reads its work over MCP.
|
|
13
13
|
// Their gateways listen on this computer, so the daemon sends and nothing is exposed to the internet.
|
|
14
|
-
// From their docs (October
|
|
14
|
+
// From their docs (October 2026), not yet run against the real apps.
|
|
15
15
|
|
|
16
16
|
export const LOCAL_WAKE_AGENTS = ["openclaw", "hermes"];
|
|
17
17
|
const COMMANDS = { openclaw: "openclaw", hermes: "hermes" };
|
package/lib/watches.mjs
CHANGED
|
@@ -6,8 +6,8 @@ import { randomUUID } from "node:crypto";
|
|
|
6
6
|
// field like "ageSeconds" or the count of lines matching a pattern like "critical") and compares it with a limit the
|
|
7
7
|
// watch names, or, without one, with its own usual range once it has enough history. A falling number with a floor gets
|
|
8
8
|
// a run-out estimate. Plain arithmetic, no model. An agent may suggest a watch; it runs only once the person starts it.
|
|
9
|
-
//
|
|
10
|
-
//
|
|
9
|
+
// One outage is why: a service's own health job logged "no recent successful keeper run" every 5 minutes for 41 hours
|
|
10
|
+
// and nobody saw it.
|
|
11
11
|
|
|
12
12
|
const HISTORY = 500;
|
|
13
13
|
const USUAL_AFTER = 12;
|