@openlatch/client 0.11.21 → 0.11.22
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/resolve-binary.js +34 -0
- package/package.json +6 -6
package/lib/resolve-binary.js
CHANGED
|
@@ -49,6 +49,19 @@ function openlatchDir() {
|
|
|
49
49
|
return process.env.OPENLATCH_DIR || path.join(os.homedir(), ".openlatch");
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* The client's own state directory, where the daemon writes `daemon.pid` — the client's
|
|
54
|
+
* `config::openlatch_dir()`: `%APPDATA%\openlatch` on Windows, `~/.openlatch` elsewhere. Not
|
|
55
|
+
* the launcher's directory, which is `~/.openlatch` on every OS.
|
|
56
|
+
*/
|
|
57
|
+
function clientStateDir() {
|
|
58
|
+
if (process.env.OPENLATCH_DIR) return process.env.OPENLATCH_DIR;
|
|
59
|
+
if (os.platform() === "win32" && process.env.APPDATA) {
|
|
60
|
+
return path.join(process.env.APPDATA, "openlatch");
|
|
61
|
+
}
|
|
62
|
+
return path.join(os.homedir(), ".openlatch");
|
|
63
|
+
}
|
|
64
|
+
|
|
52
65
|
function launcherStatePath() {
|
|
53
66
|
return path.join(openlatchDir(), "npm-launcher.json");
|
|
54
67
|
}
|
|
@@ -112,6 +125,26 @@ function preservePreGuardEvaluator(state) {
|
|
|
112
125
|
}
|
|
113
126
|
}
|
|
114
127
|
|
|
128
|
+
/**
|
|
129
|
+
* An upgrade just activated a new pair while the previous release's daemon runs: its OS
|
|
130
|
+
* supervisor still starts the previous copy (each release has its own npm-bin folder), so
|
|
131
|
+
* that daemon would serve on with the previous hook. The new binary's `restart` re-registers
|
|
132
|
+
* the supervisor on itself and cycles the daemon. Best-effort: never fails the command.
|
|
133
|
+
*/
|
|
134
|
+
function cycleRunningDaemon(stagedExe) {
|
|
135
|
+
try {
|
|
136
|
+
const pidFile = path.join(clientStateDir(), "daemon.pid");
|
|
137
|
+
if (!fs.existsSync(pidFile)) return;
|
|
138
|
+
const pid = Number.parseInt(fs.readFileSync(pidFile, "utf8").trim(), 10);
|
|
139
|
+
if (!Number.isInteger(pid) || pid <= 0) return;
|
|
140
|
+
process.kill(pid, 0);
|
|
141
|
+
spawnSync(stagedExe, ["restart"], { stdio: "ignore", timeout: 60000, windowsHide: true });
|
|
142
|
+
} catch {
|
|
143
|
+
// No live daemon, or the restart failed: the user's command runs regardless, and
|
|
144
|
+
// `openlatch doctor` names the version gap (OL-1503).
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
115
148
|
function replacePairAtRecordedPaths(executable, hook, state) {
|
|
116
149
|
const ext = os.platform() === "win32" ? ".exe" : "";
|
|
117
150
|
if (!state.current) {
|
|
@@ -196,6 +229,7 @@ function activateCandidate() {
|
|
|
196
229
|
}
|
|
197
230
|
if (state.current !== root) {
|
|
198
231
|
writeState({ current: root, previous: state.current || null, activated_at: new Date().toISOString() });
|
|
232
|
+
if (state.current) cycleRunningDaemon(stagedExe);
|
|
199
233
|
}
|
|
200
234
|
return readState();
|
|
201
235
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openlatch/client",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.22",
|
|
4
4
|
"description": "OpenLatch runtime enforcement node — the capture-and-enforce adapter that evaluates every covered action against a coding agent's Autonomy Zone before it runs",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"postinstall": "node lib/postinstall.js"
|
|
21
21
|
},
|
|
22
22
|
"optionalDependencies": {
|
|
23
|
-
"@openlatch/client-darwin-arm64": "0.11.
|
|
24
|
-
"@openlatch/client-darwin-x64": "0.11.
|
|
25
|
-
"@openlatch/client-linux-x64": "0.11.
|
|
26
|
-
"@openlatch/client-linux-arm64": "0.11.
|
|
27
|
-
"@openlatch/client-win32-x64": "0.11.
|
|
23
|
+
"@openlatch/client-darwin-arm64": "0.11.22",
|
|
24
|
+
"@openlatch/client-darwin-x64": "0.11.22",
|
|
25
|
+
"@openlatch/client-linux-x64": "0.11.22",
|
|
26
|
+
"@openlatch/client-linux-arm64": "0.11.22",
|
|
27
|
+
"@openlatch/client-win32-x64": "0.11.22"
|
|
28
28
|
}
|
|
29
29
|
}
|