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.
- 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 +259 -6
- package/lib/boardTools.mjs +2 -6
- package/lib/bridge.mjs +27 -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 +16 -2
- package/lib/coreModels.mjs +78 -0
- package/lib/daemon.mjs +775 -46
- 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 +61 -12
- 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 +180 -98
- 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 +38 -1
- 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/projectGit.mjs +328 -0
- package/lib/projectSettings.mjs +120 -0
- package/lib/projects.mjs +2539 -0
- 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 +559 -30
- package/lib/subagents.mjs +8 -4
- package/lib/swarm.mjs +379 -38
- package/lib/swarmMemory.mjs +947 -0
- package/lib/t3.mjs +43 -13
- package/lib/taskCommands.mjs +58 -5
- package/lib/taskRuns.mjs +61 -11
- package/lib/team.json +17 -15
- package/lib/team.mjs +68 -18
- package/lib/threadRuns.mjs +50 -7
- package/lib/threadView.mjs +68 -15
- 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/ui.mjs
CHANGED
|
@@ -87,8 +87,12 @@ export function createUi({
|
|
|
87
87
|
info: (text) => p.log.info(fit(text)),
|
|
88
88
|
warn: (text) => p.log.warn(fit(text)),
|
|
89
89
|
message: (text) => p.log.message(fit(text)),
|
|
90
|
-
note
|
|
90
|
+
// A boxed note draws its own border, so its lines wrap a little narrower than the rail's.
|
|
91
|
+
note: (text, title) =>
|
|
92
|
+
p.note(wrap(text, Math.max(40, columns() - 10)).join("\n"), title),
|
|
91
93
|
select: async (opts) => answer(await p.select(opts)),
|
|
94
|
+
multiselect: async (opts) =>
|
|
95
|
+
answer(await p.multiselect({ required: false, ...opts })),
|
|
92
96
|
text: async (opts) => answer(await p.text(opts)),
|
|
93
97
|
password: async (opts) => answer(await p.password(opts)),
|
|
94
98
|
confirm: async (opts) => answer(await p.confirm(opts)),
|
|
@@ -157,6 +161,16 @@ export function scriptedUi(answers = [], lines = []) {
|
|
|
157
161
|
);
|
|
158
162
|
return next(opts.initialValue ?? opts.options[0].value);
|
|
159
163
|
},
|
|
164
|
+
multiselect: async (opts) => {
|
|
165
|
+
lines.push(
|
|
166
|
+
`? ${opts.message}`,
|
|
167
|
+
...opts.options.map(
|
|
168
|
+
(option) =>
|
|
169
|
+
` [${opts.initialValues?.includes(option.value) ? "x" : " "}] ${option.label}${option.hint ? ` (${option.hint})` : ""}`
|
|
170
|
+
)
|
|
171
|
+
);
|
|
172
|
+
return next(opts.initialValues ?? []);
|
|
173
|
+
},
|
|
160
174
|
text: ask,
|
|
161
175
|
password: async (opts) => {
|
|
162
176
|
lines.push(`? ${opts.message}`);
|
|
@@ -168,7 +182,7 @@ export function scriptedUi(answers = [], lines = []) {
|
|
|
168
182
|
},
|
|
169
183
|
spinner: () => ({
|
|
170
184
|
start: say("◒"),
|
|
171
|
-
message: ()
|
|
185
|
+
message: say("◒"),
|
|
172
186
|
stop: (text, code = 0) => say(code ? "▲" : "◇")(text),
|
|
173
187
|
}),
|
|
174
188
|
waitOrType: async ({ message, until }) => {
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { MEMBERS } from "./members.mjs";
|
|
3
|
+
|
|
4
|
+
// Once a day, the home computer sends Harness the board's finished days as anonymous totals:
|
|
5
|
+
// counts under fixed names, split by agent type. No text, task ids, folders or computer details
|
|
6
|
+
// leave, and the server adds each report into the day's sums without the account
|
|
7
|
+
// (src/server/bridge/usageTotals.ts). `npx tryharness usage-totals off` stops it; days while it
|
|
8
|
+
// is off are never sent.
|
|
9
|
+
//
|
|
10
|
+
// board_meta "usage-totals" keeps the last day handled and the report waiting to be sent, whose
|
|
11
|
+
// random id is reused on a resend so the server can refuse a repeat.
|
|
12
|
+
|
|
13
|
+
const STATE_KEY = "usage-totals";
|
|
14
|
+
const CHECK_MS = 60 * 60 * 1000;
|
|
15
|
+
// A computer off for longer than this sends only its most recent days.
|
|
16
|
+
const CATCH_UP_DAYS = 30;
|
|
17
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
18
|
+
// Refusals the server will repeat however often the report is sent.
|
|
19
|
+
const FINAL_REFUSALS = new Set(["invalid_report", "day_out_of_range"]);
|
|
20
|
+
|
|
21
|
+
const KNOWN_AGENTS = new Set(MEMBERS.map((member) => member.id));
|
|
22
|
+
|
|
23
|
+
const dayOf = (date) => date.toISOString().slice(0, 10);
|
|
24
|
+
const nextDay = (day) => dayOf(new Date(Date.parse(day) + DAY_MS));
|
|
25
|
+
const daysBefore = (day, count) =>
|
|
26
|
+
dayOf(new Date(Date.parse(day) - count * DAY_MS));
|
|
27
|
+
|
|
28
|
+
// A custom agent's name could identify its owner; only roster agent types are named.
|
|
29
|
+
const agentType = (name) => (KNOWN_AGENTS.has(name) ? name : "other");
|
|
30
|
+
|
|
31
|
+
const sumOf = (rows) => rows.reduce((sum, row) => sum + row.count, 0);
|
|
32
|
+
const countOf = (rows, name) =>
|
|
33
|
+
rows.find((row) => row.name === name)?.count ?? 0;
|
|
34
|
+
|
|
35
|
+
export function reportOfDay(usage) {
|
|
36
|
+
const agentPosts = usage.posts.filter((row) => row.name !== "user");
|
|
37
|
+
const totals = {
|
|
38
|
+
tasks_posted: sumOf(usage.posted),
|
|
39
|
+
handoffs: usage.handoffs,
|
|
40
|
+
tasks_done: sumOf(usage.done),
|
|
41
|
+
tasks_failed: sumOf(usage.failed),
|
|
42
|
+
threads_started: usage.threadsStarted,
|
|
43
|
+
agent_posts: sumOf(agentPosts),
|
|
44
|
+
person_posts: countOf(usage.posts, "user"),
|
|
45
|
+
rounds: sumOf(usage.rounds),
|
|
46
|
+
rounds_handed_on: countOf(usage.rounds, "hand_on"),
|
|
47
|
+
rounds_asked_person: countOf(usage.rounds, "ask_person"),
|
|
48
|
+
};
|
|
49
|
+
const byAgent = {};
|
|
50
|
+
const add = (rows, metric) => {
|
|
51
|
+
for (const row of rows) {
|
|
52
|
+
if (!row.name) continue;
|
|
53
|
+
const agent = agentType(row.name);
|
|
54
|
+
byAgent[agent] ??= {};
|
|
55
|
+
byAgent[agent][metric] = (byAgent[agent][metric] ?? 0) + row.count;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
add(usage.posted, "tasks_posted");
|
|
59
|
+
add(usage.done, "tasks_done");
|
|
60
|
+
add(usage.failed, "tasks_failed");
|
|
61
|
+
add(agentPosts, "agent_posts");
|
|
62
|
+
return { totals, byAgent };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const isEmpty = (report) =>
|
|
66
|
+
Object.values(report.totals).every((value) => value === 0);
|
|
67
|
+
|
|
68
|
+
export function createUsageTotals({
|
|
69
|
+
store,
|
|
70
|
+
send,
|
|
71
|
+
canSend,
|
|
72
|
+
enabled,
|
|
73
|
+
log,
|
|
74
|
+
now = () => new Date(),
|
|
75
|
+
}) {
|
|
76
|
+
let timer = null;
|
|
77
|
+
let sending = null;
|
|
78
|
+
|
|
79
|
+
const readState = () => {
|
|
80
|
+
try {
|
|
81
|
+
return JSON.parse(store.meta(STATE_KEY) ?? "null");
|
|
82
|
+
} catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const writeState = (state) => store.meta(STATE_KEY, JSON.stringify(state));
|
|
87
|
+
|
|
88
|
+
// The first day a new install counts is today: the board's history before it is not sent.
|
|
89
|
+
const firstState = () => {
|
|
90
|
+
const state = { through: daysBefore(dayOf(now()), 1) };
|
|
91
|
+
writeState(state);
|
|
92
|
+
return state;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
async function sendDay(day, state) {
|
|
96
|
+
const report = reportOfDay(store.usageOfDay(day));
|
|
97
|
+
if (isEmpty(report)) return true;
|
|
98
|
+
const reportId =
|
|
99
|
+
state.pending?.day === day ? state.pending.reportId : randomUUID();
|
|
100
|
+
writeState({ ...state, pending: { day, reportId } });
|
|
101
|
+
const reply = await send({ reportId, day, ...report });
|
|
102
|
+
if (reply?.ok) return true;
|
|
103
|
+
if (FINAL_REFUSALS.has(reply?.error)) {
|
|
104
|
+
log?.(`usage totals for ${day} refused: ${reply.error}`);
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function sendDueDays() {
|
|
111
|
+
const yesterday = daysBefore(dayOf(now()), 1);
|
|
112
|
+
const state = readState() ?? firstState();
|
|
113
|
+
if (!enabled()) {
|
|
114
|
+
if (state.through < yesterday) writeState({ through: yesterday });
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (!canSend()) return;
|
|
118
|
+
const oldest = daysBefore(yesterday, CATCH_UP_DAYS - 1);
|
|
119
|
+
let day = state.through < oldest ? oldest : nextDay(state.through);
|
|
120
|
+
while (day <= yesterday) {
|
|
121
|
+
const current = readState() ?? state;
|
|
122
|
+
const handled = await sendDay(day, current).catch(() => false);
|
|
123
|
+
if (!handled) return;
|
|
124
|
+
writeState({ through: day });
|
|
125
|
+
day = nextDay(day);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function sendDue() {
|
|
130
|
+
sending ??= sendDueDays().finally(() => {
|
|
131
|
+
sending = null;
|
|
132
|
+
});
|
|
133
|
+
return sending;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
sendDue,
|
|
138
|
+
start() {
|
|
139
|
+
if (timer) return;
|
|
140
|
+
timer = setInterval(() => void sendDue(), CHECK_MS);
|
|
141
|
+
timer.unref?.();
|
|
142
|
+
},
|
|
143
|
+
stop() {
|
|
144
|
+
clearInterval(timer);
|
|
145
|
+
timer = null;
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|