tryharness 0.7.82 → 0.7.86
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 +21 -19
- package/assets/dsh-plugin.mjs +75 -4
- package/assets/herdr-mod/harness/main.js +367 -0
- package/assets/herdr-mod/harness/mod.json +6 -0
- package/assets/opencode-plugin.js +87 -22
- package/assets/pi-extension.ts +81 -2
- package/cli.mjs +544 -208
- package/lib/adapters.mjs +62 -27
- package/lib/agentBinaries.mjs +6 -8
- package/lib/agentClaims.mjs +168 -0
- package/lib/agentReadTools.json +415 -0
- package/lib/agentSignIn.mjs +17 -18
- package/lib/agentWiring.mjs +114 -0
- package/lib/archetypes.js +10 -11
- package/lib/attention.mjs +100 -0
- package/lib/audit.mjs +1 -1
- package/lib/backupSetup.mjs +6 -28
- package/lib/bankrApprovals.mjs +86 -0
- package/lib/boardAccess.mjs +40 -66
- package/lib/boardBackup.mjs +86 -85
- package/lib/boardCommands.mjs +28 -0
- package/lib/boardFileCommands.mjs +29 -36
- package/lib/boardFiles.mjs +83 -15
- package/lib/boardMirror.mjs +78 -11
- package/lib/boardProtocol.json +193 -123
- package/lib/boardThreads.mjs +19 -37
- package/lib/boardTools.mjs +22 -15
- package/lib/boardWatches.mjs +43 -15
- package/lib/bridge.mjs +7 -3
- package/lib/browserAgentTools.mjs +59 -0
- package/lib/browserWake.mjs +0 -6
- package/lib/cards.mjs +57 -2
- package/lib/circling.mjs +189 -0
- package/lib/cleanup.mjs +234 -0
- package/lib/cloudBoot.mjs +21 -4
- package/lib/cloudSave.mjs +46 -5
- package/lib/compaction.mjs +8 -1
- package/lib/completion.mjs +358 -0
- package/lib/computerDevices.mjs +853 -0
- package/lib/connectionStatus.mjs +34 -0
- package/lib/connectors.mjs +139 -1
- package/lib/coordinator.mjs +108 -14
- package/lib/coreModels.mjs +36 -12
- package/lib/daemon.mjs +2435 -333
- package/lib/daemonLock.mjs +103 -0
- package/lib/deviceDoor.mjs +308 -0
- package/lib/deviceIdentity.mjs +114 -0
- package/lib/deviceList.mjs +172 -0
- package/lib/deviceSeal.mjs +74 -0
- package/lib/dispatcher.mjs +497 -26
- package/lib/dispatches.mjs +3 -3
- package/lib/environment.mjs +2 -1
- package/lib/environments.mjs +67 -41
- package/lib/events.mjs +318 -0
- package/lib/facts.mjs +170 -0
- package/lib/fileSource.mjs +540 -0
- package/lib/files.mjs +47 -2
- package/lib/gitHost.mjs +39 -1
- package/lib/goalCommands.mjs +12 -80
- package/lib/handover.mjs +21 -16
- package/lib/harnessOffers.mjs +140 -15
- package/lib/herdr.mjs +100 -15
- package/lib/herdrAppCall.mjs +19 -0
- package/lib/herdrCore.mjs +59 -0
- package/lib/herdrRuns.mjs +1126 -0
- package/lib/hookDialects.mjs +235 -50
- package/lib/identityLink.mjs +81 -0
- package/lib/inference.mjs +31 -2
- package/lib/jamAccess.mjs +82 -0
- package/lib/{projectBoard.mjs → jamBoard.mjs} +5 -4
- package/lib/{projectGit.mjs → jamGit.mjs} +53 -15
- package/lib/jamKey.mjs +274 -0
- package/lib/{projectPieces.mjs → jamPieces.mjs} +35 -29
- package/lib/{projectSettings.mjs → jamSettings.mjs} +12 -22
- package/lib/jamStore.mjs +973 -0
- package/lib/jamUpgrade.mjs +112 -0
- package/lib/jams.mjs +3079 -0
- package/lib/kanban.mjs +13 -7
- package/lib/landed.mjs +5 -1
- package/lib/library.mjs +41 -22
- package/lib/limits.mjs +91 -0
- package/lib/lineDiff.mjs +97 -0
- package/lib/lineup.mjs +18 -13
- package/lib/link.mjs +584 -0
- package/lib/localStack.mjs +75 -16
- package/lib/localmodels.mjs +58 -78
- package/lib/loopBackstop.mjs +2 -1
- package/lib/machine.mjs +544 -0
- package/lib/machineLink.mjs +446 -0
- package/lib/machineRoutes.mjs +68 -19
- package/lib/machineRuns.mjs +85 -4
- package/lib/machineSeal.mjs +6 -31
- package/lib/manager.mjs +134 -12
- package/lib/mcp-stdio.mjs +492 -215
- package/lib/mcpRelay.mjs +34 -35
- package/lib/members.json +2 -2
- package/lib/modelRoute.mjs +162 -0
- package/lib/nativeHost.mjs +81 -90
- package/lib/nativeSenses.mjs +258 -0
- package/lib/nerves.mjs +523 -0
- package/lib/network.mjs +117 -278
- package/lib/networkPlaces.mjs +578 -0
- package/lib/nextStep.mjs +95 -0
- package/lib/notify.mjs +2 -2
- package/lib/nudge.mjs +116 -10
- package/lib/onboard.mjs +6 -6
- package/lib/originals.mjs +216 -0
- package/lib/outsideEvents.mjs +383 -0
- package/lib/outsideRuns.mjs +230 -0
- package/lib/ownMachines.mjs +674 -256
- package/lib/pain.mjs +215 -0
- package/lib/pairing.mjs +91 -11
- package/lib/paths.mjs +42 -3
- package/lib/peerProcess.mjs +21 -7
- package/lib/peopleLink.mjs +268 -0
- package/lib/personNotices.mjs +3 -2
- package/lib/phones.mjs +252 -542
- package/lib/placeCards.mjs +282 -0
- package/lib/placeChecks.mjs +95 -0
- package/lib/placeCommands.mjs +8 -17
- package/lib/placeRequests.mjs +152 -0
- package/lib/placeStore.mjs +295 -0
- package/lib/placeTool.d.ts +12 -0
- package/lib/placeTool.js +40 -0
- package/lib/places.mjs +63 -14
- package/lib/plans.mjs +53 -8
- package/lib/presence.mjs +270 -0
- package/lib/privateNetwork.d.ts +2 -0
- package/lib/privateNetwork.js +93 -0
- package/lib/proposals.mjs +300 -0
- package/lib/publicFetch.d.ts +32 -0
- package/lib/publicFetch.js +248 -0
- package/lib/reach.mjs +128 -0
- package/lib/rebuildable.mjs +72 -0
- package/lib/recall.mjs +216 -0
- package/lib/record.mjs +13 -0
- package/lib/reflexes.mjs +392 -0
- package/lib/relayLimits.mjs +31 -2
- package/lib/releaseNotice.mjs +198 -0
- package/lib/removeHarness.mjs +15 -4
- package/lib/repoLinks.mjs +204 -35
- package/lib/runAuthority.mjs +102 -39
- package/lib/runBrief.mjs +93 -40
- package/lib/runRequests.mjs +52 -14
- package/lib/runUsage.mjs +31 -0
- package/lib/runWorker.mjs +74 -25
- package/lib/runner.mjs +289 -45
- package/lib/runtime-install.mjs +37 -8
- package/lib/schedules.mjs +171 -47
- package/lib/screenWatches.mjs +221 -0
- package/lib/sealed.mjs +12 -30
- package/lib/sealedThreads.mjs +198 -392
- package/lib/secretStore.mjs +178 -0
- package/lib/secrets.mjs +11 -0
- package/lib/seen.mjs +3 -9
- package/lib/selfUpdate.mjs +51 -15
- package/lib/senseCall.mjs +1514 -0
- package/lib/senseHook.mjs +114 -0
- package/lib/senseTools.mjs +1298 -0
- package/lib/sessionBriefs.mjs +87 -0
- package/lib/sessionControl.mjs +63 -13
- package/lib/sessionFiles.mjs +85 -0
- package/lib/setupChoices.mjs +12 -3
- package/lib/setupMode.mjs +70 -25
- package/lib/sharedKeys.mjs +166 -0
- package/lib/sleep.mjs +396 -0
- package/lib/sources.mjs +306 -0
- package/lib/speech.mjs +166 -411
- package/lib/spoken.mjs +210 -0
- package/lib/steerHook.mjs +3 -1
- package/lib/steerQueue.mjs +40 -11
- package/lib/store.mjs +323 -130
- package/lib/stuck.mjs +85 -7
- package/lib/swarm.mjs +157 -49
- package/lib/swarmDevices.mjs +25 -85
- package/lib/swarmMemory.mjs +93 -9
- package/lib/t3.mjs +73 -3
- package/lib/taskCommands.mjs +51 -60
- package/lib/taskRooms.mjs +30 -4
- package/lib/taskRules.json +29 -0
- package/lib/taskRules.mjs +21 -0
- package/lib/taskRuns.mjs +74 -11
- package/lib/team.mjs +2 -1
- package/lib/threadActions.mjs +37 -9
- package/lib/threadAuthority.mjs +4 -4
- package/lib/threadBriefs.mjs +173 -43
- package/lib/threadNotes.mjs +320 -0
- package/lib/threadRecord.mjs +491 -0
- package/lib/threadRuns.mjs +216 -108
- package/lib/threadView.mjs +27 -30
- package/lib/threadWatches.mjs +1962 -0
- package/lib/timeSense.mjs +839 -0
- package/lib/tripwires.mjs +454 -0
- package/lib/ui.mjs +1 -1
- package/lib/vault.mjs +560 -45
- package/lib/vaultCommands.mjs +5 -3
- package/lib/vaultPeers.mjs +165 -0
- package/lib/vaultTools.d.ts +4 -1
- package/lib/vaultTools.js +22 -1
- package/lib/verdicts.mjs +12 -26
- package/lib/versions.mjs +117 -0
- package/lib/waitTool.mjs +278 -0
- package/lib/wakePicture.mjs +268 -0
- package/lib/wakeQueue.mjs +108 -0
- package/lib/watchResponses.mjs +533 -0
- package/lib/watches.mjs +290 -145
- package/lib/windowAsks.mjs +80 -17
- package/lib/worktrees.mjs +159 -9
- package/npm-shrinkwrap.json +138 -631
- package/package.json +7 -6
- package/release.json +212 -130
- package/lib/callSessions.mjs +0 -51
- package/lib/directLink.mjs +0 -349
- package/lib/peopleBoard.mjs +0 -131
- package/lib/projects.mjs +0 -2917
- package/lib/roomChannels.mjs +0 -667
package/lib/boardThreads.mjs
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { nameOf } from "./members.mjs";
|
|
4
3
|
import { notifyDesktop } from "./notify.mjs";
|
|
5
4
|
import { secretReason } from "./secrets.mjs";
|
|
5
|
+
import { checkedAsText } from "./boardFiles.mjs";
|
|
6
6
|
|
|
7
|
+
// A friendship's messages on this computer (docs/jam-plan.md J2): only the person reads, writes, sends, discards and
|
|
8
|
+
// ends them. No agent is ever in a message, so every thread command from any other caller is refused.
|
|
7
9
|
export function createBoardThreads({
|
|
8
10
|
blobPath,
|
|
9
11
|
notifyBoard,
|
|
10
12
|
sendThreadEnd,
|
|
11
13
|
sendThreadMessage,
|
|
12
14
|
store,
|
|
13
|
-
textLike,
|
|
14
15
|
visibleFile,
|
|
15
16
|
}) {
|
|
16
17
|
return (request, { agent, id }) => {
|
|
18
|
+
if (agent !== "user")
|
|
19
|
+
return { ok: false, error: "messages are only between people" };
|
|
17
20
|
let outcome;
|
|
18
21
|
if (request.command === "board.thread.read") {
|
|
19
22
|
const thread = store.getThread(id);
|
|
@@ -41,7 +44,7 @@ export function createBoardThreads({
|
|
|
41
44
|
ref: ref.ref,
|
|
42
45
|
...(typeof ref.note === "string" ? { note: ref.note } : {}),
|
|
43
46
|
}));
|
|
44
|
-
// Files go only sealed to the other computer
|
|
47
|
+
// Files go only sealed to the other computer.
|
|
45
48
|
const files = (Array.isArray(request.files) ? request.files : [])
|
|
46
49
|
.slice(0, 10)
|
|
47
50
|
.map((fileId) => store.file(String(fileId)));
|
|
@@ -57,11 +60,12 @@ export function createBoardThreads({
|
|
|
57
60
|
ok: false,
|
|
58
61
|
error: "a file in files is not one you can send",
|
|
59
62
|
};
|
|
60
|
-
|
|
63
|
+
// Nothing goes unsealed: until this computer holds the friend's key, nothing is sent.
|
|
64
|
+
if (!store.getThread(id)?.peer_key)
|
|
61
65
|
return {
|
|
62
66
|
ok: false,
|
|
63
67
|
error:
|
|
64
|
-
"
|
|
68
|
+
"this computer does not have your friend's key yet, and messages never go unsealed; nothing was sent",
|
|
65
69
|
};
|
|
66
70
|
const refs = [
|
|
67
71
|
...named,
|
|
@@ -78,11 +82,13 @@ export function createBoardThreads({
|
|
|
78
82
|
secretReason(text) ||
|
|
79
83
|
secretReason(JSON.stringify(named)) ||
|
|
80
84
|
files
|
|
81
|
-
.map(
|
|
82
|
-
(file)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
.map((file) => {
|
|
86
|
+
const bytes = fs.readFileSync(blobPath(file.sha256));
|
|
87
|
+
return (
|
|
88
|
+
checkedAsText(file.mime, bytes) &&
|
|
89
|
+
secretReason(bytes.toString("utf8"))
|
|
90
|
+
);
|
|
91
|
+
})
|
|
86
92
|
.find(Boolean) ||
|
|
87
93
|
null;
|
|
88
94
|
outcome = store.postMessage({
|
|
@@ -92,31 +98,18 @@ export function createBoardThreads({
|
|
|
92
98
|
text,
|
|
93
99
|
refs,
|
|
94
100
|
flagReason,
|
|
95
|
-
hold: files.length > 0,
|
|
96
101
|
});
|
|
97
|
-
if (outcome.ok && flagReason) store.revertAutoSend(id);
|
|
98
|
-
if (outcome.ok && outcome.message.state === "sent")
|
|
99
|
-
sendThreadMessage(outcome.message);
|
|
100
102
|
if (outcome.ok) {
|
|
101
103
|
outcome = { ...outcome, task: store.getTask(id) };
|
|
102
104
|
if (flagReason)
|
|
103
105
|
notifyDesktop(
|
|
104
|
-
`
|
|
105
|
-
);
|
|
106
|
-
else if (outcome.message.state === "held")
|
|
107
|
-
notifyDesktop(
|
|
108
|
-
`${nameOf(agent)} drafted a reply to ${outcome.message.recipient}: send it from Harness.`
|
|
106
|
+
`Your message to ${outcome.message.recipient.split("/")[0]} was held: it looks like ${flagReason}. Review it in Harness.`
|
|
109
107
|
);
|
|
110
108
|
}
|
|
111
109
|
} else if (
|
|
112
110
|
request.command === "board.thread.send" ||
|
|
113
111
|
request.command === "board.thread.discard"
|
|
114
112
|
) {
|
|
115
|
-
if (agent !== "user")
|
|
116
|
-
return {
|
|
117
|
-
ok: false,
|
|
118
|
-
error: "only the user sends or discards a held reply",
|
|
119
|
-
};
|
|
120
113
|
const messageId = String(request.messageId || "");
|
|
121
114
|
if (request.command === "board.thread.discard") {
|
|
122
115
|
outcome = store.discardMessage(messageId);
|
|
@@ -128,25 +121,14 @@ export function createBoardThreads({
|
|
|
128
121
|
outcome = { ...outcome, task: store.getTask(id) };
|
|
129
122
|
}
|
|
130
123
|
}
|
|
131
|
-
} else if (request.command === "board.thread.auto") {
|
|
132
|
-
if (agent !== "user")
|
|
133
|
-
return { ok: false, error: "only the user changes auto-send" };
|
|
134
|
-
outcome = store.setAutoSend(id, request.on === true);
|
|
135
|
-
if (outcome.ok) outcome = { ...outcome, task: store.getTask(id) };
|
|
136
124
|
} else if (request.command === "board.thread.end") {
|
|
137
|
-
|
|
138
|
-
if (!task) return { ok: false, error: "task not found" };
|
|
139
|
-
if (agent !== "user" && task.claimed_by !== agent)
|
|
140
|
-
return {
|
|
141
|
-
ok: false,
|
|
142
|
-
error: "only the user or the agent holding the task ends its thread",
|
|
143
|
-
};
|
|
125
|
+
if (!store.getTask(id)) return { ok: false, error: "task not found" };
|
|
144
126
|
outcome = store.closeThread(
|
|
145
127
|
id,
|
|
146
128
|
String(request.outcome || "").slice(0, 20_000) || null
|
|
147
129
|
);
|
|
148
130
|
if (outcome.ok && !outcome.already)
|
|
149
|
-
sendThreadEnd(id,
|
|
131
|
+
sendThreadEnd(id, outcome.thread.outcome);
|
|
150
132
|
} else return { ok: false, error: "unknown command" };
|
|
151
133
|
if (outcome.ok) notifyBoard(outcome.task);
|
|
152
134
|
return outcome;
|
package/lib/boardTools.mjs
CHANGED
|
@@ -3,6 +3,25 @@ import path from "node:path";
|
|
|
3
3
|
import { compareScreens } from "./screens.mjs";
|
|
4
4
|
import { nameOf } from "./members.mjs";
|
|
5
5
|
|
|
6
|
+
const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
7
|
+
|
|
8
|
+
/** A screenshot comparison as the log keeps it: how much changed, never the words on the screen. */
|
|
9
|
+
const countsOf = ({ size, regions = [], text = {} }) => {
|
|
10
|
+
const sameSize =
|
|
11
|
+
size?.before?.[0] === size?.after?.[0] &&
|
|
12
|
+
size?.before?.[1] === size?.after?.[1];
|
|
13
|
+
const lines = ["changed", "moved", "added", "removed"].reduce(
|
|
14
|
+
(sum, kind) => sum + (text[kind]?.length ?? 0),
|
|
15
|
+
0
|
|
16
|
+
);
|
|
17
|
+
return [
|
|
18
|
+
sameSize
|
|
19
|
+
? `${plural(regions.length, "region")} of the picture changed`
|
|
20
|
+
: "the screenshots differ in size",
|
|
21
|
+
`${plural(lines, "line")} of text ${lines === 1 ? "differs" : "differ"}`,
|
|
22
|
+
].join("; ");
|
|
23
|
+
};
|
|
24
|
+
|
|
6
25
|
export function createBoardTools({
|
|
7
26
|
MAX_FILE_BYTES,
|
|
8
27
|
contextEngine,
|
|
@@ -14,10 +33,8 @@ export function createBoardTools({
|
|
|
14
33
|
localReady,
|
|
15
34
|
ocr,
|
|
16
35
|
askWindows,
|
|
17
|
-
getServerFeatures,
|
|
18
36
|
snippets,
|
|
19
37
|
roomOf,
|
|
20
|
-
state,
|
|
21
38
|
store,
|
|
22
39
|
watchOrListen,
|
|
23
40
|
}) {
|
|
@@ -56,9 +73,11 @@ export function createBoardTools({
|
|
|
56
73
|
ocr,
|
|
57
74
|
lane: "interactive",
|
|
58
75
|
}).then((result) => {
|
|
76
|
+
// The log keeps counts, never the words read off the screen (events.mjs: no one's words; owner, November
|
|
77
|
+
// 13: "yeah okat"). The agent that asked gets the words in its answer.
|
|
59
78
|
localEvent(
|
|
60
79
|
"screens",
|
|
61
|
-
`compared two screenshots: ${result
|
|
80
|
+
`compared two screenshots: ${countsOf(result)}`,
|
|
62
81
|
result.ms
|
|
63
82
|
);
|
|
64
83
|
return { ok: true, ...result };
|
|
@@ -142,18 +161,6 @@ export function createBoardTools({
|
|
|
142
161
|
.trim()
|
|
143
162
|
.slice(0, 2_000);
|
|
144
163
|
if (!query) return { ok: false, error: "search_screen needs a query" };
|
|
145
|
-
if (!state.connected)
|
|
146
|
-
return {
|
|
147
|
-
ok: false,
|
|
148
|
-
error:
|
|
149
|
-
"the daemon is not connected to Harness, so the person's Harness window cannot be reached",
|
|
150
|
-
};
|
|
151
|
-
if (!getServerFeatures().has("sealed_ask"))
|
|
152
|
-
return {
|
|
153
|
-
ok: false,
|
|
154
|
-
error:
|
|
155
|
-
"the Harness this computer is connected to cannot carry a sealed screen search yet",
|
|
156
|
-
};
|
|
157
164
|
const since = request.since ? Date.parse(String(request.since)) : NaN;
|
|
158
165
|
const input = {
|
|
159
166
|
query,
|
package/lib/boardWatches.mjs
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import { digestSince } from "./digest.mjs";
|
|
2
2
|
|
|
3
|
+
// What the buddy's strip shows from the log (events.mjs): the local stack's steps, watch alerts and snippets, as before
|
|
4
|
+
// the log. Anything else that happens reaches the strip only once the owner has reviewed how the buddy says it.
|
|
5
|
+
const SHOWN = ["stack", "watch", "snippet"];
|
|
6
|
+
|
|
7
|
+
// A call that may itself answer later ({ pending }), as one promise.
|
|
8
|
+
const settled = async (result) =>
|
|
9
|
+
result?.pending ? { ok: true, ...(await result.pending) } : result;
|
|
10
|
+
|
|
3
11
|
export function createBoardWatches({
|
|
4
12
|
takeNotices = () => [],
|
|
5
13
|
folderOf,
|
|
6
14
|
contextEngine,
|
|
7
15
|
environment,
|
|
8
16
|
frames,
|
|
9
|
-
|
|
17
|
+
events,
|
|
10
18
|
notePresence,
|
|
11
19
|
presence,
|
|
12
20
|
store,
|
|
13
21
|
watches,
|
|
22
|
+
// A watch of a thread's that waits for the person (threadWatches.mjs): the person's start reaches it too.
|
|
23
|
+
startThreadWatch = () => ({ ok: false, error: "no such watch" }),
|
|
14
24
|
}) {
|
|
15
25
|
return (request, { agent }) => {
|
|
16
26
|
if (
|
|
@@ -27,9 +37,15 @@ export function createBoardWatches({
|
|
|
27
37
|
if (request.command === "board.local.events")
|
|
28
38
|
return {
|
|
29
39
|
ok: true,
|
|
30
|
-
events:
|
|
31
|
-
(
|
|
32
|
-
|
|
40
|
+
events: events
|
|
41
|
+
.read({ since: String(request.since || ""), sources: SHOWN })
|
|
42
|
+
.map(({ seq, at, kind, text, ms }) => ({
|
|
43
|
+
seq,
|
|
44
|
+
at,
|
|
45
|
+
kind,
|
|
46
|
+
text,
|
|
47
|
+
...(ms === undefined ? {} : { ms }),
|
|
48
|
+
})),
|
|
33
49
|
};
|
|
34
50
|
if (request.command === "board.watch.list")
|
|
35
51
|
return {
|
|
@@ -45,14 +61,16 @@ export function createBoardWatches({
|
|
|
45
61
|
above: request.above ?? null,
|
|
46
62
|
below: request.below ?? null,
|
|
47
63
|
};
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
return {
|
|
65
|
+
pending: watches.add({
|
|
66
|
+
name: request.name,
|
|
67
|
+
command: request.watchCommand,
|
|
68
|
+
folder: folderOf(request),
|
|
69
|
+
everySeconds: Number(request.everySeconds) || 300,
|
|
70
|
+
measure,
|
|
71
|
+
by: agent === "user" ? "user" : agent,
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
56
74
|
}
|
|
57
75
|
if (agent !== "user")
|
|
58
76
|
return {
|
|
@@ -62,10 +80,20 @@ export function createBoardWatches({
|
|
|
62
80
|
// The notices the buddy posts itself (daemon.mjs tellDesktop), handed over once.
|
|
63
81
|
if (request.command === "board.notices.take")
|
|
64
82
|
return { ok: true, notices: takeNotices() };
|
|
65
|
-
if (request.command === "board.watch.start")
|
|
66
|
-
|
|
83
|
+
if (request.command === "board.watch.start") {
|
|
84
|
+
const id = String(request.id || "");
|
|
85
|
+
return {
|
|
86
|
+
pending: watches
|
|
87
|
+
.start(id)
|
|
88
|
+
.then((started) =>
|
|
89
|
+
started.ok || started.error !== "no such watch"
|
|
90
|
+
? started
|
|
91
|
+
: settled(startThreadWatch(id))
|
|
92
|
+
),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
67
95
|
if (request.command === "board.watch.remove")
|
|
68
|
-
return watches.remove(String(request.id || ""));
|
|
96
|
+
return { pending: watches.remove(String(request.id || "")) };
|
|
69
97
|
if (request.command === "board.digest") {
|
|
70
98
|
notePresence();
|
|
71
99
|
const since =
|
package/lib/bridge.mjs
CHANGED
|
@@ -7,11 +7,13 @@ const HEARTBEAT_MS = Number(process.env.HARNESS_HEARTBEAT_MS) || 30_000;
|
|
|
7
7
|
// A dropped connection dials again after about a second (give or take a fifth), doubling up to 30 s.
|
|
8
8
|
export const RECONNECT_FIRST_MS = 1_000;
|
|
9
9
|
// How long a request to Harness waits for its answer unless it says otherwise; a request between the person's own
|
|
10
|
-
// computers waits as long on the direct link (
|
|
10
|
+
// computers waits as long on the direct link (machineLink.mjs) before it goes through Harness.
|
|
11
11
|
export const ASK_TIMEOUT_MS = 15_000;
|
|
12
12
|
export const RECONNECT_JITTER = 0.2;
|
|
13
13
|
// Harness's answer when another computer paired to this account is connected, kept in step with Harness's server: 409
|
|
14
14
|
// on the dial, or close code 4409 when two dials crossed.
|
|
15
|
+
// Harness's close for a computer older than it accepts (src/server/bridge/bridgeHub.ts TOO_OLD).
|
|
16
|
+
const TOO_OLD_CODE = 4426;
|
|
15
17
|
const HELD_ELSEWHERE = {
|
|
16
18
|
status: 409,
|
|
17
19
|
code: 4409,
|
|
@@ -292,9 +294,11 @@ export function createBridge({
|
|
|
292
294
|
saveStatus();
|
|
293
295
|
scheduleReconnect();
|
|
294
296
|
};
|
|
295
|
-
socket.on("close", (code) => {
|
|
297
|
+
socket.on("close", (code, reason) => {
|
|
296
298
|
if (code === HELD_ELSEWHERE.code) holdElsewhere();
|
|
297
|
-
|
|
299
|
+
// Harness closed on this computer as too old (src/server/bridge/bridgeHub.ts TOO_OLD): its words are the error.
|
|
300
|
+
if (code === TOO_OLD_CODE) refusal = String(reason || "") || refusal;
|
|
301
|
+
dropped(refusal ? new Error(refusal) : undefined);
|
|
298
302
|
});
|
|
299
303
|
socket.on("error", dropped);
|
|
300
304
|
} catch (error) {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// The two tools an agent on this computer has for the pages in the person's browsers (owner, November 12: local agents
|
|
2
|
+
// get browser_page and browser_task, not the browser toolkit). They are this computer's own tools: listed by its MCP
|
|
3
|
+
// server (mcp-stdio.mjs) and answered here (deviceDoor.mjs), which asks the browser running on this computer or the
|
|
4
|
+
// computer that browser runs on, over their own link. Harness's server never lists or carries them.
|
|
5
|
+
// Same names as src/shared/doorTools.ts LOCAL_AGENT_BROWSER_TOOLS, which the browser maps to its door calls.
|
|
6
|
+
|
|
7
|
+
export const BROWSER_PAGE = "browser_page";
|
|
8
|
+
export const BROWSER_TASK = "browser_task";
|
|
9
|
+
|
|
10
|
+
const DEVICE = {
|
|
11
|
+
type: "string",
|
|
12
|
+
description:
|
|
13
|
+
"Which of the person's browsers: a device id or name from list_devices. Leave it out for the browser on this computer, else one on the person's other computers.",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const BROWSER_AGENT_TOOLS = [
|
|
17
|
+
{
|
|
18
|
+
name: BROWSER_PAGE,
|
|
19
|
+
description:
|
|
20
|
+
"Read a page in the person's own browser now, where they are signed in: the tab in front, another open tab, or an address. Examples: the Linear ticket they have open; tab 'stripe' for their open Stripe dashboard; url 'https://sentry.io/issues/123' for a page behind their sign-in. Use it for what is open or behind their sign-in; for what they saw earlier, use the screen history tools; to change anything on a page, use browser_task. `tab`: part of an open tab's title or address; left out, the tab in front. `url`: an address to open in a background tab, read and close, so the person's own tab stays in front. `document`: a file the page links to (a PDF invoice, an email attachment) or one on the page's own site, read as text instead of the page. `picture`: true to get a picture of the page as well. `offset`: where the text continues, as the last read said. It returns the page's title and address, its visible text in order (tables as text), the text of the frames inside it it may read, and its links; a long page comes in parts. It changes nothing on the page the person is on. It reads what the page has loaded: a list that loads more as you scroll shows only what is loaded. At most six minutes per read.",
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
tab: { type: "string" },
|
|
25
|
+
url: { type: "string" },
|
|
26
|
+
document: { type: "string" },
|
|
27
|
+
picture: { type: "boolean" },
|
|
28
|
+
offset: { type: "integer", minimum: 0 },
|
|
29
|
+
device: DEVICE,
|
|
30
|
+
},
|
|
31
|
+
additionalProperties: false,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: BROWSER_TASK,
|
|
36
|
+
description:
|
|
37
|
+
"Do one thing on a website in the person's own browser, where they are already signed in. Examples: 'in Gmail, reply to Dana's last email with: Friday works'; 'on dashboard.stripe.com, download the October invoice'. Use it only when the work needs their browser: to read what is open, use browser_page; to look things up on the public web, use your own tools. `instruction`: one task in the person's words; name the site, and put text to type in quotes exactly as it should appear. `device`: optional, which browser. Harness's browser session does it step by step and checks each step on the page; new pages open in a new tab, so the person's page stays where it is; the person can watch. It returns what was done and what the page now shows, or the one thing it needs from the person (a sign-in, a code, a choice): ask them exactly that, do not retry around it. One task per call, at most 10 minutes.",
|
|
38
|
+
inputSchema: {
|
|
39
|
+
type: "object",
|
|
40
|
+
properties: {
|
|
41
|
+
instruction: { type: "string", minLength: 1 },
|
|
42
|
+
device: DEVICE,
|
|
43
|
+
},
|
|
44
|
+
required: ["instruction"],
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
// Each tool's deadline, as src/shared/doorTools.ts doorDeadlineMs gives it (smoke link-browsers checks they match):
|
|
51
|
+
// browser_task's own definition's (src/runtime/client-channel/browserTaskTool.ts), and browser_page's steps' own
|
|
52
|
+
// deadlines added up (BROWSER_PAGE_DEADLINE_MS) with the same margin a window's turn gives a browser tool.
|
|
53
|
+
export const BROWSER_AGENT_DEADLINES = {
|
|
54
|
+
[BROWSER_PAGE]: 360_000,
|
|
55
|
+
[BROWSER_TASK]: 600_000,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const isBrowserAgentTool = (name) =>
|
|
59
|
+
Object.hasOwn(BROWSER_AGENT_DEADLINES, String(name ?? ""));
|
package/lib/browserWake.mjs
CHANGED
|
@@ -8,13 +8,10 @@ const MAX_WAITING = 20;
|
|
|
8
8
|
const LONGEST_WAIT_MS = 25_000;
|
|
9
9
|
// The host asks again at once after each answer; a minute with no ask means no browser is listening.
|
|
10
10
|
const LISTENING_MS = 60_000;
|
|
11
|
-
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
12
11
|
|
|
13
12
|
export function createBrowserWake({
|
|
14
13
|
log = () => {},
|
|
15
14
|
now = () => Date.now(),
|
|
16
|
-
// What should reach a browser that starts listening (after this daemon or the browser restarted).
|
|
17
|
-
pending = () => [],
|
|
18
15
|
} = {}) {
|
|
19
16
|
const waiting = [];
|
|
20
17
|
const askers = new Set();
|
|
@@ -29,9 +26,6 @@ export function createBrowserWake({
|
|
|
29
26
|
|
|
30
27
|
/** What is waiting, or after up to `waitMs` nothing. */
|
|
31
28
|
function next(waitMs = LONGEST_WAIT_MS) {
|
|
32
|
-
if (!listening())
|
|
33
|
-
for (const message of pending())
|
|
34
|
-
if (!waiting.some((kept) => same(kept, message))) waiting.push(message);
|
|
35
29
|
askedAt = now();
|
|
36
30
|
if (waiting.length) return Promise.resolve(waiting.splice(0));
|
|
37
31
|
const wait = Math.min(Math.max(0, Number(waitMs) || 0), LONGEST_WAIT_MS);
|
package/lib/cards.mjs
CHANGED
|
@@ -20,6 +20,7 @@ const ANSWERS = {
|
|
|
20
20
|
email: "woken by email when work is posted",
|
|
21
21
|
webhook: "woken when work is posted",
|
|
22
22
|
"local-webhook": "woken when work is posted",
|
|
23
|
+
listen: "woken when work is posted",
|
|
23
24
|
schedule: "picks work up on its own schedule",
|
|
24
25
|
none: "only when the person next talks to it",
|
|
25
26
|
};
|
|
@@ -28,8 +29,10 @@ export const answersFor = (entry) =>
|
|
|
28
29
|
? "not set up yet: work posted for it waits until the person sets it up in Harness"
|
|
29
30
|
: entry.setup?.state === "not_answering"
|
|
30
31
|
? "not answering right now: work posted for it waits until it does"
|
|
31
|
-
:
|
|
32
|
-
|
|
32
|
+
: entry.setup?.how === "listen" && entry.setup.detail
|
|
33
|
+
? entry.setup.detail
|
|
34
|
+
: (ANSWERS[entry.setup?.how ?? member(entry.id)?.wake] ??
|
|
35
|
+
"when it next looks");
|
|
33
36
|
|
|
34
37
|
const NOTE_LIMIT = 300;
|
|
35
38
|
const noteKey = (id) => `agent-note:${id}`;
|
|
@@ -88,6 +91,39 @@ export const roundFields = (card) => ({
|
|
|
88
91
|
offices: card.offices?.map((office) => office.id),
|
|
89
92
|
});
|
|
90
93
|
|
|
94
|
+
/**
|
|
95
|
+
* What an agent's finished runs cost (docs/senses-plan.md S9.3), over its latest RECENT runs whose provider said what
|
|
96
|
+
* they used: the tokens each read and wrote (cached reads and writes included, as they are read again), and dollars
|
|
97
|
+
* where the provider puts a price on them (Codex says none). Null with no such run.
|
|
98
|
+
*/
|
|
99
|
+
export function costOf(rows) {
|
|
100
|
+
const tokens = [];
|
|
101
|
+
const dollars = [];
|
|
102
|
+
for (const row of rows.slice(0, RECENT)) {
|
|
103
|
+
let usage;
|
|
104
|
+
try {
|
|
105
|
+
usage = JSON.parse(row.usage);
|
|
106
|
+
} catch {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const used = [
|
|
110
|
+
"input_tokens",
|
|
111
|
+
"output_tokens",
|
|
112
|
+
"cache_read_tokens",
|
|
113
|
+
"cache_write_tokens",
|
|
114
|
+
].reduce((sum, key) => sum + (Number(usage?.[key]) || 0), 0);
|
|
115
|
+
if (used > 0) tokens.push(used);
|
|
116
|
+
if (Number(usage?.cost_usd) > 0) dollars.push(Number(usage.cost_usd));
|
|
117
|
+
}
|
|
118
|
+
if (!tokens.length) return null;
|
|
119
|
+
const usd = median(dollars);
|
|
120
|
+
return {
|
|
121
|
+
runs: tokens.length,
|
|
122
|
+
medianTokens: Math.round(median(tokens)),
|
|
123
|
+
medianUsd: usd === null ? null : Math.round(usd * 10_000) / 10_000,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
91
127
|
/** Cards for the given roster entries ({ id, setup? }), in their order. A card's setup is its state alone ("not_set_up"). */
|
|
92
128
|
// `lessons`: what the person has said about each agent (lessons.mjs), left off a card going to a caller off this computer.
|
|
93
129
|
export function swarmCards(store, entries, { home, lessons = true } = {}) {
|
|
@@ -132,6 +168,10 @@ export function swarmCards(store, entries, { home, lessons = true } = {}) {
|
|
|
132
168
|
const checks = store.receiptCounts?.() ?? {};
|
|
133
169
|
// The person's verdicts on its work (reactions.mjs; a store from before reactions has none).
|
|
134
170
|
const verdicts = store.verdictCounts?.() ?? {};
|
|
171
|
+
// What its finished runs cost (a store from before run usage has none).
|
|
172
|
+
const costRows = new Map();
|
|
173
|
+
for (const row of store.runCosts?.() ?? [])
|
|
174
|
+
costRows.set(row.agent, [...(costRows.get(row.agent) ?? []), row]);
|
|
135
175
|
const pinned = pins(store);
|
|
136
176
|
const held = offices(store);
|
|
137
177
|
return entries.map((entry) => {
|
|
@@ -183,6 +223,9 @@ export function swarmCards(store, entries, { home, lessons = true } = {}) {
|
|
|
183
223
|
medianMinutes: minutes === null ? null : Math.round(minutes * 10) / 10,
|
|
184
224
|
...(checks[entry.id] ? { checks: checks[entry.id] } : {}),
|
|
185
225
|
...(verdicts[entry.id] ? { verdicts: verdicts[entry.id] } : {}),
|
|
226
|
+
...(costOf(costRows.get(entry.id) ?? [])
|
|
227
|
+
? { cost: costOf(costRows.get(entry.id)) }
|
|
228
|
+
: {}),
|
|
186
229
|
},
|
|
187
230
|
working: done.working,
|
|
188
231
|
waiting: done.waiting,
|
|
@@ -207,6 +250,13 @@ const span = (minutes) =>
|
|
|
207
250
|
const sentence = (text) =>
|
|
208
251
|
`${text.charAt(0).toUpperCase()}${text.slice(1)}${/[.!?]$/.test(text) ? "" : "."}`;
|
|
209
252
|
|
|
253
|
+
const tokensWords = (tokens) =>
|
|
254
|
+
tokens >= 1_000_000
|
|
255
|
+
? `${(tokens / 1_000_000).toFixed(1)}M`
|
|
256
|
+
: tokens >= 1_000
|
|
257
|
+
? `${Math.round(tokens / 1_000)}k`
|
|
258
|
+
: String(tokens);
|
|
259
|
+
|
|
210
260
|
const names = (entries) => entries.map((entry) => entry.name).join(", ");
|
|
211
261
|
|
|
212
262
|
/**
|
|
@@ -281,6 +331,11 @@ export function cardLine(card, now = Date.now(), { evidence = true } = {}) {
|
|
|
281
331
|
parts.push(
|
|
282
332
|
`On this board: ${done} done, ${failed} failed${ended ? ` (${ended} of them when its process or its model's provider failed, not the work itself)` : ""}${medianMinutes === null ? "" : `; a median of ${span(medianMinutes)} from start to report`}.`
|
|
283
333
|
);
|
|
334
|
+
const cost = card.record.cost;
|
|
335
|
+
if (cost)
|
|
336
|
+
parts.push(
|
|
337
|
+
`Its finished runs used a median of ${tokensWords(cost.medianTokens)} tokens${cost.medianUsd === null ? "" : ` ($${cost.medianUsd.toFixed(2)})`}, over its latest ${cost.runs}.`
|
|
338
|
+
);
|
|
284
339
|
const verdicts = card.record.verdicts;
|
|
285
340
|
if (verdicts)
|
|
286
341
|
parts.push(
|