tryharness 0.7.44 → 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.
Files changed (101) hide show
  1. package/README.md +232 -12
  2. package/cli.mjs +406 -184
  3. package/lib/actorRoster.mjs +28 -5
  4. package/lib/adapters.mjs +9 -1
  5. package/lib/agentRuntimeConfig.mjs +36 -0
  6. package/lib/agentRuntimes.mjs +560 -0
  7. package/lib/atlas.mjs +7 -2
  8. package/lib/boardCommands.mjs +5 -10
  9. package/lib/boardFileCommands.mjs +2 -1
  10. package/lib/boardMirror.mjs +459 -0
  11. package/lib/boardProtocol.json +259 -6
  12. package/lib/boardTools.mjs +2 -6
  13. package/lib/bridge.mjs +27 -3
  14. package/lib/browserWake.mjs +60 -0
  15. package/lib/cards.mjs +35 -2
  16. package/lib/commands.mjs +20 -5
  17. package/lib/connectionTools.d.ts +13 -0
  18. package/lib/connectionTools.js +45 -0
  19. package/lib/connectorAuth.mjs +309 -0
  20. package/lib/connectorCatalog.json +41 -0
  21. package/lib/connectorCommands.mjs +121 -0
  22. package/lib/connectorGoogle.mjs +513 -0
  23. package/lib/connectors.mjs +805 -0
  24. package/lib/coordinator.mjs +16 -2
  25. package/lib/coreModels.mjs +78 -0
  26. package/lib/daemon.mjs +775 -46
  27. package/lib/desktop.mjs +7 -2
  28. package/lib/digest.mjs +32 -0
  29. package/lib/directLink.mjs +283 -0
  30. package/lib/environments.mjs +595 -0
  31. package/lib/folders.mjs +2 -2
  32. package/lib/goalCommands.mjs +61 -12
  33. package/lib/inference.mjs +263 -152
  34. package/lib/lessons.mjs +6 -0
  35. package/lib/lineup.mjs +324 -0
  36. package/lib/localmodels.mjs +10 -0
  37. package/lib/machineIdentity.mjs +3 -0
  38. package/lib/machineRoutes.mjs +40 -2
  39. package/lib/machineRuns.mjs +30 -3
  40. package/lib/machineSeal.mjs +69 -10
  41. package/lib/mcp-stdio.mjs +180 -98
  42. package/lib/mcpRelay.mjs +119 -0
  43. package/lib/members.json +12 -0
  44. package/lib/members.mjs +33 -0
  45. package/lib/modelMemory.mjs +100 -0
  46. package/lib/modelTiers.json +1183 -0
  47. package/lib/modelTiers.mjs +133 -0
  48. package/lib/models.mjs +41 -8
  49. package/lib/museSession.mjs +119 -0
  50. package/lib/nativeHost.mjs +203 -0
  51. package/lib/network.mjs +38 -1
  52. package/lib/nudge.mjs +10 -2
  53. package/lib/onboard.mjs +430 -1
  54. package/lib/oneclawLocal.mjs +150 -0
  55. package/lib/ownMachines.mjs +521 -36
  56. package/lib/pairing.mjs +165 -0
  57. package/lib/paths.mjs +4 -0
  58. package/lib/phones.mjs +61 -0
  59. package/lib/placeCommands.mjs +27 -0
  60. package/lib/places.mjs +10 -2
  61. package/lib/plans.mjs +151 -27
  62. package/lib/profile.mjs +152 -0
  63. package/lib/projectGit.mjs +328 -0
  64. package/lib/projectSettings.mjs +120 -0
  65. package/lib/projects.mjs +2539 -0
  66. package/lib/readiness.mjs +283 -0
  67. package/lib/repoLinks.mjs +354 -0
  68. package/lib/roomChannels.mjs +641 -0
  69. package/lib/runBrief.mjs +32 -2
  70. package/lib/runRequests.mjs +157 -0
  71. package/lib/runWorker.mjs +20 -7
  72. package/lib/runner.mjs +67 -8
  73. package/lib/secretPatterns.json +55 -0
  74. package/lib/secrets.mjs +10 -27
  75. package/lib/seen.mjs +102 -0
  76. package/lib/service.mjs +11 -6
  77. package/lib/sessionControl.mjs +10 -8
  78. package/lib/sessionIndex.mjs +5 -3
  79. package/lib/store.mjs +559 -30
  80. package/lib/subagents.mjs +8 -4
  81. package/lib/swarm.mjs +379 -38
  82. package/lib/swarmMemory.mjs +947 -0
  83. package/lib/t3.mjs +43 -13
  84. package/lib/taskCommands.mjs +58 -5
  85. package/lib/taskRuns.mjs +61 -11
  86. package/lib/team.json +17 -15
  87. package/lib/team.mjs +68 -18
  88. package/lib/threadRuns.mjs +50 -7
  89. package/lib/threadView.mjs +68 -15
  90. package/lib/tokenizer.mjs +405 -0
  91. package/lib/ui.mjs +16 -2
  92. package/lib/usageTotals.mjs +148 -0
  93. package/lib/vault.mjs +1144 -0
  94. package/lib/vaultCloud.mjs +117 -0
  95. package/lib/vaultCommands.mjs +201 -0
  96. package/lib/vaultTools.d.ts +12 -0
  97. package/lib/vaultTools.js +42 -0
  98. package/lib/windowAsks.mjs +42 -0
  99. package/lib/workFocus.mjs +59 -0
  100. package/lib/workLinks.mjs +90 -0
  101. package/package.json +9 -4
@@ -0,0 +1,117 @@
1
+ // The 1claw API, as the relay's vault uses it for the person's backup (vault.mjs). Shapes from @1claw/openapi-spec
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 (AGENTS.md), so a call lasts
4
+ // until 1claw answers or the caller gives up.
5
+
6
+ export const ONECLAW_API = "https://api.1claw.co";
7
+
8
+ /** An answer from 1claw that is not a success, with what 1claw said. */
9
+ export class OneclawError extends Error {
10
+ constructor(status, detail, type) {
11
+ super(detail || `1claw answered ${status}`);
12
+ this.status = status;
13
+ this.type = type ?? null;
14
+ }
15
+ }
16
+
17
+ export function createOneclawCloud({
18
+ base = ONECLAW_API,
19
+ fetch = globalThis.fetch,
20
+ } = {}) {
21
+ const root = base.replace(/\/+$/, "");
22
+ const call = async (method, path, { token, body } = {}) => {
23
+ const response = await fetch(`${root}/v1${path}`, {
24
+ method,
25
+ headers: {
26
+ ...(body === undefined ? {} : { "content-type": "application/json" }),
27
+ ...(token ? { authorization: `Bearer ${token}` } : {}),
28
+ },
29
+ ...(body === undefined ? {} : { body: JSON.stringify(body) }),
30
+ });
31
+ const text = await response.text();
32
+ let value = null;
33
+ try {
34
+ value = text ? JSON.parse(text) : null;
35
+ } catch {}
36
+ if (!response.ok)
37
+ throw new OneclawError(
38
+ response.status,
39
+ value?.detail ?? value?.error ?? value?.message ?? text.slice(0, 200),
40
+ value?.type
41
+ );
42
+ return value;
43
+ };
44
+ const secretPath = (path) =>
45
+ path.split("/").map(encodeURIComponent).join("/");
46
+ // A signed-in person (the device flow's token) or this computer's agent (its exchanged token).
47
+ const as = (token) => ({
48
+ vaults: async () => (await call("GET", "/vaults", { token }))?.vaults ?? [],
49
+ createVault: (name, description) =>
50
+ call("POST", "/vaults", { token, body: { name, description } }),
51
+ agents: async () => (await call("GET", "/agents", { token }))?.agents ?? [],
52
+ createAgent: (name, description) =>
53
+ call("POST", "/agents", {
54
+ token,
55
+ body: {
56
+ name,
57
+ description,
58
+ auth_method: "api_key",
59
+ skip_default_policy: true,
60
+ },
61
+ }),
62
+ rotateKey: (agentId) =>
63
+ call("POST", `/agents/${agentId}/rotate-key`, { token }),
64
+ bindVault: (agentId, vaultId) =>
65
+ call("PATCH", `/agents/${agentId}`, {
66
+ token,
67
+ body: { vault_ids: [vaultId] },
68
+ }),
69
+ grantAgent: (vaultId, agentId) =>
70
+ call("POST", `/vaults/${vaultId}/policies`, {
71
+ token,
72
+ body: {
73
+ secret_path_pattern: "**",
74
+ principal_type: "agent",
75
+ principal_id: agentId,
76
+ permissions: ["read", "write", "delete"],
77
+ },
78
+ }),
79
+ secrets: async (vaultId) =>
80
+ (await call("GET", `/vaults/${vaultId}/secrets`, { token }))?.secrets ??
81
+ [],
82
+ secret: (vaultId, path) =>
83
+ call("GET", `/vaults/${vaultId}/secrets/${secretPath(path)}`, { token }),
84
+ putSecret: (vaultId, path, body) =>
85
+ call("PUT", `/vaults/${vaultId}/secrets/${secretPath(path)}`, {
86
+ token,
87
+ body,
88
+ }),
89
+ deleteSecret: (vaultId, path) =>
90
+ call("DELETE", `/vaults/${vaultId}/secrets/${secretPath(path)}`, {
91
+ token,
92
+ }),
93
+ share: (secretId, body) =>
94
+ call("POST", `/secrets/${secretId}/share`, { token, body }),
95
+ unshare: (shareId) => call("DELETE", `/share/${shareId}`, { token }),
96
+ });
97
+ return {
98
+ base: root,
99
+ // Where the person approves a sign-in code: the dashboard beside the API (api.1claw.co → 1claw.co).
100
+ verifyUrl: (code) =>
101
+ `${root.replace("://api.", "://")}/cli/verify?code=${encodeURIComponent(code)}`,
102
+ deviceCode: (email) =>
103
+ call("POST", "/auth/device/code", {
104
+ body: { client_id: "harness", email },
105
+ }),
106
+ deviceToken: (deviceCode) =>
107
+ call("POST", "/auth/device/token", {
108
+ body: {
109
+ device_code: deviceCode,
110
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
111
+ },
112
+ }),
113
+ agentToken: (apiKey) =>
114
+ call("POST", "/auth/agent-token", { body: { api_key: apiKey } }),
115
+ as,
116
+ };
117
+ }
@@ -0,0 +1,201 @@
1
+ import { daemonRequest } from "./control-client.mjs";
2
+
3
+ // `npx tryharness vault`: the person's vault in this computer's relay (vault.mjs), from the terminal. A value is
4
+ // typed at a hidden prompt, piped in, or named by an environment variable; never written on the command line, where
5
+ // the shell's history would keep it.
6
+
7
+ const USAGE = `vault what is kept, who is asking, who may use what, and the backup
8
+ vault add <name> --hosts api.fly.io[,...] [--value-env NAME] keep a secret (typed hidden, piped, or from NAME)
9
+ vault hosts <name> <host,...> change where it may be sent
10
+ vault remove <name>
11
+ vault allow <agent> <name> let an agent use it (the relay sends it; the agent never sees it)
12
+ vault runs <agent> <name> <VARIABLE> [--elsewhere] put it in the agent's runs (it can read it there)
13
+ vault revoke <grant id>
14
+ vault backup <email> [--bring-in] keep a copy in your 1claw account (the email you sign in with; a new one makes an account)
15
+ vault backup sync | vault backup off
16
+ vault import --key-env NAME bring in what a 1claw agent key (ocv_) can read; the key is not kept
17
+ vault share <name> [--hours 24] [--uses 1] a 1claw link, for an agent outside your swarm`;
18
+
19
+ /** A value typed without showing it, or piped in. */
20
+ async function hiddenValue(prompt) {
21
+ const input = process.stdin;
22
+ if (!input.isTTY) {
23
+ let piped = "";
24
+ for await (const chunk of input) piped += chunk;
25
+ return piped.replace(/\r?\n$/, "");
26
+ }
27
+ process.stdout.write(prompt);
28
+ input.setRawMode(true);
29
+ input.resume();
30
+ input.setEncoding("utf8");
31
+ return new Promise((resolve, reject) => {
32
+ let value = "";
33
+ const done = (error) => {
34
+ input.setRawMode(false);
35
+ input.pause();
36
+ input.removeListener("data", onData);
37
+ process.stdout.write("\n");
38
+ error ? reject(error) : resolve(value);
39
+ };
40
+ const onData = (chunk) => {
41
+ for (const character of chunk) {
42
+ if (character === "\r" || character === "\n") return done();
43
+ if (character === "\u0003") return done(new Error("cancelled"));
44
+ if (character === "\u007f") value = value.slice(0, -1);
45
+ else value += character;
46
+ }
47
+ };
48
+ input.on("data", onData);
49
+ });
50
+ }
51
+
52
+ export async function vaultCommands(argv) {
53
+ const option = (name) => {
54
+ const at = argv.indexOf(name);
55
+ return at < 0 ? null : argv[at + 1];
56
+ };
57
+ const call = async (action, fields = {}) => {
58
+ const reply = await daemonRequest({
59
+ command: `board.vault.${action}`,
60
+ agent: "user",
61
+ ...fields,
62
+ });
63
+ if (!reply.ok) throw new Error(reply.error || "the vault refused");
64
+ return reply;
65
+ };
66
+ const [action = "list", first, second, third] = argv;
67
+ const hostsOf = (text) =>
68
+ String(text || "")
69
+ .split(",")
70
+ .map((host) => host.trim())
71
+ .filter(Boolean);
72
+
73
+ if (action === "list") {
74
+ const vault = await call("list");
75
+ for (const request of vault.requests)
76
+ console.log(
77
+ request.why === "missing"
78
+ ? `${request.agent} needs ${request.secret}${request.host ? ` for ${request.host}` : ""}: npx tryharness vault add ${request.secret} --hosts ${request.host ?? "<website>"}`
79
+ : `${request.agent} asks to use ${request.secret}: npx tryharness vault allow ${request.agent} ${request.secret}`
80
+ );
81
+ if (!vault.secrets.length) console.log("Nothing kept yet.");
82
+ for (const secret of vault.secrets)
83
+ console.log(
84
+ `${secret.name} ${secret.hosts.length ? `only sent to ${secret.hosts.join(", ")}` : "no website yet, so no agent can use it"}`
85
+ );
86
+ for (const grant of vault.grants)
87
+ console.log(
88
+ grant.mode === "use"
89
+ ? ` ${grant.agent} may use ${grant.secret} (${grant.id})`
90
+ : ` ${grant.secret} is in ${grant.agent}'s runs as ${grant.env}${grant.machines === "own" ? ", on your other computers too" : ""} (${grant.id})`
91
+ );
92
+ const backup = vault.backup;
93
+ console.log(
94
+ backup.status === "on"
95
+ ? `Backup: on, in 1claw (${backup.email}).`
96
+ : backup.status === "waiting"
97
+ ? `Backup: approve code ${backup.code} at ${backup.verifyUrl}`
98
+ : `Backup: ${backup.status}.${backup.message ? ` ${backup.message}` : ""}`
99
+ );
100
+ return;
101
+ }
102
+ if (action === "add") {
103
+ const name = first;
104
+ const fromEnv = option("--value-env");
105
+ if (fromEnv && !process.env[fromEnv])
106
+ throw new Error(`nothing is set in ${fromEnv}`);
107
+ const value = fromEnv
108
+ ? process.env[fromEnv]
109
+ : await hiddenValue(`Value for ${name} (hidden): `);
110
+ await call("save", { name, value, hosts: hostsOf(option("--hosts")) });
111
+ console.log(
112
+ `Kept ${name} on this computer${option("--hosts") ? `, only sent to ${hostsOf(option("--hosts")).join(", ")}` : ". Name its website before an agent uses it: npx tryharness vault hosts " + name + " <host>"}.`
113
+ );
114
+ return;
115
+ }
116
+ if (action === "hosts") {
117
+ await call("save", { name: first, value: "", hosts: hostsOf(second) });
118
+ console.log(`${first} is only sent to ${hostsOf(second).join(", ")}.`);
119
+ return;
120
+ }
121
+ if (action === "remove") {
122
+ await call("remove", { name: first });
123
+ console.log(`Removed ${first}.`);
124
+ return;
125
+ }
126
+ if (action === "allow") {
127
+ await call("grant", { forAgent: first, secret: second, mode: "use" });
128
+ console.log(`${first} may use ${second}.`);
129
+ return;
130
+ }
131
+ if (action === "runs") {
132
+ const elsewhere = argv.includes("--elsewhere");
133
+ await call("grant", {
134
+ forAgent: first,
135
+ secret: second,
136
+ mode: "env",
137
+ env: third,
138
+ machines: elsewhere ? "own" : "home",
139
+ });
140
+ console.log(
141
+ `${second} is in ${first}'s runs as ${third}${elsewhere ? ", on your other computers too" : ""}. ${first} can read it there; what its runs say is cleaned of it.`
142
+ );
143
+ return;
144
+ }
145
+ if (action === "revoke") {
146
+ await call("revoke", { id: first });
147
+ console.log("Removed.");
148
+ return;
149
+ }
150
+ if (action === "backup" && first === "sync") {
151
+ await call("backup.sync");
152
+ console.log("Backed up.");
153
+ return;
154
+ }
155
+ if (action === "backup" && first === "off") {
156
+ await call("backup.stop");
157
+ console.log(
158
+ "Backup is off. 1claw still holds the last copy; remove it there if you want it gone."
159
+ );
160
+ return;
161
+ }
162
+ if (action === "backup") {
163
+ const started = await call("backup.start", {
164
+ email: first,
165
+ bringIn: argv.includes("--bring-in"),
166
+ });
167
+ console.log(
168
+ `Approve code ${started.code} in 1claw: ${started.verifyUrl}\nWith no 1claw account, signing up with ${first} makes one. Then: npx tryharness vault`
169
+ );
170
+ return;
171
+ }
172
+ if (action === "import") {
173
+ const name = option("--key-env");
174
+ if (!name || !process.env[name])
175
+ throw new Error(
176
+ "put the 1claw key in an environment variable and name it: --key-env NAME"
177
+ );
178
+ const { imported } = await call("import", { apiKey: process.env[name] });
179
+ console.log(
180
+ imported.length
181
+ ? `Brought in ${imported.join(", ")}. Name each one's website: npx tryharness vault hosts <name> <host>`
182
+ : "Nothing new to bring in."
183
+ );
184
+ return;
185
+ }
186
+ if (action === "share") {
187
+ const hours = Number(option("--hours") || 24);
188
+ const uses = Number(option("--uses") || 1);
189
+ const { share } = await call("share", {
190
+ name: first,
191
+ to: "link",
192
+ expiresAt: new Date(Date.now() + hours * 3_600_000).toISOString(),
193
+ maxUses: uses,
194
+ });
195
+ console.log(
196
+ `${share.url}\nWorks ${uses === 1 ? "once" : `${uses} times`}, for ${hours === 1 ? "an hour" : `${hours} hours`}. Whoever has the link can read ${first}.`
197
+ );
198
+ return;
199
+ }
200
+ throw new Error(USAGE);
201
+ }
@@ -0,0 +1,12 @@
1
+ export declare const USE_SECRET_TOOL: {
2
+ name: "use_secret";
3
+ description: string;
4
+ inputSchema: Record<string, unknown>;
5
+ };
6
+ export function secretToolRequest(input: Record<string, unknown>): {
7
+ command: "board.vault.list" | "board.vault.use";
8
+ url?: string;
9
+ method?: string;
10
+ headers?: string[];
11
+ body?: string;
12
+ };
@@ -0,0 +1,42 @@
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 (src/runtime/client-channel/vaultTools.ts). The daemon's vault (vault.mjs)
3
+ // answers it; plain JavaScript so the app and the published cli/ share it.
4
+ export const USE_SECRET_TOOL = {
5
+ name: "use_secret",
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 the url, a header or the body; 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
+ inputSchema: {
9
+ type: "object",
10
+ properties: {
11
+ url: {
12
+ type: "string",
13
+ description: "https address, for example https://api.fly.io/v1/apps",
14
+ },
15
+ method: {
16
+ type: "string",
17
+ enum: ["GET", "POST", "PUT", "PATCH", "DELETE"],
18
+ },
19
+ headers: {
20
+ type: "array",
21
+ items: { type: "string" },
22
+ description:
23
+ 'Header lines, for example "Authorization: Bearer {{secret:fly-token}}"',
24
+ },
25
+ body: { type: "string" },
26
+ list: { type: "boolean", description: "show the secrets you may use" },
27
+ },
28
+ additionalProperties: false,
29
+ },
30
+ };
31
+
32
+ /** The daemon request a use_secret call makes. */
33
+ export function secretToolRequest(input) {
34
+ if (input.list === true) return { command: "board.vault.list" };
35
+ return {
36
+ command: "board.vault.use",
37
+ url: typeof input.url === "string" ? input.url : "",
38
+ method: typeof input.method === "string" ? input.method : undefined,
39
+ headers: Array.isArray(input.headers) ? input.headers.map(String) : [],
40
+ body: typeof input.body === "string" ? input.body : undefined,
41
+ };
42
+ }
@@ -0,0 +1,42 @@
1
+ // This computer asking the person's own Harness window for what only it holds (phones.mjs ask): this computer's own
2
+ // windows first, then those linked to each of the person's other computers (ownMachines.mjs). With no Harness window
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 (owner, October 22: the swarm reads what the
5
+ // person has seen from the hidden page). It is asked again as it comes up, until WAKE_DEADLINE_MS.
6
+
7
+ // How long to keep asking a woken hidden page: the owner's value (October 22: "lets go 1 min on the wait"). Measured
8
+ // only against a local app on loopback (e2e hidden-page-seen, run 20261022-161745-75cbcea9-f21f: closed page to
9
+ // answer 1.04 to 1.08 s, 5 samples on an M5 Pro), never against tryharness.ai.
10
+ export const WAKE_DEADLINE_MS = 60_000;
11
+ const ASK_EVERY_MS = 1_000;
12
+
13
+ export function createWindowAsks({
14
+ askOwn,
15
+ askWorkers = async () => null,
16
+ browserWake,
17
+ log = () => {},
18
+ now = () => Date.now(),
19
+ wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
20
+ }) {
21
+ const nobodyAt = (reply) =>
22
+ reply?.ok === false && ["unpaired", "closed"].includes(reply.code);
23
+ const askAnywhere = async (call) => {
24
+ const here = await askOwn(call);
25
+ return (nobodyAt(here) && (await askWorkers(call))) || here;
26
+ };
27
+
28
+ /** The window's answer to `call`, waking the hidden page when no window is open and a browser listens. */
29
+ return async function ask(call) {
30
+ const first = await askAnywhere(call);
31
+ if (first?.code !== "closed" || !browserWake?.listening()) return first;
32
+ browserWake.send({ kind: "window" });
33
+ log(`windows: none open, woke the browser for ${call.tool}`);
34
+ const until = now() + WAKE_DEADLINE_MS;
35
+ let reply = first;
36
+ while (reply?.code === "closed" && now() < until) {
37
+ await wait(ASK_EVERY_MS);
38
+ reply = await askAnywhere(call);
39
+ }
40
+ return reply;
41
+ };
42
+ }
@@ -0,0 +1,59 @@
1
+ import { createHash } from "node:crypto";
2
+
3
+ /** Following and read receipts belong to the work, so paired surfaces agree. */
4
+ export function createWorkFocus({ store }) {
5
+ const keyOf = (id) => `work-focus:${id}`;
6
+ const saved = (id) => JSON.parse(store.meta(keyOf(id)) || "{}");
7
+ // What the person can read: new words, a new question, the thread ending. Agents starting, stopping or queueing
8
+ // are not, so reading a thread while its agents work stays read.
9
+ const revisionOf = (thread) =>
10
+ createHash("sha256")
11
+ .update(
12
+ JSON.stringify([
13
+ thread.updatedAt,
14
+ thread.status,
15
+ thread.view?.needsYou,
16
+ thread.posts,
17
+ thread.last,
18
+ thread.activityVersion,
19
+ thread.relatedVersion,
20
+ ])
21
+ )
22
+ .digest("hex");
23
+ const decorate = (thread) => {
24
+ const receipt = saved(thread.id);
25
+ const following = receipt.following ?? !thread.source;
26
+ const revision = revisionOf(thread);
27
+ return {
28
+ ...thread,
29
+ focus: {
30
+ following,
31
+ revision,
32
+ changed: following && receipt.seen !== revision,
33
+ seenAt: receipt.seenAt ?? null,
34
+ },
35
+ };
36
+ };
37
+ const update = (thread, request) => {
38
+ const receipt = saved(thread.id);
39
+ if (request.command === "board.swarm.follow") {
40
+ if (typeof request.following !== "boolean")
41
+ return { ok: false, error: "Choose whether to follow this work." };
42
+ receipt.following = request.following;
43
+ } else {
44
+ const revision = revisionOf(thread);
45
+ if (request.revision !== revision)
46
+ return {
47
+ ok: false,
48
+ code: "changed",
49
+ error:
50
+ "This work changed since your check-in. Read the update first.",
51
+ };
52
+ receipt.seen = revision;
53
+ receipt.seenAt = new Date().toISOString();
54
+ }
55
+ store.meta(keyOf(thread.id), JSON.stringify(receipt));
56
+ return { ok: true, thread: decorate(thread) };
57
+ };
58
+ return { decorate, update };
59
+ }
@@ -0,0 +1,90 @@
1
+ import { createHash } from "node:crypto";
2
+
3
+ /** Private references beside an objective. No copied history, agent input or execution authority. */
4
+ export function createWorkLinks({ store, readWork }) {
5
+ const key = (id) => `work-links:${id}`;
6
+ const references = (id) => JSON.parse(store.meta(key(id)) || "[]");
7
+ const read = async (id) => {
8
+ const entries = await Promise.all(
9
+ references(id).map(async (sourceId) => {
10
+ try {
11
+ const source = await readWork(sourceId);
12
+ if (!source.ok) return { id: sourceId, available: false };
13
+ const { thread, posts } = source;
14
+ const result = posts
15
+ .filter(
16
+ (post) =>
17
+ post.author !== "user" &&
18
+ ["result", "post"].includes(post.kind) &&
19
+ post.text.trim()
20
+ )
21
+ .sort((a, b) => a.created_at.localeCompare(b.created_at))
22
+ .at(-1);
23
+ return {
24
+ id: sourceId,
25
+ available: true,
26
+ title: thread.title,
27
+ environment: thread.source?.environmentName ?? "Harness",
28
+ source: thread.source ?? null,
29
+ agents: thread.agents,
30
+ line: thread.view?.line ?? null,
31
+ working: thread.working,
32
+ needsYou: thread.view?.needsYou?.length ?? 0,
33
+ result: result
34
+ ? {
35
+ id: result.id,
36
+ author: result.author,
37
+ text: result.text,
38
+ at: result.created_at,
39
+ url: result.source?.url ?? thread.source?.url ?? null,
40
+ truncated: result.source?.truncated === true,
41
+ }
42
+ : null,
43
+ };
44
+ } catch {
45
+ // A revoked or unavailable source must not leave its old private content on the card.
46
+ return { id: sourceId, available: false };
47
+ }
48
+ })
49
+ );
50
+ return { ok: true, entries };
51
+ };
52
+ const update = async (request) => {
53
+ const { id, sourceId, linked } = request;
54
+ if (
55
+ typeof sourceId !== "string" ||
56
+ typeof linked !== "boolean" ||
57
+ sourceId === id
58
+ )
59
+ return {
60
+ ok: false,
61
+ error: "Choose another work thread to keep beside this objective.",
62
+ };
63
+ if (linked) {
64
+ const source = await readWork(sourceId);
65
+ if (!source.ok) return source;
66
+ }
67
+ // Read after the source check so simultaneous additions preserve each other.
68
+ const current = references(id);
69
+ if (linked && !current.includes(sourceId) && current.length >= 12)
70
+ return {
71
+ ok: false,
72
+ error: "Keep up to 12 work threads beside an objective.",
73
+ };
74
+ const next = linked
75
+ ? [...new Set([...current, sourceId])]
76
+ : current.filter((entry) => entry !== sourceId);
77
+ store.meta(key(id), JSON.stringify(next));
78
+ return read(id);
79
+ };
80
+ const version = (id, lookup) => {
81
+ const ids = references(id);
82
+ if (!ids.length) return null;
83
+ return createHash("sha256")
84
+ .update(
85
+ JSON.stringify(ids.map((sourceId) => [sourceId, lookup(sourceId)]))
86
+ )
87
+ .digest("hex");
88
+ };
89
+ return { read, update, version };
90
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tryharness",
3
- "version": "0.7.44",
3
+ "version": "0.7.53",
4
4
  "description": "Harness Relay: the daemon that turns the agents on this machine into your personal swarm. Memory, history, and work handed between any of them.",
5
5
  "bin": {
6
6
  "tryharness": "cli.mjs"
@@ -29,20 +29,25 @@
29
29
  "homepage": "https://tryharness.ai",
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
+ "@agentclientprotocol/sdk": "2.0.0",
32
33
  "@clack/core": "0.5.0",
33
34
  "@clack/prompts": "0.11.0",
34
35
  "@huggingface/tokenizers": "^0.1.3",
36
+ "@muse-code/sdk": "1.4.11",
37
+ "hyperdht": "6.34.1",
35
38
  "jpeg-js": "0.4.4",
36
39
  "node-sqlite3-wasm": "0.8.60",
37
40
  "onnxruntime-node": "1.24.3",
38
41
  "picocolors": "^1.1.1",
39
42
  "pngjs": "7.0.0",
40
43
  "qr": "0.4.2",
41
- "ws": "^8.18.3"
44
+ "udx-native": "1.22.0",
45
+ "ws": "^8.18.3",
46
+ "zod": "^4.4.3"
42
47
  },
43
48
  "optionalDependencies": {
44
- "tryharness-desktop-darwin-arm64": "0.7.25",
45
- "tryharness-desktop-darwin-x64": "0.7.25",
49
+ "tryharness-desktop-darwin-arm64": "0.7.53",
50
+ "tryharness-desktop-darwin-x64": "0.7.53",
46
51
  "tryharness-desktop-linux-x64": "0.7.4",
47
52
  "tryharness-desktop-win32-x64": "0.7.4"
48
53
  }