@hermespilot/link 0.5.3 → 0.5.5

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.
@@ -4502,7 +4502,7 @@ import os2 from "os";
4502
4502
  import path5 from "path";
4503
4503
 
4504
4504
  // src/constants.ts
4505
- var LINK_VERSION = "0.5.3";
4505
+ var LINK_VERSION = "0.5.5";
4506
4506
  var LINK_COMMAND = "hermeslink";
4507
4507
  var LINK_DEFAULT_PORT = 52379;
4508
4508
  var LINK_RUNTIME_DIR_NAME = ".hermeslink";
@@ -24459,6 +24459,8 @@ var UPDATE_FETCH_TIMEOUT_MS = 5e3;
24459
24459
  var MAX_UPDATE_LOG_LINES2 = 240;
24460
24460
  var MAX_OUTPUT_LINE_LENGTH3 = 1200;
24461
24461
  var AUTO_RESTART_DELAY_MS = 1500;
24462
+ var RUNNING_STATE_GRACE_MS = 1e4;
24463
+ var LINK_UPDATE_TIMEOUT_MS = 15 * 60 * 1e3;
24462
24464
  var updateEvents2 = new EventEmitter4();
24463
24465
  var runningUpdate2 = null;
24464
24466
  async function readLinkUpdateCheck(options) {
@@ -24609,9 +24611,36 @@ async function startLinkUpdate(options) {
24609
24611
  child.stderr?.on("data", (chunk) => {
24610
24612
  void appendChunk(chunk);
24611
24613
  });
24614
+ let timedOut = false;
24615
+ const timeoutTimer = setTimeout(() => {
24616
+ timedOut = true;
24617
+ void (async () => {
24618
+ const failed = {
24619
+ ...started,
24620
+ state: "failed",
24621
+ finished_at: now().toISOString(),
24622
+ error: linkUpdateTimeoutError()
24623
+ };
24624
+ await writer.write(`
24625
+ [failed] ${failed.error}
24626
+ `);
24627
+ await writeUpdateState2(options.paths, failed);
24628
+ await emitUpdateStatus2(options.paths);
24629
+ if (!child.killed) {
24630
+ child.kill("SIGTERM");
24631
+ }
24632
+ void options.logger?.error("link_update_timed_out", {
24633
+ job_id: jobId,
24634
+ target_version: targetVersion,
24635
+ timeout_ms: LINK_UPDATE_TIMEOUT_MS
24636
+ });
24637
+ })();
24638
+ }, LINK_UPDATE_TIMEOUT_MS);
24639
+ timeoutTimer.unref();
24612
24640
  runningUpdate2 = new Promise((resolve) => {
24613
24641
  child.on("error", (error) => {
24614
24642
  void (async () => {
24643
+ clearTimeout(timeoutTimer);
24615
24644
  const failed = {
24616
24645
  ...started,
24617
24646
  state: "failed",
@@ -24635,6 +24664,7 @@ async function startLinkUpdate(options) {
24635
24664
  });
24636
24665
  child.on("close", (code, signal) => {
24637
24666
  void (async () => {
24667
+ clearTimeout(timeoutTimer);
24638
24668
  const succeeded = code === 0;
24639
24669
  const state = {
24640
24670
  ...started,
@@ -24642,7 +24672,7 @@ async function startLinkUpdate(options) {
24642
24672
  finished_at: now().toISOString(),
24643
24673
  exit_code: code,
24644
24674
  signal,
24645
- error: succeeded ? null : `install script exited with code ${code ?? "unknown"}`
24675
+ error: succeeded ? null : timedOut ? linkUpdateTimeoutError() : `install script exited with code ${code ?? "unknown"}`
24646
24676
  };
24647
24677
  await writer.write(
24648
24678
  `
@@ -24713,6 +24743,21 @@ async function readLinkUpdateStatus(paths) {
24713
24743
  };
24714
24744
  await writeUpdateState2(paths, state);
24715
24745
  }
24746
+ if (state?.state === "running" && isRunningStateTimedOut(state)) {
24747
+ const reachedTarget = state.target_version && compareSemver3(LINK_VERSION, state.target_version) >= 0;
24748
+ state = reachedTarget ? {
24749
+ ...state,
24750
+ state: "succeeded",
24751
+ finished_at: (/* @__PURE__ */ new Date()).toISOString(),
24752
+ error: null
24753
+ } : {
24754
+ ...state,
24755
+ state: "failed",
24756
+ finished_at: (/* @__PURE__ */ new Date()).toISOString(),
24757
+ error: state.error ?? linkUpdateTimeoutError()
24758
+ };
24759
+ await writeUpdateState2(paths, state);
24760
+ }
24716
24761
  if (state?.state === "running" && !runningUpdate2 && !isRecentRunningState3(state) && !isProcessAlive4(state.pid)) {
24717
24762
  const reachedTarget = state.target_version && compareSemver3(LINK_VERSION, state.target_version) >= 0;
24718
24763
  state = reachedTarget ? {
@@ -25203,7 +25248,16 @@ function quotePowerShellString(value) {
25203
25248
  }
25204
25249
  function isRecentRunningState3(state, now = Date.now()) {
25205
25250
  const startedAt = state.started_at ? Date.parse(state.started_at) : Number.NaN;
25206
- return Number.isFinite(startedAt) && now - startedAt < 1e4;
25251
+ return Number.isFinite(startedAt) && now - startedAt < RUNNING_STATE_GRACE_MS;
25252
+ }
25253
+ function isRunningStateTimedOut(state, now = Date.now()) {
25254
+ const startedAt = state.started_at ? Date.parse(state.started_at) : Number.NaN;
25255
+ return Number.isFinite(startedAt) && now - startedAt >= LINK_UPDATE_TIMEOUT_MS;
25256
+ }
25257
+ function linkUpdateTimeoutError() {
25258
+ return `Link update timed out after ${Math.round(
25259
+ LINK_UPDATE_TIMEOUT_MS / 6e4
25260
+ )} minutes.`;
25207
25261
  }
25208
25262
  function isProcessAlive4(pid) {
25209
25263
  if (!pid || pid <= 0) {
package/dist/cli/index.js CHANGED
@@ -37,7 +37,7 @@ import {
37
37
  startDaemonProcess,
38
38
  startLinkService,
39
39
  stopDaemonProcess
40
- } from "../chunk-5JBXQ3VC.js";
40
+ } from "../chunk-NPDVJND7.js";
41
41
 
42
42
  // src/cli/index.ts
43
43
  import { Command } from "commander";
package/dist/http/app.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createApp
3
- } from "../chunk-5JBXQ3VC.js";
3
+ } from "../chunk-NPDVJND7.js";
4
4
  export {
5
5
  createApp
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hermespilot/link",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "private": false,
5
5
  "description": "Hermes Link companion service and CLI for connecting hermes-agent through HermesPilot",
6
6
  "license": "MIT",