@timurproko/a1 0.2.3-dev.655 → 0.2.3-dev.657

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.
@@ -80,3 +80,4 @@ export declare function removeUpdateRecoveryCapsule(dataDir: string, transaction
80
80
  export declare function inspectUpdateLauncherSet(capsule: UpdateRecoveryCapsule, platform?: NodeJS.Platform): Promise<"target" | "recovery" | "unavailable">;
81
81
  /** Remove terminal recovery capsules only after no canonical launcher references them. */
82
82
  export declare function cleanupUpdateRecoveryCapsules(dataDir: string): Promise<void>;
83
+ export declare function resolveNpmCli(globalRoot: string, environment: NodeJS.ProcessEnv, platform?: NodeJS.Platform, nodeExecutable?: string): Promise<string>;
@@ -119,7 +119,7 @@ export async function prepareUpdateRecoveryCapsule(options) {
119
119
  const prefix = npmPrefixForGlobalRoot(canonicalGlobal, platform);
120
120
  const launcherRoot = platform === "win32" ? prefix : resolve(prefix, "bin");
121
121
  const npmCliRoot = await realpath(options.npmCliRoot ?? canonicalGlobal);
122
- const npmCli = await resolveNpmCli(npmCliRoot, options.environment ?? process.env);
122
+ const npmCli = await resolveNpmCli(npmCliRoot, options.environment ?? process.env, platform);
123
123
  const capsule = {
124
124
  schema: UPDATE_RECOVERY_SCHEMA,
125
125
  launchContract: PRIVATE_LAUNCH_CONTRACT,
@@ -299,15 +299,61 @@ async function spawnRecoveryWorker(entry, manifestPath, environment) {
299
299
  });
300
300
  child.unref();
301
301
  }
302
- async function resolveNpmCli(globalRoot, environment) {
303
- const candidates = [environment.npm_execpath, resolve(globalRoot, "npm", "bin", "npm-cli.js")].filter((value) => typeof value === "string" && value.length > 0);
302
+ export async function resolveNpmCli(globalRoot, environment, platform = process.platform, nodeExecutable = process.execPath) {
303
+ const candidates = [environment.npm_execpath, resolve(globalRoot, "npm", "bin", "npm-cli.js")]
304
+ .filter((value) => typeof value === "string" && value.length > 0);
304
305
  for (const candidate of candidates) {
305
- const canonical = await realpath(candidate).catch(() => null);
306
- if (canonical && await lstat(canonical).then(metadata => metadata.isFile()).catch(() => false))
306
+ const canonical = await canonicalRegularFile(candidate);
307
+ if (canonical)
307
308
  return canonical;
308
309
  }
310
+ if (platform === "win32") {
311
+ const commandCandidate = await windowsNpmCliFromPath(environment);
312
+ const bundledCandidates = [commandCandidate, resolve(dirname(nodeExecutable), "node_modules", "npm", "bin", "npm-cli.js")]
313
+ .filter((value) => value !== null);
314
+ for (const candidate of bundledCandidates) {
315
+ const canonical = await canonicalRegularFile(candidate);
316
+ if (canonical)
317
+ return canonical;
318
+ }
319
+ }
309
320
  throw new Error("could not resolve npm's JavaScript entry for protected package replacement");
310
321
  }
322
+ async function windowsNpmCliFromPath(environment) {
323
+ const pathValue = windowsEnvironmentValue(environment, "PATH");
324
+ if (!pathValue)
325
+ return null;
326
+ const pathExtValue = windowsEnvironmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD";
327
+ const extensions = pathExtValue.split(";")
328
+ .map(extension => extension.trim())
329
+ .filter(extension => /^\.[a-z0-9]+$/i.test(extension));
330
+ if (extensions.length === 0)
331
+ return null;
332
+ for (const rawDirectory of pathValue.split(";")) {
333
+ const directory = unquoteWindowsPathEntry(rawDirectory.trim());
334
+ if (!directory)
335
+ continue;
336
+ for (const extension of extensions) {
337
+ const command = resolve(directory, `npm${extension}`);
338
+ if (await canonicalRegularFile(command))
339
+ return resolve(directory, "node_modules", "npm", "bin", "npm-cli.js");
340
+ }
341
+ }
342
+ return null;
343
+ }
344
+ function windowsEnvironmentValue(environment, name) {
345
+ const key = Object.keys(environment).find(candidate => candidate.toLowerCase() === name.toLowerCase());
346
+ return key ? environment[key] : undefined;
347
+ }
348
+ function unquoteWindowsPathEntry(value) {
349
+ return value.length >= 2 && value.startsWith('"') && value.endsWith('"') ? value.slice(1, -1) : value;
350
+ }
351
+ async function canonicalRegularFile(path) {
352
+ const canonical = await realpath(path).catch(() => null);
353
+ if (!canonical)
354
+ return null;
355
+ return await lstat(canonical).then(metadata => metadata.isFile() ? canonical : null).catch(() => null);
356
+ }
311
357
  async function readLiveRecoveryOwner(path, transactionId) {
312
358
  const owner = await readJson(path).catch(() => null);
313
359
  const metadata = await lstat(path).catch(() => null);
@@ -5,7 +5,7 @@
5
5
  "platform": "darwin",
6
6
  "architecture": "arm64",
7
7
  "capability": "supported",
8
- "builtAt": "2026-10-01T13:12:01.163Z",
8
+ "builtAt": "2026-10-01T18:43:37.177Z",
9
9
  "artifact": {
10
10
  "filename": "process-guardian",
11
11
  "sha256": "d3979187180449cb181eb92c187d1c8d0bfc4b2ba442e2e0a7c32704ea7e9589",
@@ -5,7 +5,7 @@
5
5
  "platform": "linux",
6
6
  "architecture": "x64",
7
7
  "capability": "supported",
8
- "builtAt": "2026-10-01T13:11:54.732Z",
8
+ "builtAt": "2026-10-01T18:43:16.251Z",
9
9
  "artifact": {
10
10
  "filename": "process-guardian",
11
11
  "sha256": "a316d11a4aabe5aa88a360169206a87a11fe4b355e836b77cd8a7950279ab415",
@@ -5,10 +5,10 @@
5
5
  "platform": "win32",
6
6
  "architecture": "x64",
7
7
  "capability": "supported",
8
- "builtAt": "2026-10-01T13:13:04.358Z",
8
+ "builtAt": "2026-10-01T18:44:06.108Z",
9
9
  "artifact": {
10
10
  "filename": "process-guardian.exe",
11
- "sha256": "1349f709243e603c8dfe25e5f97f276b284e8c078c46c9d534f93eac34cb7d23",
11
+ "sha256": "84f1f4f34c5bdc93407ae0fed392edd4ce58a0ff94fa948db38a5e885999a682",
12
12
  "size": 177152
13
13
  },
14
14
  "provenance": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timurproko/a1",
3
- "version": "0.2.3-dev.655",
3
+ "version": "0.2.3-dev.657",
4
4
  "description": "Standalone terminal workspace for supervised native and managed agents",
5
5
  "type": "module",
6
6
  "privateLaunchContract": "neutral-launch-v1",