@postman-cse/cse-toold 4.11.0 → 4.11.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/package.json +5 -5
  2. package/src/index.js +38 -28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postman-cse/cse-toold",
3
- "version": "4.11.0",
3
+ "version": "4.11.3",
4
4
  "description": "CSE tools daemon: signed Node SEA launcher mediating MCP traffic for Claude/Codex/Droid; pure-JS cred store plus signed cse-se-unwrap helper own credential custody",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -22,9 +22,9 @@
22
22
  "bin/"
23
23
  ],
24
24
  "optionalDependencies": {
25
- "@postman-cse/cse-toold-darwin-arm64": "4.11.0",
26
- "@postman-cse/cse-toold-linux-arm64": "4.11.0",
27
- "@postman-cse/cse-toold-linux-x64": "4.11.0",
28
- "@postman-cse/cse-toold-win32-arm64": "4.11.0"
25
+ "@postman-cse/cse-toold-darwin-arm64": "4.11.3",
26
+ "@postman-cse/cse-toold-linux-arm64": "4.11.3",
27
+ "@postman-cse/cse-toold-linux-x64": "4.11.3",
28
+ "@postman-cse/cse-toold-win32-arm64": "4.11.3"
29
29
  }
30
30
  }
package/src/index.js CHANGED
@@ -5,6 +5,10 @@ const fs = require('fs');
5
5
  const os = require('os');
6
6
  const child_process = require('child_process');
7
7
 
8
+ /// Commands that must prefer the packaged platform launcher over a possibly
9
+ /// stale stable install (install / session provisioning).
10
+ const BUNDLED_FIRST_COMMANDS = new Set(['install', 'session-start-hook']);
11
+
8
12
  function platformPackageName() {
9
13
  return `@postman-cse/cse-toold-${process.platform}-${process.arch}`;
10
14
  }
@@ -28,7 +32,12 @@ function executableCandidate(candidate) {
28
32
  }
29
33
  }
30
34
 
31
- function resolveCoreBinary() {
35
+ function preferBundledFirst(argv) {
36
+ const command = Array.isArray(argv) ? argv[0] : undefined;
37
+ return typeof command === 'string' && BUNDLED_FIRST_COMMANDS.has(command);
38
+ }
39
+
40
+ function resolveBundledBinary() {
32
41
  const platformKey = `${process.platform}-${process.arch}`;
33
42
  const supportedPlatforms = new Set([
34
43
  'darwin-arm64',
@@ -36,42 +45,43 @@ function resolveCoreBinary() {
36
45
  'linux-x64',
37
46
  'win32-arm64',
38
47
  ]);
48
+ if (!supportedPlatforms.has(platformKey)) return undefined;
39
49
  const binaryName = nativeBinaryName(process.platform);
40
- const stable = executableCandidate(stableBinaryPath());
41
- if (stable) return stable;
42
-
43
- if (supportedPlatforms.has(platformKey)) {
44
- try {
45
- const pkgJson = require.resolve(`${platformPackageName()}/package.json`);
46
- const candidate = path.join(path.dirname(pkgJson), 'bin', binaryName);
47
- if (fs.existsSync(candidate)) {
48
- try {
49
- fs.accessSync(candidate, fs.constants.X_OK);
50
- return candidate;
51
- } catch (_) {
52
- throw new Error('native runtime is not executable');
53
- }
54
- }
55
- } catch (e) {
56
- if (e.message === 'native runtime is not executable') throw e;
57
- }
50
+ try {
51
+ const pkgJson = require.resolve(`${platformPackageName()}/package.json`);
52
+ const candidate = path.join(path.dirname(pkgJson), 'bin', binaryName);
53
+ return executableCandidate(candidate);
54
+ } catch (e) {
55
+ if (e.message === 'native runtime is not executable') throw e;
56
+ return undefined;
58
57
  }
58
+ }
59
59
 
60
+ function resolveVendorBinary() {
61
+ const binaryName = nativeBinaryName(process.platform);
60
62
  const vendorCandidate = path.resolve(__dirname, '..', 'vendor', binaryName);
61
- if (fs.existsSync(vendorCandidate)) {
62
- try {
63
- fs.accessSync(vendorCandidate, fs.constants.X_OK);
64
- return vendorCandidate;
65
- } catch (_) {
66
- throw new Error('native runtime is not executable');
67
- }
68
- }
63
+ return executableCandidate(vendorCandidate);
64
+ }
69
65
 
66
+ /// Resolve the native launcher. Ordinary commands keep stable-first resolution;
67
+ /// `install` and `session-start-hook` prefer the packaged platform binary so a
68
+ /// stale LaunchAgent install can still activate a newer bundled release.
69
+ function resolveCoreBinary(argv) {
70
+ const platformKey = `${process.platform}-${process.arch}`;
71
+ const bundled = resolveBundledBinary();
72
+ const stable = executableCandidate(stableBinaryPath());
73
+ const order = preferBundledFirst(argv) ? [bundled, stable] : [stable, bundled];
74
+ for (const candidate of order) {
75
+ if (candidate) return candidate;
76
+ }
77
+ const vendor = resolveVendorBinary();
78
+ if (vendor) return vendor;
70
79
  throw new Error(`native runtime is unavailable for this platform: ${platformKey}`);
71
80
  }
72
81
 
73
82
  function spawnRaw(args, options) {
74
- return child_process.spawnSync(resolveCoreBinary(), args || [], {
83
+ const argv = args || [];
84
+ return child_process.spawnSync(resolveCoreBinary(argv), argv, {
75
85
  stdio: 'inherit',
76
86
  ...(options || {}),
77
87
  });