@herdingchats/friday 0.1.538 → 0.1.541

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 (2) hide show
  1. package/herd.mjs +24 -8
  2. package/package.json +2 -2
package/herd.mjs CHANGED
@@ -18,7 +18,7 @@ var __export = (target, all) => {
18
18
  var define_HERD_PACKAGE_default;
19
19
  var init_define_HERD_PACKAGE = __esm({
20
20
  "<define:HERD_PACKAGE>"() {
21
- define_HERD_PACKAGE_default = { version: "0.1.538", gitHead: "ddb7331693c41a23a60c6f16eefa82f7adc09860" };
21
+ define_HERD_PACKAGE_default = { version: "0.1.541", gitHead: "ca2d136a1b409a0d993ead45879528bb25fd4ac5" };
22
22
  }
23
23
  });
24
24
 
@@ -4733,6 +4733,7 @@ async function permissionHook(raw, options = {}) {
4733
4733
  var ACTIVATION_DEADLINE_MS = 3 * 60 * 1e3;
4734
4734
  var ACTIVATION_POLL_MS = 500;
4735
4735
  var SIGN_IN_RESTART_MS = 20 * 1e3;
4736
+ var KILL_WAIT_MS = 5e3;
4736
4737
  var BUSY_POLL_MS = 2e3;
4737
4738
  var activationPrompt = (code) => `herd is checking that you can work from its terminals. Run \`herd activate ${code}\` now, then stop.`;
4738
4739
  var CODE_LETTERS = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
@@ -4939,10 +4940,19 @@ var Activator = class {
4939
4940
  let startedAt = 0;
4940
4941
  let prompted = false;
4941
4942
  let signingIn = wasSignedOut;
4943
+ const stillRunning = async () => (await terminals.list().catch(() => [])).some(
4944
+ (t) => t.name === current.terminal && !t.exited
4945
+ );
4942
4946
  const start = async () => {
4943
- const existing = (await terminals.list()).find((t) => t.name === current.terminal);
4944
- if (existing) await terminals.kill(current.terminal).catch(() => {
4945
- });
4947
+ if (await stillRunning()) {
4948
+ await terminals.kill(current.terminal).catch(() => {
4949
+ });
4950
+ const until = Date.now() + (this.options.killWaitMs ?? KILL_WAIT_MS);
4951
+ while (await stillRunning()) {
4952
+ if (Date.now() >= until) return;
4953
+ await new Promise((resolve6) => setTimeout(resolve6, Math.min(pollMs, 100)));
4954
+ }
4955
+ }
4946
4956
  const shell = process.env.SHELL ?? "/bin/sh";
4947
4957
  await terminals.create({
4948
4958
  name: current.terminal,
@@ -5918,8 +5928,8 @@ var Supervisor = class {
5918
5928
  failures = 0;
5919
5929
  restartTimer = null;
5920
5930
  checkTimer = null;
5921
- /** Releases that failed to install, so each is logged once rather than every check. */
5922
- failed = /* @__PURE__ */ new Set();
5931
+ /** Releases that failed to install, and when, so each is retried rather than tried every check. */
5932
+ failed = /* @__PURE__ */ new Map();
5923
5933
  status;
5924
5934
  log;
5925
5935
  /** Starts the daemon and the release checks. */
@@ -6066,7 +6076,11 @@ var Supervisor = class {
6066
6076
  return "none";
6067
6077
  }
6068
6078
  const key = `${target} ${integrity ?? ""}`;
6069
- if (this.failed.has(key)) return "failed";
6079
+ const now = this.options.now?.() ?? Date.now();
6080
+ const failedAt = this.failed.get(key);
6081
+ if (failedAt !== void 0 && now - failedAt < (this.options.retryFailedMs ?? 10 * 6e4)) {
6082
+ return "failed";
6083
+ }
6070
6084
  const release = takeLock(paths.updateLock);
6071
6085
  if (!release) return "busy";
6072
6086
  try {
@@ -6076,7 +6090,9 @@ var Supervisor = class {
6076
6090
  log: this.log
6077
6091
  });
6078
6092
  if (!installed.ok) {
6079
- this.failed.add(key);
6093
+ const again = failedAt !== void 0;
6094
+ this.failed.set(key, now);
6095
+ if (again) return "failed";
6080
6096
  return this.problem(`Staying on ${current}: ${target} ${installed.reason}`);
6081
6097
  }
6082
6098
  activate(paths, target);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herdingchats/friday",
3
- "version": "0.1.538",
3
+ "version": "0.1.541",
4
4
  "description": "Friday, HerdingChats' agent daemon, and the herd command it runs agents with.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,5 +22,5 @@
22
22
  "satori": "0.32.0",
23
23
  "zod": "4.6.7"
24
24
  },
25
- "gitHead": "ddb7331693c41a23a60c6f16eefa82f7adc09860"
25
+ "gitHead": "ca2d136a1b409a0d993ead45879528bb25fd4ac5"
26
26
  }