@herdingchats/friday 0.1.550 → 0.1.556

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 +19 -6
  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.550", gitHead: "8fdd8ce87ad61c0e396cc832c6e165e69c6fde22" };
21
+ define_HERD_PACKAGE_default = { version: "0.1.556", gitHead: "1dcf65d7fd6285d076e72e3d28475c4bd04eae8e" };
22
22
  }
23
23
  });
24
24
 
@@ -5343,20 +5343,22 @@ init_define_HERD_PACKAGE();
5343
5343
  import { spawn as spawn2 } from "node:child_process";
5344
5344
  import { existsSync as existsSync6, mkdirSync as mkdirSync7, openSync as openSync3, readFileSync as readFileSync7, rmSync as rmSync7, writeFileSync as writeFileSync7 } from "node:fs";
5345
5345
  import { userInfo } from "node:os";
5346
- import { dirname as dirname7, join as join9 } from "node:path";
5346
+ import { dirname as dirname7, join as join9, win32 } from "node:path";
5347
+ var systemdBooted = () => existsSync6("/run/systemd/system");
5347
5348
  var LAUNCH_AGENT = "com.herdingchats.friday";
5348
5349
  var SYSTEMD_UNIT = "herdingchats-friday.service";
5349
- async function detectService(run4, platform2 = process.platform, override = process.env.HERD_SERVICE) {
5350
+ async function detectService(run4, platform2 = process.platform, override = process.env.HERD_SERVICE, booted = systemdBooted) {
5350
5351
  if (override === "launchd" || override === "systemd" || override === "background")
5351
5352
  return override;
5352
5353
  if (platform2 === "darwin") return "launchd";
5353
- if (platform2 === "linux") {
5354
+ if (platform2 === "linux" && booted()) {
5354
5355
  const probe = await run4("systemctl", ["--user", "show-environment"], { timeoutMs: 1e4 });
5355
5356
  if (probe.status === 0) return "systemd";
5356
5357
  }
5357
5358
  return "background";
5358
5359
  }
5359
- function servicePath(node) {
5360
+ function servicePath(node, platform2 = process.platform, inherited = process.env.PATH ?? process.env.Path) {
5361
+ if (platform2 === "win32") return [win32.dirname(node), inherited].filter(Boolean).join(";");
5360
5362
  return [
5361
5363
  dirname7(node),
5362
5364
  "/opt/homebrew/bin",
@@ -5490,10 +5492,21 @@ function spawnInBackground(command, env, log) {
5490
5492
  const [program = process.execPath, ...args] = command;
5491
5493
  spawn2(program, args, {
5492
5494
  detached: true,
5495
+ // On Windows, a detached process otherwise opens a console window of its own.
5496
+ windowsHide: true,
5493
5497
  stdio: ["ignore", out, out],
5494
- env: { ...process.env, ...env }
5498
+ env: mergeEnv(process.env, env)
5495
5499
  }).unref();
5496
5500
  }
5501
+ function mergeEnv(base, extra) {
5502
+ const replaced = new Set(Object.keys(extra).map((key) => key.toUpperCase()));
5503
+ const merged = {};
5504
+ for (const [key, value] of Object.entries(base)) {
5505
+ if (value !== void 0 && !(key.toUpperCase() === "PATH" && replaced.has("PATH")))
5506
+ merged[key] = value;
5507
+ }
5508
+ return { ...merged, ...extra };
5509
+ }
5497
5510
  function background(context2) {
5498
5511
  const launch = context2.spawnBackground ?? spawnInBackground;
5499
5512
  const supervisor = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herdingchats/friday",
3
- "version": "0.1.550",
3
+ "version": "0.1.556",
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": "8fdd8ce87ad61c0e396cc832c6e165e69c6fde22"
25
+ "gitHead": "1dcf65d7fd6285d076e72e3d28475c4bd04eae8e"
26
26
  }