tryharness 0.7.45 → 0.7.53
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 +232 -12
- package/cli.mjs +406 -184
- package/lib/actorRoster.mjs +28 -5
- package/lib/adapters.mjs +9 -1
- package/lib/agentRuntimeConfig.mjs +36 -0
- package/lib/agentRuntimes.mjs +560 -0
- package/lib/atlas.mjs +7 -2
- package/lib/boardCommands.mjs +5 -10
- package/lib/boardFileCommands.mjs +2 -1
- package/lib/boardMirror.mjs +459 -0
- package/lib/boardProtocol.json +206 -6
- package/lib/boardTools.mjs +2 -6
- package/lib/bridge.mjs +25 -3
- package/lib/browserWake.mjs +60 -0
- package/lib/cards.mjs +35 -2
- package/lib/commands.mjs +20 -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/coordinator.mjs +8 -1
- package/lib/coreModels.mjs +78 -0
- package/lib/daemon.mjs +643 -45
- package/lib/desktop.mjs +7 -2
- package/lib/digest.mjs +32 -0
- package/lib/directLink.mjs +283 -0
- package/lib/environments.mjs +595 -0
- package/lib/folders.mjs +2 -2
- package/lib/goalCommands.mjs +58 -14
- package/lib/inference.mjs +263 -152
- package/lib/lessons.mjs +6 -0
- package/lib/lineup.mjs +324 -0
- 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 +121 -118
- package/lib/mcpRelay.mjs +119 -0
- package/lib/members.json +12 -0
- package/lib/members.mjs +33 -0
- package/lib/modelMemory.mjs +100 -0
- package/lib/modelTiers.json +1183 -0
- package/lib/modelTiers.mjs +133 -0
- package/lib/models.mjs +41 -8
- package/lib/museSession.mjs +119 -0
- package/lib/nativeHost.mjs +203 -0
- package/lib/network.mjs +7 -2
- package/lib/nudge.mjs +10 -2
- package/lib/onboard.mjs +430 -1
- package/lib/oneclawLocal.mjs +150 -0
- package/lib/ownMachines.mjs +521 -36
- package/lib/pairing.mjs +165 -0
- package/lib/paths.mjs +4 -0
- package/lib/phones.mjs +61 -0
- package/lib/placeCommands.mjs +27 -0
- package/lib/places.mjs +10 -2
- package/lib/plans.mjs +151 -27
- package/lib/profile.mjs +152 -0
- package/lib/projects.mjs +624 -137
- package/lib/readiness.mjs +283 -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 +20 -7
- package/lib/runner.mjs +67 -8
- 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 +10 -8
- package/lib/sessionIndex.mjs +5 -3
- package/lib/store.mjs +546 -29
- package/lib/subagents.mjs +8 -4
- package/lib/swarm.mjs +367 -37
- package/lib/swarmMemory.mjs +947 -0
- package/lib/t3.mjs +43 -13
- package/lib/taskCommands.mjs +56 -5
- package/lib/taskRuns.mjs +61 -11
- package/lib/team.json +17 -15
- package/lib/team.mjs +68 -18
- package/lib/threadRuns.mjs +3 -1
- package/lib/threadView.mjs +51 -14
- 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/package.json +9 -4
package/lib/profile.mjs
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import pc from "picocolors";
|
|
3
|
+
import { readJson, writeJsonAtomic } from "./files.mjs";
|
|
4
|
+
import { paths } from "./paths.mjs";
|
|
5
|
+
|
|
6
|
+
// The person's Harness profile on this computer: their name and how they like to work, so every agent here knows who
|
|
7
|
+
// it works for. The profile is the account's, one for all their computers: Harness sends it to the daemon when it
|
|
8
|
+
// connects and whenever it changes anywhere (src/server/bridge/profilePush.ts), and the daemon keeps it here. Setup
|
|
9
|
+
// imports it too, and when the account has no name yet, asks for one and saves it to the account. Each run's brief
|
|
10
|
+
// carries it (runBrief.mjs). The saved copy holds only what the server shares with a computer.
|
|
11
|
+
|
|
12
|
+
const NAME_LIMIT = 80;
|
|
13
|
+
const PREFERENCE_LIMIT = 200;
|
|
14
|
+
|
|
15
|
+
/** The account's profile as this computer last had it, or null. */
|
|
16
|
+
export function readProfile(file = paths.profile) {
|
|
17
|
+
const saved = readJson(file, null);
|
|
18
|
+
return saved?.displayName ? saved : null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Keeps the account's profile as Harness sent it; one without a name leaves this computer with none. */
|
|
22
|
+
export function keepProfile(profile, file = paths.profile) {
|
|
23
|
+
if (profile?.displayName) writeJsonAtomic(file, profile);
|
|
24
|
+
else fs.rmSync(file, { force: true });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function request(origin, token, init = {}) {
|
|
28
|
+
const response = await fetch(
|
|
29
|
+
`${String(origin).replace(/\/$/, "")}/api/mcp/profile`,
|
|
30
|
+
{
|
|
31
|
+
...init,
|
|
32
|
+
headers: {
|
|
33
|
+
authorization: `Bearer ${token}`,
|
|
34
|
+
"content-type": "application/json",
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
const body = await response.json().catch(() => null);
|
|
39
|
+
if (!response.ok)
|
|
40
|
+
throw Object.assign(
|
|
41
|
+
new Error(body?.error || `Harness answered ${response.status}`),
|
|
42
|
+
{ status: response.status }
|
|
43
|
+
);
|
|
44
|
+
return body?.profile ?? {};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const preferenceCount = (profile) =>
|
|
48
|
+
(profile.hardPreferences?.length ?? 0) +
|
|
49
|
+
(profile.softPreferences?.length ?? 0);
|
|
50
|
+
|
|
51
|
+
const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
52
|
+
|
|
53
|
+
async function ask(ui, profile) {
|
|
54
|
+
ui.note(
|
|
55
|
+
"Your agents work for you, so they should know who you are. What you write here is saved to your Harness account, so Harness and the agents on all your computers use it. Change it any time in Harness, Settings, Profile.",
|
|
56
|
+
"About you"
|
|
57
|
+
);
|
|
58
|
+
const name = await ui.text({
|
|
59
|
+
message: "What should your agents call you?",
|
|
60
|
+
validate: (value) =>
|
|
61
|
+
String(value ?? "").trim().length > NAME_LIMIT
|
|
62
|
+
? `Keep it under ${NAME_LIMIT} characters`
|
|
63
|
+
: undefined,
|
|
64
|
+
});
|
|
65
|
+
const displayName = String(name ?? "").trim();
|
|
66
|
+
if (!displayName) return null;
|
|
67
|
+
const update = { displayName };
|
|
68
|
+
if (!preferenceCount(profile)) {
|
|
69
|
+
const said = await ui.text({
|
|
70
|
+
message:
|
|
71
|
+
"Anything they should always keep in mind about how you work? Press Enter to skip.",
|
|
72
|
+
placeholder: "Keep answers short, and ask before deleting anything",
|
|
73
|
+
validate: (value) =>
|
|
74
|
+
String(value ?? "").trim().length > PREFERENCE_LIMIT
|
|
75
|
+
? `Keep it under ${PREFERENCE_LIMIT} characters`
|
|
76
|
+
: undefined,
|
|
77
|
+
});
|
|
78
|
+
const preference = String(said ?? "").trim();
|
|
79
|
+
if (preference) update.hardPreferences = [preference];
|
|
80
|
+
}
|
|
81
|
+
return update;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Setup's step: imports the person's profile into this computer, asking for their name (and one preference, when they
|
|
86
|
+
* have none) if their account has no name yet. Never stops setup: a profile Harness cannot give leaves the last import.
|
|
87
|
+
*/
|
|
88
|
+
export async function setupProfile({
|
|
89
|
+
ui,
|
|
90
|
+
origin,
|
|
91
|
+
token,
|
|
92
|
+
file = paths.profile,
|
|
93
|
+
}) {
|
|
94
|
+
let profile;
|
|
95
|
+
try {
|
|
96
|
+
profile = await request(origin, token);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
// A Harness from before profiles reached computers has no such page: nothing is wrong, so nothing is said.
|
|
99
|
+
if (error.status === 404) return readProfile(file);
|
|
100
|
+
ui.warn(
|
|
101
|
+
`Your Harness profile did not load (${error.message}). Your agents will learn your name the next time you run setup.`
|
|
102
|
+
);
|
|
103
|
+
return readProfile(file);
|
|
104
|
+
}
|
|
105
|
+
if (!profile.displayName) {
|
|
106
|
+
const update = ui.interactive ? await ask(ui, profile) : null;
|
|
107
|
+
if (!update) {
|
|
108
|
+
ui.info(
|
|
109
|
+
"Your agents will not know your name yet. Add it any time in Harness, Settings, Profile, then run setup again."
|
|
110
|
+
);
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
profile = await request(origin, token, {
|
|
115
|
+
method: "PUT",
|
|
116
|
+
body: JSON.stringify(update),
|
|
117
|
+
});
|
|
118
|
+
} catch (error) {
|
|
119
|
+
// The agents here still get it; the next setup, finding no name in the account, asks again.
|
|
120
|
+
profile = { ...profile, ...update };
|
|
121
|
+
ui.warn(
|
|
122
|
+
`Saved on this computer, but not to your Harness account yet (${error.message}).`
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
writeJsonAtomic(file, profile);
|
|
127
|
+
const count = preferenceCount(profile);
|
|
128
|
+
ui.success(
|
|
129
|
+
`Your agents know you as ${pc.bold(profile.displayName)}${count ? `, with your ${plural(count, "preference")} from Harness` : ""}`
|
|
130
|
+
);
|
|
131
|
+
return profile;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** The profile as an agent is told it at the start of a run; empty without one. */
|
|
135
|
+
export function profileBrief(profile = readProfile()) {
|
|
136
|
+
if (!profile?.displayName) return "";
|
|
137
|
+
const lines = [
|
|
138
|
+
`You are working for ${profile.displayName}${profile.role ? `, ${profile.role}` : ""}. From their Harness profile:`,
|
|
139
|
+
];
|
|
140
|
+
if (profile.communicationStyle)
|
|
141
|
+
lines.push(`- They prefer ${profile.communicationStyle} communication.`);
|
|
142
|
+
const hard = profile.hardPreferences ?? [];
|
|
143
|
+
const soft = profile.softPreferences ?? [];
|
|
144
|
+
if (hard.length)
|
|
145
|
+
lines.push("Always follow:", ...hard.map((item) => `- ${item}`));
|
|
146
|
+
if (soft.length)
|
|
147
|
+
lines.push(
|
|
148
|
+
"When in doubt, they prefer:",
|
|
149
|
+
...soft.map((item) => `- ${item}`)
|
|
150
|
+
);
|
|
151
|
+
return lines.join("\n");
|
|
152
|
+
}
|