@openlatch/client 0.1.6 → 0.1.7

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.
package/lib/index.js CHANGED
@@ -3,45 +3,9 @@
3
3
  "use strict";
4
4
 
5
5
  const { execFileSync } = require("child_process");
6
- const path = require("path");
7
- const os = require("os");
6
+ const { resolveBinary } = require("./resolve-binary");
8
7
 
9
- // Map Node.js platform/arch to @openlatch/client-{platform} package names
10
- const PLATFORMS = {
11
- "darwin-arm64": "@openlatch/client-darwin-arm64",
12
- "darwin-x64": "@openlatch/client-darwin-x64",
13
- "linux-x64": "@openlatch/client-linux-x64",
14
- "linux-arm64": "@openlatch/client-linux-arm64",
15
- "win32-x64": "@openlatch/client-win32-x64",
16
- };
17
-
18
- function getBinaryPath() {
19
- const platformKey = `${os.platform()}-${os.arch()}`;
20
- const pkg = PLATFORMS[platformKey];
21
-
22
- if (!pkg) {
23
- console.error(
24
- `openlatch: unsupported platform ${platformKey}. ` +
25
- `Supported: ${Object.keys(PLATFORMS).join(", ")}`
26
- );
27
- process.exit(1);
28
- }
29
-
30
- const ext = os.platform() === "win32" ? ".exe" : "";
31
- const binaryName = `openlatch${ext}`;
32
-
33
- // Try to resolve from the platform-specific optional dependency
34
- try {
35
- const pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
36
- return path.join(pkgDir, binaryName);
37
- } catch {
38
- // Optional dependency not installed (--no-optional, Yarn Plug-n-Play, etc.)
39
- // Fall back to postinstall-downloaded binary
40
- return path.join(__dirname, "..", "bin", binaryName);
41
- }
42
- }
43
-
44
- const binary = getBinaryPath();
8
+ const binary = resolveBinary("openlatch");
45
9
 
46
10
  try {
47
11
  execFileSync(binary, process.argv.slice(2), {
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ // Shim for the `openlatch-hook` bin entry. Mirrors index.js but resolves
6
+ // the hook binary. Both shims share `resolve-binary.js` so platform-
7
+ // resolution logic stays in one place.
8
+
9
+ const { execFileSync } = require("child_process");
10
+ const { resolveBinary } = require("./resolve-binary");
11
+
12
+ const binary = resolveBinary("openlatch-hook");
13
+
14
+ try {
15
+ execFileSync(binary, process.argv.slice(2), {
16
+ stdio: "inherit",
17
+ env: process.env,
18
+ });
19
+ } catch (err) {
20
+ if (err.status !== null && err.status !== undefined) {
21
+ process.exit(err.status);
22
+ }
23
+ if (err.code === "ENOENT") {
24
+ console.error(
25
+ `openlatch-hook: binary not found at ${binary}\n` +
26
+ `Try reinstalling: npm install -g @openlatch/client`
27
+ );
28
+ process.exit(1);
29
+ }
30
+ process.exit(1);
31
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ // Shared binary resolver for the main npm shim. Both `openlatch` and
4
+ // `openlatch-hook` use the same lookup path: first the platform-specific
5
+ // optional dependency (@openlatch/client-{platform}), then the postinstall
6
+ // fallback under ../bin/. Keeping this in one place means the two bins
7
+ // can't drift apart.
8
+
9
+ const path = require("path");
10
+ const os = require("os");
11
+
12
+ const PLATFORMS = {
13
+ "darwin-arm64": "@openlatch/client-darwin-arm64",
14
+ "darwin-x64": "@openlatch/client-darwin-x64",
15
+ "linux-x64": "@openlatch/client-linux-x64",
16
+ "linux-arm64": "@openlatch/client-linux-arm64",
17
+ "win32-x64": "@openlatch/client-win32-x64",
18
+ };
19
+
20
+ function resolveBinary(baseName) {
21
+ const platformKey = `${os.platform()}-${os.arch()}`;
22
+ const pkg = PLATFORMS[platformKey];
23
+
24
+ if (!pkg) {
25
+ console.error(
26
+ `${baseName}: unsupported platform ${platformKey}. ` +
27
+ `Supported: ${Object.keys(PLATFORMS).join(", ")}`
28
+ );
29
+ process.exit(1);
30
+ }
31
+
32
+ const ext = os.platform() === "win32" ? ".exe" : "";
33
+ const binaryName = `${baseName}${ext}`;
34
+
35
+ try {
36
+ const pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
37
+ return path.join(pkgDir, binaryName);
38
+ } catch {
39
+ // Optional dependency not installed (--no-optional, Yarn Plug-n-Play,
40
+ // etc.); fall back to the postinstall-downloaded binary.
41
+ return path.join(__dirname, "..", "bin", binaryName);
42
+ }
43
+ }
44
+
45
+ module.exports = { resolveBinary, PLATFORMS };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openlatch/client",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "OpenLatch — the open-source security layer for AI agents",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -9,7 +9,8 @@
9
9
  },
10
10
  "homepage": "https://openlatch.ai",
11
11
  "bin": {
12
- "openlatch": "lib/index.js"
12
+ "openlatch": "lib/index.js",
13
+ "openlatch-hook": "lib/openlatch-hook.js"
13
14
  },
14
15
  "files": [
15
16
  "lib/"
@@ -18,10 +19,10 @@
18
19
  "postinstall": "node lib/postinstall.js"
19
20
  },
20
21
  "optionalDependencies": {
21
- "@openlatch/client-darwin-arm64": "0.1.6",
22
- "@openlatch/client-darwin-x64": "0.1.6",
23
- "@openlatch/client-linux-x64": "0.1.6",
24
- "@openlatch/client-linux-arm64": "0.1.6",
25
- "@openlatch/client-win32-x64": "0.1.6"
22
+ "@openlatch/client-darwin-arm64": "0.1.7",
23
+ "@openlatch/client-darwin-x64": "0.1.7",
24
+ "@openlatch/client-linux-x64": "0.1.7",
25
+ "@openlatch/client-linux-arm64": "0.1.7",
26
+ "@openlatch/client-win32-x64": "0.1.7"
26
27
  }
27
28
  }