benignswarm 0.12.64 → 0.12.65
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/dist/commands/machine.js +44 -1
- package/dist/commands/watch.js +6 -2
- package/dist/harness.js +9 -4
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/commands/machine.js
CHANGED
|
@@ -126,7 +126,8 @@ export async function reconcile(m, log) {
|
|
|
126
126
|
delete state.sessions[id];
|
|
127
127
|
}
|
|
128
128
|
writeMachineState(state);
|
|
129
|
-
const
|
|
129
|
+
const clones = refreshClones(workdir, [...new Set(desired.filter((s) => !s.dir && s.project && s.desired === "running").map((s) => s.project))], log);
|
|
130
|
+
const report = { ...machineFacts(), workdir: workdir ?? join(homedir(), "bschat"), workdir_free_bytes: freeBytes(workdir ?? homedir()), clones };
|
|
130
131
|
await client.call("POST", "/machines/me/report", { report, sessions: out });
|
|
131
132
|
return { sessions: out, report };
|
|
132
133
|
}
|
|
@@ -197,6 +198,48 @@ export function ensureCheckout(s, log, workdir = null) {
|
|
|
197
198
|
return { dir };
|
|
198
199
|
}
|
|
199
200
|
const shq = (x) => `'${x.replace(/'/g, `'\\''`)}'`;
|
|
201
|
+
const CLONE_REFRESH_MS = 10 * 60_000;
|
|
202
|
+
let clonesRefreshedAt = 0;
|
|
203
|
+
/** Tests reset the 10-minute throttle. */
|
|
204
|
+
export const resetCloneRefresh = () => { clonesRefreshedAt = 0; };
|
|
205
|
+
let lastClones = {};
|
|
206
|
+
/**
|
|
207
|
+
* Keeps each project clone's checked-out branch current: fetch, then fast-forward when it is clean.
|
|
208
|
+
* Unless a project requires pushed work, wu start branches from the clone's local target, so a
|
|
209
|
+
* clone made once went stale (ronald's benignswarm clone was 52 commits behind GitHub within a day).
|
|
210
|
+
* Anything it cannot fast-forward is reported, never forced.
|
|
211
|
+
*/
|
|
212
|
+
export function refreshClones(workdir, projects, log) {
|
|
213
|
+
if (Date.now() - clonesRefreshedAt < CLONE_REFRESH_MS)
|
|
214
|
+
return lastClones;
|
|
215
|
+
clonesRefreshedAt = Date.now();
|
|
216
|
+
const out = {};
|
|
217
|
+
for (const p of projects) {
|
|
218
|
+
const base = join(workdir ?? join(homedir(), "bschat"), p, "main");
|
|
219
|
+
if (!existsSync(join(base, ".git")))
|
|
220
|
+
continue;
|
|
221
|
+
const branch = (git(["rev-parse", "--abbrev-ref", "HEAD"], base).stdout ?? "").trim();
|
|
222
|
+
if (git(["fetch", "-q", "origin"], base).status !== 0) {
|
|
223
|
+
out[p] = { branch, behind: -1, note: "fetch failed" };
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
const behind = Number((git(["rev-list", "--count", `HEAD..origin/${branch}`], base).stdout ?? "0").trim()) || 0;
|
|
227
|
+
if (behind > 0) {
|
|
228
|
+
const dirty = (git(["status", "--porcelain"], base).stdout ?? "").trim() !== "";
|
|
229
|
+
const ff = dirty ? null : git(["merge", "-q", "--ff-only", `origin/${branch}`], base);
|
|
230
|
+
if (ff && ff.status === 0) {
|
|
231
|
+
log(`${p}: clone fast-forwarded ${behind} commit(s) to origin/${branch}`);
|
|
232
|
+
out[p] = { branch, behind: 0 };
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
out[p] = { branch, behind, note: dirty ? "clone has local changes; not fast-forwarded" : "not a fast-forward of origin" };
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
out[p] = { branch, behind: 0 };
|
|
239
|
+
}
|
|
240
|
+
lastClones = out;
|
|
241
|
+
return out;
|
|
242
|
+
}
|
|
200
243
|
/** Saves the agent's key on first use, and replaces it when the server no longer accepts it. */
|
|
201
244
|
async function ensureCredentials(client, m, s, local, log) {
|
|
202
245
|
let saved = true;
|
package/dist/commands/watch.js
CHANGED
|
@@ -337,8 +337,12 @@ async function deliver(name, exec, wake, summary, tier, total, log, prefix, seq,
|
|
|
337
337
|
*/
|
|
338
338
|
function stopRevokedWatcher(name, log) {
|
|
339
339
|
const label = `${WATCH_LABEL_PREFIX}${name.replace("/", ".")}`;
|
|
340
|
-
|
|
341
|
-
|
|
340
|
+
// By label, else by the --as it runs with: watchers installed before 0.9 carry labels without the
|
|
341
|
+
// project (org.benignswarm.watch.visualizer-creator), and missing them left a restart loop.
|
|
342
|
+
const bare = name.split("/").pop();
|
|
343
|
+
const svc = watcherServices().find((s) => s.label === label)
|
|
344
|
+
?? watcherServices().find((s) => { const a = s.args ?? []; const i = a.indexOf("--as"); return a[1] === "watch" && i >= 0 && (a[i + 1] === name || a[i + 1] === bare); });
|
|
345
|
+
log(`this agent's key was revoked (moved to another machine, or retired): stopping and removing ${svc?.label ?? `${label} (no service found; exiting)`}`);
|
|
342
346
|
if (svc)
|
|
343
347
|
removeService(svc); // ends this process when it unloads the service
|
|
344
348
|
process.exit(0);
|
package/dist/harness.js
CHANGED
|
@@ -84,13 +84,18 @@ export function upsertBlock(path, body) {
|
|
|
84
84
|
else
|
|
85
85
|
writeFileSync(path, (cur.endsWith("\n") || cur === "" ? cur : cur + "\n") + "\n" + block);
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
/**
|
|
88
|
+
* The section join writes into AGENTS.md / GEMINI.md. Those files are usually committed and read on
|
|
89
|
+
* every machine, so it names no path: a Mac's /opt/homebrew/bin/bschat in a committed AGENTS.md
|
|
90
|
+
* pointed agents on a Linux machine at nothing. Each machine records its install in install.json.
|
|
91
|
+
*/
|
|
92
|
+
function pointer(_name, apiUrl, _bin) {
|
|
88
93
|
return [
|
|
89
94
|
`## bschat: agent chat for this project`,
|
|
90
95
|
``,
|
|
91
|
-
`This repo's agents coordinate on BenignSwarm with the \`bschat\` command, installed
|
|
92
|
-
`machine
|
|
93
|
-
`and do not use npx). Your identity for this repo is recorded in \`.bschat/identity.json\``,
|
|
96
|
+
`This repo's agents coordinate on BenignSwarm with the \`bschat\` command, installed once per`,
|
|
97
|
+
`machine (if \`bschat\` is not on your PATH, \`~/.bschat/install.json\` names this machine's copy;`,
|
|
98
|
+
`do not install another, and do not use npx). Your identity for this repo is recorded in \`.bschat/identity.json\``,
|
|
94
99
|
`(vendor -> agent name), so it works without env vars. If you are told you are a different agent,`,
|
|
95
100
|
`export BSCHAT_AGENT=<project>/<name>.`,
|
|
96
101
|
``,
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = "0.12.
|
|
1
|
+
export const CLI_VERSION = "0.12.65";
|