@simplr-ai/connect 0.7.7 → 0.7.8

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.js +40 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -178,6 +178,11 @@ function matchesCommandAcknowledgement(commandId, status, acknowledgement) {
178
178
  function isHermesRunCancellation(message) {
179
179
  return message === "Hermes run cancelled" || message === "Hermes run exceeded the 30 minute monitoring window and was stopped";
180
180
  }
181
+ function shouldRestartHermesForExecutionTools(restartPending, journalStatuses) {
182
+ return restartPending && !journalStatuses.some(
183
+ (status) => ["preparing", "creating", "running", "waiting_approval"].includes(status)
184
+ );
185
+ }
181
186
  function workOrderPayload(classification) {
182
187
  return {
183
188
  ...classification.work_order_kind ? { work_order_kind: classification.work_order_kind } : {},
@@ -252,7 +257,14 @@ var KanbanReconciliationError = class extends Error {
252
257
  };
253
258
  var DeferredUpdateError = class extends Error {
254
259
  };
255
- var APP_VERSION = "0.7.7";
260
+ var HermesRequestError = class extends Error {
261
+ constructor(message, status) {
262
+ super(message);
263
+ this.status = status;
264
+ }
265
+ status;
266
+ };
267
+ var APP_VERSION = "0.7.8";
256
268
  var STANDALONE_EXECUTABLE = process.env.SIMPLR_CONNECT_STANDALONE === "true";
257
269
  var MANIFEST_PUBLIC_KEY = process.env.SIMPLR_CONNECT_MANIFEST_PUBLIC_KEY || "";
258
270
  var HERMES_INSTALL_COMMIT = "542e146b055f0d43767ac43cdb9e78054b240263";
@@ -1376,7 +1388,10 @@ async function hermesRequest(state, path, options = {}) {
1376
1388
  }
1377
1389
  );
1378
1390
  if (!response.ok)
1379
- throw new Error(`Hermes request failed (${response.status})`);
1391
+ throw new HermesRequestError(
1392
+ `Hermes request failed (${response.status})`,
1393
+ response.status
1394
+ );
1380
1395
  return await response.json();
1381
1396
  }
1382
1397
  async function streamHermesRunEvents(state, command, runId) {
@@ -2434,7 +2449,11 @@ async function monitorHermesRun(state, command, runId, startedAt) {
2434
2449
  `/v1/runs/${encodeURIComponent(runId)}`
2435
2450
  );
2436
2451
  consecutivePollFailures = 0;
2437
- } catch {
2452
+ } catch (error) {
2453
+ if (error instanceof HermesRequestError && error.status === 404)
2454
+ throw new Error(
2455
+ "Hermes run is no longer available after a gateway restart"
2456
+ );
2438
2457
  consecutivePollFailures += 1;
2439
2458
  if (consecutivePollFailures >= 3) {
2440
2459
  await repairConnector(state);
@@ -3031,6 +3050,18 @@ async function reconcileIncompleteCompletedRuns(state) {
3031
3050
  );
3032
3051
  }
3033
3052
  }
3053
+ async function restartHermesForExecutionToolsWhenIdle(state) {
3054
+ const journal = await loadCommandJournal();
3055
+ if (!shouldRestartHermesForExecutionTools(
3056
+ Boolean(state.hermes_execution_tools_restart_pending),
3057
+ Object.values(journal).map((entry) => entry.status)
3058
+ ))
3059
+ return false;
3060
+ await restartHermesGateway(state);
3061
+ state.hermes_execution_tools_restart_pending = false;
3062
+ await saveState(state);
3063
+ return true;
3064
+ }
3034
3065
  async function serviceInstallationPresent() {
3035
3066
  try {
3036
3067
  await access(serviceExecutablePath(), constants.R_OK);
@@ -3087,7 +3118,11 @@ async function watch() {
3087
3118
  );
3088
3119
  const executionToolsChanged = await ensureHermesExecutionTools(state);
3089
3120
  await ensureSimplrMcpConfiguration(state);
3090
- if (executionToolsChanged) await restartHermesGateway(state);
3121
+ if (executionToolsChanged) {
3122
+ state.hermes_execution_tools_restart_pending = true;
3123
+ await saveState(state);
3124
+ }
3125
+ await restartHermesForExecutionToolsWhenIdle(state);
3091
3126
  await reconcileIncompleteCompletedRuns(state);
3092
3127
  await resumeHermesRuns(state);
3093
3128
  let nextInventoryAt = 0;
@@ -3101,6 +3136,7 @@ async function watch() {
3101
3136
  nextServiceAuditAt = Date.now() + 15 * 6e4;
3102
3137
  }
3103
3138
  if (Date.now() >= nextHermesAuditAt) {
3139
+ await restartHermesForExecutionToolsWhenIdle(state);
3104
3140
  for (const connection of state.connections.filter(
3105
3141
  (item) => item.setup_status !== "ready"
3106
3142
  )) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplr-ai/connect",
3
- "version": "0.7.7",
3
+ "version": "0.7.8",
4
4
  "description": "Simplr Connect workstation enrollment and AI tool inventory companion",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",