hermes-agent 0.22.1 → 0.22.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.
@@ -3,12 +3,17 @@ const fs = require("node:fs");
3
3
  const path = require("node:path");
4
4
 
5
5
  const packageJson = require("../package.json");
6
+ const { provisionRuntime } = require("./provision");
6
7
 
7
8
  const packageRoot = path.resolve(__dirname, "..");
9
+ const DEFAULT_RUNTIME_DIRECTORY = "runtime/hermes-agent";
10
+
11
+ function resolveRuntimeSourceDirectory(root, runtimeDirectory = DEFAULT_RUNTIME_DIRECTORY) {
12
+ return path.join(root, ...runtimeDirectory.split("/"));
13
+ }
8
14
 
9
15
  function getRuntimeSourceDirectory() {
10
- const configured = packageJson.hermesAgent?.runtimeDirectory || "runtime/hermes-agent";
11
- return path.join(packageRoot, ...configured.split("/"));
16
+ return resolveRuntimeSourceDirectory(packageRoot, packageJson.hermesAgent?.runtimeDirectory || DEFAULT_RUNTIME_DIRECTORY);
12
17
  }
13
18
 
14
19
  function getVenvDirectory() {
@@ -20,12 +25,16 @@ function normalizeBinName(binName) {
20
25
  return baseName.replace(/(\.cmd|\.exe)$/i, "");
21
26
  }
22
27
 
23
- function getConsoleExecutable(binName, platform = process.platform) {
28
+ function venvConsoleExecutable(venvDirectory, binName, platform = process.platform) {
24
29
  const normalized = normalizeBinName(binName) === "hermes" ? "hermes" : "hermes-agent";
25
30
  if (platform === "win32") {
26
- return path.join(getVenvDirectory(), "Scripts", `${normalized}.exe`);
31
+ return path.join(venvDirectory, "Scripts", `${normalized}.exe`);
27
32
  }
28
- return path.join(getVenvDirectory(), "bin", normalized);
33
+ return path.join(venvDirectory, "bin", normalized);
34
+ }
35
+
36
+ function getConsoleExecutable(binName, platform = process.platform) {
37
+ return venvConsoleExecutable(getVenvDirectory(), binName, platform);
29
38
  }
30
39
 
31
40
  function buildConsoleInvocation(binName, userArgs, platform = process.platform) {
@@ -49,12 +58,57 @@ function getRuntimeEnvironment() {
49
58
  return env;
50
59
  }
51
60
 
61
+ function autoSetupDisabled(env = process.env) {
62
+ return ["0", "false", "no", "off"].includes(String(env.HERMES_NPM_AUTO_SETUP || "").toLowerCase());
63
+ }
64
+
65
+ function printRuntimeNotReady(reason) {
66
+ console.error(`Hermes Agent isolated runtime is not ready${reason ? `: ${reason}` : "."}`);
67
+ console.error("Run 'hermes-npm setup' to install it, or reinstall the npm package.");
68
+ }
69
+
70
+ // npm 12 blocks dependency install scripts by default, so a plain
71
+ // 'npm install' leaves only the command shims. Provision on first launch
72
+ // instead of failing; provisioning output goes to stderr so stdout stays
73
+ // reserved for the Hermes command itself.
74
+ function ensureRuntimeForLaunch(executable, options = {}) {
75
+ if (fs.existsSync(executable)) return true;
76
+ if (autoSetupDisabled(options.env)) {
77
+ printRuntimeNotReady("automatic setup is disabled by HERMES_NPM_AUTO_SETUP");
78
+ return false;
79
+ }
80
+
81
+ const result = (options.provisionRuntime || provisionRuntime)({
82
+ packageRoot: options.packageRoot || packageRoot,
83
+ isReady: () => fs.existsSync(executable),
84
+ stdio: ["ignore", 2, 2],
85
+ onWait: (lock) => {
86
+ console.error(`Waiting for another Hermes Agent setup to finish${lock?.pid ? ` (pid ${lock.pid})` : ""}...`);
87
+ },
88
+ onStart: () => {
89
+ console.error("Hermes Agent runtime is not installed yet; setting it up now (one-time download, usually 1-2 minutes)...");
90
+ }
91
+ });
92
+
93
+ if (result.error) {
94
+ printRuntimeNotReady(result.error);
95
+ return false;
96
+ }
97
+ if (result.status !== 0) {
98
+ printRuntimeNotReady(`setup failed with exit code ${result.status}`);
99
+ return false;
100
+ }
101
+ if (!fs.existsSync(executable)) {
102
+ printRuntimeNotReady(`setup finished but ${executable} is missing`);
103
+ return false;
104
+ }
105
+ return true;
106
+ }
107
+
52
108
  function runHermes(binName, userArgs, stdio = "inherit") {
53
109
  const invocation = buildConsoleInvocation(binName, userArgs);
54
110
 
55
- if (!fs.existsSync(invocation.command)) {
56
- console.error("Hermes Agent isolated runtime is not ready.");
57
- console.error("Run 'npm rebuild hermes-agent' or reinstall the npm package.");
111
+ if (!ensureRuntimeForLaunch(invocation.command)) {
58
112
  process.exitCode = 1;
59
113
  return 1;
60
114
  }
@@ -82,11 +136,15 @@ function runHermes(binName, userArgs, stdio = "inherit") {
82
136
  }
83
137
 
84
138
  module.exports = {
139
+ autoSetupDisabled,
85
140
  buildConsoleInvocation,
141
+ ensureRuntimeForLaunch,
86
142
  getConsoleExecutable,
87
143
  getRuntimeEnvironment,
88
144
  getRuntimeSourceDirectory,
89
145
  getVenvDirectory,
90
146
  normalizeBinName,
91
- runHermes
147
+ resolveRuntimeSourceDirectory,
148
+ runHermes,
149
+ venvConsoleExecutable
92
150
  };
@@ -241,7 +241,8 @@ function assertMigrationPreconditions(plan, runtimeStatus, runGit) {
241
241
  }
242
242
  if (runtimeStatus.runtimeChannel !== "npm-release") {
243
243
  throw new Error(
244
- "The npm runtime is not at its release-pinned commit. Run 'hermes-npm update', then retry the migration."
244
+ "The npm runtime is not on the npm release channel (its source or dependencies are managed by the native updater). " +
245
+ "Run 'hermes-npm update', then retry the migration."
245
246
  );
246
247
  }
247
248
  if (!fs.existsSync(plan.installerPath)) {
@@ -0,0 +1,281 @@
1
+ const crypto = require("node:crypto");
2
+ const fs = require("node:fs");
3
+ const os = require("node:os");
4
+ const path = require("node:path");
5
+
6
+ // A native 'hermes update' hands the package-local checkout to upstream's
7
+ // package manager (PM). PM records the dependency environment it built under
8
+ // '<root>/installs/<key>' and writes an untracked 'install-stamp.json' with
9
+ // 'updateMechanism: "self"' into the checkout; from then on upstream selects
10
+ // that environment at startup instead of the package's own venv. This module
11
+ // locates that state exactly as upstream does, so 'hermes-npm status' can
12
+ // report it and the installer can hand the checkout back to npm.
13
+
14
+ const INSTALL_STAMP_FILE = "install-stamp.json";
15
+ const INSTALL_KEY_PATTERN = /^[0-9a-f]{16}$/u;
16
+
17
+ function platformPath(platform = process.platform) {
18
+ return platform === "win32" ? path.win32 : path.posix;
19
+ }
20
+
21
+ function lookupEnv(env, name, platform) {
22
+ if (platform !== "win32") return env[name];
23
+ const key = Object.keys(env).find((candidate) => candidate.toUpperCase() === name.toUpperCase());
24
+ return key === undefined ? undefined : env[key];
25
+ }
26
+
27
+ // os.path.expandvars: '$name' and '${name}' everywhere, '%name%' on Windows.
28
+ // Unknown variables are left unchanged.
29
+ function expandVars(value, env, platform) {
30
+ let expanded = value.replace(/\$(?:\{([^}]+)\}|(\w+))/gu, (match, braced, bare) => {
31
+ const replacement = lookupEnv(env, braced || bare, platform);
32
+ return replacement === undefined ? match : replacement;
33
+ });
34
+ if (platform === "win32") {
35
+ expanded = expanded.replace(/%([^%]+)%/gu, (match, name) => {
36
+ const replacement = lookupEnv(env, name, platform);
37
+ return replacement === undefined ? match : replacement;
38
+ });
39
+ }
40
+ return expanded;
41
+ }
42
+
43
+ // os.path.expanduser for the current user ('~' and '~/...'). '~user' forms
44
+ // are left unchanged.
45
+ function expandUser(value, env, platform, home) {
46
+ const paths = platformPath(platform);
47
+ const separators = platform === "win32" ? ["/", "\\"] : ["/"];
48
+ if (value !== "~" && !(value.startsWith("~") && separators.includes(value[1]))) return value;
49
+ const userHome = platform === "win32"
50
+ ? lookupEnv(env, "USERPROFILE", platform) || home
51
+ : env.HOME || home;
52
+ return value === "~" ? userHome : paths.join(userHome, value.slice(2));
53
+ }
54
+
55
+ // hermes_constants._expand_hermes_home
56
+ function expandHermesHome(value, env, platform, home) {
57
+ return expandUser(expandVars(value, env, platform), env, platform, home);
58
+ }
59
+
60
+ // Path.resolve(strict=False): the real path of the longest existing prefix,
61
+ // with the remaining components appended.
62
+ function resolveLikePython(target, platform = process.platform) {
63
+ const paths = platformPath(platform);
64
+ const absolute = paths.resolve(target);
65
+ try {
66
+ return fs.realpathSync.native(absolute);
67
+ } catch {
68
+ const parent = paths.dirname(absolute);
69
+ if (parent === absolute) return absolute;
70
+ return paths.join(resolveLikePython(parent, platform), paths.basename(absolute));
71
+ }
72
+ }
73
+
74
+ function isSameOrInside(parent, candidate, platform) {
75
+ const paths = platformPath(platform);
76
+ const normalize = (value) => (platform === "win32" ? value.toLowerCase() : value);
77
+ const relative = paths.relative(normalize(parent), normalize(candidate));
78
+ if (relative === "") return true;
79
+ return !(relative === ".." || relative.startsWith(`..${paths.sep}`) || paths.isAbsolute(relative));
80
+ }
81
+
82
+ // hermes_constants._get_platform_default_hermes_home
83
+ function getPlatformDefaultHermesHome(platform = process.platform, env = process.env, home = os.homedir()) {
84
+ const paths = platformPath(platform);
85
+ const suffix = env.HERMES_DATA_DIR_SUFFIX || "";
86
+ if (platform === "win32") {
87
+ const localAppData = (lookupEnv(env, "LOCALAPPDATA", platform) || "").trim();
88
+ const base = localAppData || paths.join(home, "AppData", "Local");
89
+ return paths.join(base, `hermes${suffix}`);
90
+ }
91
+ return paths.join(home, `.hermes${suffix}`);
92
+ }
93
+
94
+ // hermes_constants.get_default_hermes_root: the platform default home, unless
95
+ // HERMES_HOME resolves outside it. Then it is HERMES_HOME itself, or its
96
+ // grandparent when HERMES_HOME is '<root>/profiles/<name>'.
97
+ function getDefaultHermesRoot(options = {}) {
98
+ const platform = options.platform || process.platform;
99
+ const env = options.env || process.env;
100
+ const home = options.home || os.homedir();
101
+ const paths = platformPath(platform);
102
+ const nativeHome = getPlatformDefaultHermesHome(platform, env, home);
103
+ const envHome = (env.HERMES_HOME || "").trim();
104
+ if (!envHome) return nativeHome;
105
+ const envPath = expandHermesHome(envHome, env, platform, home);
106
+ if (isSameOrInside(resolveLikePython(nativeHome, platform), resolveLikePython(envPath, platform), platform)) {
107
+ return nativeHome;
108
+ }
109
+ const absolute = paths.resolve(envPath);
110
+ return paths.basename(paths.dirname(absolute)) === "profiles" ? paths.dirname(paths.dirname(absolute)) : absolute;
111
+ }
112
+
113
+ // pm.environments.install_key: the first 16 hex digits of the SHA-256 of the
114
+ // resolved checkout path.
115
+ function getInstallKey(checkoutDirectory, platform = process.platform) {
116
+ const canonical = resolveLikePython(checkoutDirectory, platform);
117
+ return crypto.createHash("sha256").update(canonical, "utf8").digest("hex").slice(0, 16);
118
+ }
119
+
120
+ function getUpstreamInstallState(checkoutDirectory, options = {}) {
121
+ const platform = options.platform || process.platform;
122
+ const paths = platformPath(platform);
123
+ const hermesRoot = getDefaultHermesRoot(options);
124
+ const installKey = getInstallKey(checkoutDirectory, platform);
125
+ const directory = paths.join(hermesRoot, "installs", installKey);
126
+ return {
127
+ hermesRoot,
128
+ installKey,
129
+ directory,
130
+ factsPath: paths.join(directory, "facts.json")
131
+ };
132
+ }
133
+
134
+ // Upstream reads its records as 'utf-8-sig'.
135
+ function stripByteOrderMark(text) {
136
+ return text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
137
+ }
138
+
139
+ function readFacts(factsPath) {
140
+ let text;
141
+ try {
142
+ text = fs.readFileSync(factsPath, "utf8");
143
+ } catch (error) {
144
+ if (error.code === "ENOENT" || error.code === "ENOTDIR") return null;
145
+ return { environment: null, error: `cannot read ${factsPath}: ${error.message}` };
146
+ }
147
+ try {
148
+ const data = JSON.parse(stripByteOrderMark(text));
149
+ const environment = data?.packages?.venv?.environment;
150
+ return { environment: typeof environment === "string" ? environment : null, error: null };
151
+ } catch (error) {
152
+ return { environment: null, error: `invalid ${factsPath}: ${error.message}` };
153
+ }
154
+ }
155
+
156
+ function readInstallStamp(checkoutDirectory, isTracked) {
157
+ const stampPath = path.join(checkoutDirectory, INSTALL_STAMP_FILE);
158
+ let data;
159
+ try {
160
+ data = JSON.parse(stripByteOrderMark(fs.readFileSync(stampPath, "utf8")));
161
+ } catch (error) {
162
+ if (error.code === "ENOENT" || error.code === "ENOTDIR") return null;
163
+ data = null;
164
+ }
165
+ const updateMechanism = data && typeof data === "object" && typeof data.updateMechanism === "string"
166
+ ? data.updateMechanism
167
+ : null;
168
+ return {
169
+ path: stampPath,
170
+ updateMechanism,
171
+ tracked: isTracked ? isTracked(INSTALL_STAMP_FILE) : null
172
+ };
173
+ }
174
+
175
+ // Who owns the dependency environment of the checkout: upstream's package
176
+ // manager when it has a record for this checkout, npm otherwise. A
177
+ // self-managed install stamp means upstream takes the checkout over on the
178
+ // next launch even without a record.
179
+ function readUpstreamOwnership(checkoutDirectory, options = {}) {
180
+ const state = getUpstreamInstallState(checkoutDirectory, options);
181
+ const facts = readFacts(state.factsPath);
182
+ const installStamp = readInstallStamp(checkoutDirectory, options.isTracked);
183
+ const selfManagedStamp = Boolean(
184
+ installStamp && installStamp.updateMechanism === "self" && installStamp.tracked !== true
185
+ );
186
+ return {
187
+ hermesRoot: state.hermesRoot,
188
+ installKey: state.installKey,
189
+ installStateDirectory: state.directory,
190
+ factsPath: state.factsPath,
191
+ dependenciesOwner: facts ? "upstream-pm" : "npm",
192
+ dependencyEnvironment: facts ? facts.environment : null,
193
+ factsError: facts ? facts.error : null,
194
+ installStamp,
195
+ selfManagedStamp
196
+ };
197
+ }
198
+
199
+ function isSymbolicLink(target) {
200
+ try {
201
+ return fs.lstatSync(target).isSymbolicLink();
202
+ } catch {
203
+ return false;
204
+ }
205
+ }
206
+
207
+ function removeEntry(target, description, result, log, warn) {
208
+ let stats;
209
+ try {
210
+ stats = fs.lstatSync(target);
211
+ } catch (error) {
212
+ if (error.code === "ENOENT" || error.code === "ENOTDIR") return;
213
+ result.failed.push(target);
214
+ warn(`Unable to inspect ${description} ${target}: ${error.message}`);
215
+ return;
216
+ }
217
+ try {
218
+ fs.rmSync(target, { recursive: stats.isDirectory(), force: true });
219
+ result.removed.push(target);
220
+ log(`Removed ${description}: ${target}`);
221
+ } catch (error) {
222
+ result.failed.push(target);
223
+ warn(`Unable to remove ${description} ${target}: ${error.message}`);
224
+ }
225
+ }
226
+
227
+ // Hands the checkout's dependencies back to npm after the installer has put
228
+ // the checkout on the commit pinned by this package. Removes exactly
229
+ // '<root>/installs/<key>' for this checkout and the checkout's untracked
230
+ // install stamp; nothing else under HERMES_HOME. Never throws: a failure is
231
+ // reported, and 'hermes-npm status' keeps showing upstream ownership.
232
+ function reclaimNpmOwnership(checkoutDirectory, options = {}) {
233
+ const log = options.log || console.log;
234
+ const warn = options.warn || console.warn;
235
+ const result = { removed: [], failed: [] };
236
+ let state;
237
+ try {
238
+ state = getUpstreamInstallState(checkoutDirectory, options);
239
+ } catch (error) {
240
+ warn(`Unable to locate upstream dependency state for ${checkoutDirectory}: ${error.message}`);
241
+ result.failed.push(checkoutDirectory);
242
+ return result;
243
+ }
244
+
245
+ const stamp = readInstallStamp(checkoutDirectory, options.isTracked);
246
+ // Only a stamp git confirms as untracked is removed; an unknown answer keeps it.
247
+ if (stamp && stamp.tracked === false) {
248
+ removeEntry(stamp.path, "upstream install stamp", result, log, warn);
249
+ }
250
+
251
+ const installsDirectory = path.join(state.hermesRoot, "installs");
252
+ const expected = path.join(installsDirectory, state.installKey);
253
+ if (!INSTALL_KEY_PATTERN.test(state.installKey) || state.directory !== expected) {
254
+ warn(`Refusing to remove unexpected upstream dependency state path: ${state.directory}`);
255
+ result.failed.push(state.directory);
256
+ return result;
257
+ }
258
+ if (isSymbolicLink(installsDirectory) || isSymbolicLink(state.directory)) {
259
+ warn(`Refusing to remove upstream dependency state through a symbolic link: ${state.directory}`);
260
+ result.failed.push(state.directory);
261
+ return result;
262
+ }
263
+ // facts.json first: it is the record that selects upstream's environment,
264
+ // so once it is gone upstream falls back to the package's own venv even if
265
+ // the rest of the directory cannot be removed.
266
+ removeEntry(state.factsPath, "upstream dependency record", result, log, warn);
267
+ removeEntry(state.directory, "upstream dependency state for this checkout", result, log, warn);
268
+ return result;
269
+ }
270
+
271
+ module.exports = {
272
+ INSTALL_STAMP_FILE,
273
+ expandHermesHome,
274
+ getDefaultHermesRoot,
275
+ getInstallKey,
276
+ getPlatformDefaultHermesHome,
277
+ getUpstreamInstallState,
278
+ readUpstreamOwnership,
279
+ reclaimNpmOwnership,
280
+ resolveLikePython
281
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hermes-agent",
3
- "version": "0.22.1",
4
- "description": "Unofficial npm bridge for Hermes Agent 0.22.1: The self-improving AI agent \u2014 creates skills from experience, improves them during use, and runs anywhere",
3
+ "version": "0.22.3",
4
+ "description": "Unofficial npm bridge for Hermes Agent 0.22.3: The self-improving AI agent \u2014 creates skills from experience, improves them during use, and runs anywhere",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "hermes-agent",
@@ -46,10 +46,10 @@
46
46
  "SECURITY.md"
47
47
  ],
48
48
  "hermesAgent": {
49
- "upstreamVersion": "0.22.1",
49
+ "upstreamVersion": "0.22.3",
50
50
  "upstreamRepository": "NousResearch/hermes-agent",
51
- "upstreamGitTag": "v0.22.1",
52
- "upstreamCommit": "297552a9d646119871391d202509822cd86330df",
51
+ "upstreamGitTag": "v0.22.3",
52
+ "upstreamCommit": "5b147ab036d6d19131bff8d20701b5001eab844a",
53
53
  "pythonVersion": "3.14",
54
54
  "runtimeDirectory": "runtime/hermes-agent",
55
55
  "installerFinalizeStage": "products"
@@ -6,8 +6,10 @@ const path = require("node:path");
6
6
 
7
7
  const packageJson = require("../package.json");
8
8
  const { getRelatedPackageNames } = require("../lib/package-metadata");
9
+ const { holdProvisionLockForInstaller } = require("../lib/provision");
9
10
  const { getRuntimeSourceDirectory, getVenvDirectory } = require("../lib/python-launcher");
10
11
  const { configureRuntimeSparseCheckout } = require("../lib/runtime-checkout");
12
+ const { reclaimNpmOwnership } = require("../lib/upstream-ownership");
11
13
  const { ensureUv, UV_VERSION } = require("../lib/uv-installer");
12
14
 
13
15
  const packageName = packageJson.name;
@@ -85,7 +87,7 @@ function ensureGit() {
85
87
  return run("git", ["--version"], { capture: true, env: cleanGitEnvironment() });
86
88
  } catch {
87
89
  throw new Error(
88
- "Git is required for the native 'hermes update' channel. Install Git and run 'npm rebuild hermes-agent'."
90
+ "Git is required for the native 'hermes update' channel. Install Git and run 'hermes-npm setup'."
89
91
  );
90
92
  }
91
93
  }
@@ -205,6 +207,34 @@ function installPinnedCheckout() {
205
207
  };
206
208
  }
207
209
 
210
+ // A native 'hermes update' leaves upstream's package manager in charge of the
211
+ // checkout's dependencies: a record under HERMES_HOME/installs/<key> that
212
+ // selects its own environment, and a self-managed install stamp in the
213
+ // checkout. Once this installer has put the checkout back on the pinned
214
+ // commit, remove exactly those two so the package venv is used again. Only
215
+ // the paths that replace or reset the checkout call this; keeping the
216
+ // checkout keeps a native update, and its dependencies, on purpose.
217
+ function reclaimDependencyOwnership() {
218
+ const result = reclaimNpmOwnership(sourceDirectory, {
219
+ isTracked(file) {
220
+ try {
221
+ return git(["-C", sourceDirectory, "ls-files", "--", file], { capture: true }) !== "";
222
+ } catch {
223
+ return null;
224
+ }
225
+ }
226
+ });
227
+ if (result.removed.length > 0) {
228
+ console.log("Dependency selection returned to the npm package venv.");
229
+ }
230
+ if (result.failed.length > 0) {
231
+ console.warn(
232
+ "Upstream's package manager may still select its own environment for this checkout; " +
233
+ "'hermes-npm status' shows the owner. Stop running Hermes processes and run 'hermes-npm update' to retry."
234
+ );
235
+ }
236
+ }
237
+
208
238
  function uvBootstrapEnvironment() {
209
239
  const env = {
210
240
  ...process.env,
@@ -276,6 +306,17 @@ function warnIfRelatedPackageInstalled() {
276
306
  }
277
307
 
278
308
  async function main() {
309
+ const lock = holdProvisionLockForInstaller(packageRoot, {
310
+ onWait: (holder) => console.log(`Waiting for another Hermes Agent setup to finish${holder?.pid ? ` (PID ${holder.pid})` : ""}...`)
311
+ });
312
+ try {
313
+ await provision();
314
+ } finally {
315
+ lock.release();
316
+ }
317
+ }
318
+
319
+ async function provision() {
279
320
  validateMetadata();
280
321
  warnIfRelatedPackageInstalled();
281
322
  console.log(ensureGit());
@@ -290,7 +331,7 @@ async function main() {
290
331
 
291
332
  try {
292
333
  if (keepCurrentCheckout) {
293
- console.log("Keeping the existing checkout; native rolling updates are preserved for this npm version.");
334
+ console.log("Keeping the existing checkout; native updates are preserved for this npm version.");
294
335
  } else if (resetCurrentCheckout) {
295
336
  console.log("Resetting the clean runtime to the release commit pinned by this npm package...");
296
337
  transaction = resetPinnedCheckoutInPlace();
@@ -318,9 +359,14 @@ async function main() {
318
359
  npmUpdateCommand: "hermes-npm update"
319
360
  };
320
361
  fs.writeFileSync(runtimeMarkerPath, `${JSON.stringify(runtimeMarker, null, 2)}\n`, "utf8");
362
+ const checkoutReprovisioned = transaction !== null;
321
363
  transaction?.commit();
364
+ // Nothing below may roll the checkout back: the reclaim deletes state
365
+ // that a rollback could not restore.
366
+ transaction = null;
367
+ if (checkoutReprovisioned) reclaimDependencyOwnership();
322
368
  console.log("Hermes Agent npm runtime is ready.");
323
- console.log("Use 'hermes update' for upstream rolling updates or 'hermes-npm update' for npm releases.");
369
+ console.log("Use 'hermes-npm update' for npm releases or 'hermes update' for the native upstream updater.");
324
370
  } catch (error) {
325
371
  transaction?.rollback();
326
372
  throw new Error(`Failed to prepare the isolated Hermes Agent runtime: ${error.message}`);