@merittdev/horus 0.8.1 → 0.8.3

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/dist/index.cjs +46 -11
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -65880,8 +65880,8 @@ init_cjs_shims();
65880
65880
 
65881
65881
  // ../../packages/core/src/version.ts
65882
65882
  init_cjs_shims();
65883
- var HORUS_VERSION = true ? "0.8.1" : "dev";
65884
- var PINNED_SOURCE_VERSION = "1.4.0";
65883
+ var HORUS_VERSION = true ? "0.8.3" : "dev";
65884
+ var PINNED_SOURCE_VERSION = "1.5.0";
65885
65885
 
65886
65886
  // ../../packages/core/src/evidence.ts
65887
65887
  init_cjs_shims();
@@ -71100,6 +71100,21 @@ function removeSpawnedHostRecord(root) {
71100
71100
  } catch {
71101
71101
  }
71102
71102
  }
71103
+ function reconcileSpawnedHostPid(root, port) {
71104
+ try {
71105
+ const backend = readSourceHostPid(root);
71106
+ if (!backend || !Number.isInteger(backend.pid) || backend.pid <= 0) return;
71107
+ if (Number.isFinite(backend.port) && backend.port !== port) return;
71108
+ const spawned = readSpawnedHost(root);
71109
+ if (!spawned || spawned.pid === backend.pid) return;
71110
+ const updated = { ...spawned, pid: backend.pid };
71111
+ (0, import_node_fs3.writeFileSync)(
71112
+ (0, import_node_path3.join)(root, ".horus", SPAWNED_HOST_FILE),
71113
+ JSON.stringify(updated, null, 2) + "\n"
71114
+ );
71115
+ } catch {
71116
+ }
71117
+ }
71103
71118
  async function waitForHost(hostUrl, timeoutMs = 45e3) {
71104
71119
  const deadline = Date.now() + timeoutMs;
71105
71120
  while (Date.now() < deadline) {
@@ -97166,6 +97181,7 @@ async function runIndex(opts) {
97166
97181
  );
97167
97182
  return 1;
97168
97183
  }
97184
+ reconcileSpawnedHostPid(root, port);
97169
97185
  }
97170
97186
  await stitchQueueMap(hostUrl, dbUrl, label);
97171
97187
  buildKnowledgeIndex(root, config2, label, configuredProject, opts);
@@ -110127,7 +110143,10 @@ async function ensureSourceHost(root, hostUrl, opts = {}) {
110127
110143
  const port = parseHostPort(hostUrl);
110128
110144
  if (port === null) return { ok: false, reason: "bad-url" };
110129
110145
  startHost(root, port);
110130
- if (await waitForHost(hostUrl, opts.timeoutMs ?? 2e4)) return { ok: true, hostUrl };
110146
+ if (await waitForHost(hostUrl, opts.timeoutMs ?? 2e4)) {
110147
+ reconcileSpawnedHostPid(root, port);
110148
+ return { ok: true, hostUrl };
110149
+ }
110131
110150
  removeSpawnedHostRecord(root);
110132
110151
  return { ok: false, reason: "unhealthy" };
110133
110152
  }
@@ -113800,18 +113819,34 @@ function validateSpawnedRecord(r) {
113800
113819
  return null;
113801
113820
  }
113802
113821
  async function getProcessInfo(pid) {
113822
+ let args2;
113803
113823
  try {
113804
- const [argsResult, etimeResult] = await Promise.all([
113805
- execFileAsync("ps", ["-p", String(pid), "-o", "args="], { timeout: 3e3 }),
113806
- execFileAsync("ps", ["-p", String(pid), "-o", "etimes="], { timeout: 3e3 })
113807
- ]);
113808
- const args2 = argsResult.stdout.trim();
113809
- const etimeSeconds = parseInt(etimeResult.stdout.trim(), 10);
113810
- if (!args2 || isNaN(etimeSeconds)) return null;
113811
- return { args: args2, etimeSeconds };
113824
+ const argsResult = await execFileAsync("ps", ["-p", String(pid), "-o", "args="], {
113825
+ timeout: 3e3
113826
+ });
113827
+ args2 = argsResult.stdout.trim();
113812
113828
  } catch {
113813
113829
  return null;
113814
113830
  }
113831
+ if (!args2) return null;
113832
+ let etimeSeconds = Number.NaN;
113833
+ try {
113834
+ const etimeResult = await execFileAsync("ps", ["-p", String(pid), "-o", "etime="], {
113835
+ timeout: 3e3
113836
+ });
113837
+ etimeSeconds = parseEtimeSeconds(etimeResult.stdout.trim());
113838
+ } catch {
113839
+ }
113840
+ return { args: args2, etimeSeconds };
113841
+ }
113842
+ function parseEtimeSeconds(etime) {
113843
+ const m5 = etime.match(/^(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+)$/);
113844
+ if (!m5) return Number.NaN;
113845
+ const days = m5[1] ? Number(m5[1]) : 0;
113846
+ const hours = m5[2] ? Number(m5[2]) : 0;
113847
+ const minutes = Number(m5[3]);
113848
+ const seconds = Number(m5[4]);
113849
+ return days * 86400 + hours * 3600 + minutes * 60 + seconds;
113815
113850
  }
113816
113851
  function extractPort(hostUrl) {
113817
113852
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merittdev/horus",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "Local-first, source-aware production-incident investigation engine",
5
5
  "type": "module",
6
6
  "bin": {