@pushary/agent-hooks 1.8.3 → 1.9.1
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/CHANGELOG.md +13 -0
- package/dist/bin/pushary-bell-hook.js +23 -23
- package/dist/bin/pushary-bell.js +9 -9
- package/dist/bin/pushary-claude.js +26 -26
- package/dist/bin/pushary-clean.js +28 -28
- package/dist/bin/pushary-codex-bridge.js +18 -18
- package/dist/bin/pushary-codex-hook.js +31 -31
- package/dist/bin/pushary-codex.js +13 -13
- package/dist/bin/pushary-connect.js +13 -13
- package/dist/bin/pushary-cowork.js +5 -5
- package/dist/bin/pushary-daemon.js +26 -26
- package/dist/bin/pushary-disconnect.js +18 -18
- package/dist/bin/pushary-doctor.js +30 -30
- package/dist/bin/pushary-elicitation-hook.js +25 -25
- package/dist/bin/pushary-gemini-bridge.js +13 -13
- package/dist/bin/pushary-gemini-hook.js +28 -28
- package/dist/bin/pushary-hook.js +32 -32
- package/dist/bin/pushary-login.js +12 -12
- package/dist/bin/pushary-logout.js +7 -7
- package/dist/bin/pushary-mcp.js +9 -9
- package/dist/bin/pushary-mode.js +9 -9
- package/dist/bin/pushary-notification-hook.js +28 -28
- package/dist/bin/pushary-opencode-hook.js +27 -27
- package/dist/bin/pushary-permission-denied-hook.js +32 -32
- package/dist/bin/pushary-permission-hook.js +31 -31
- package/dist/bin/pushary-post-hook.js +28 -28
- package/dist/bin/pushary-prompt-hook.js +28 -28
- package/dist/bin/pushary-session-end-hook.js +28 -28
- package/dist/bin/pushary-session-start-hook.js +31 -31
- package/dist/bin/pushary-setup.js +53 -38
- package/dist/bin/pushary-stats.js +5 -5
- package/dist/bin/pushary-status.js +15 -15
- package/dist/bin/pushary-stop-hook.js +28 -28
- package/dist/bin/pushary-stopfailure-hook.js +28 -28
- package/dist/bin/pushary-suggestions.js +4 -4
- package/dist/bin/pushary-transcript-register.js +19 -19
- package/dist/bin/pushary-transcripts.js +7 -7
- package/dist/bin/pushary-upgrade.js +42 -394
- package/dist/bin/pushary-wait.js +9 -9
- package/dist/bin/pushary.js +6 -6
- package/dist/{chunk-ON5JW2HP.js → chunk-4SB46XLF.js} +1 -1
- package/dist/{chunk-HMNR7B2F.js → chunk-4XT4JXMG.js} +1 -1
- package/dist/{chunk-YOYSXLUB.js → chunk-5K43TBK4.js} +3 -3
- package/dist/{chunk-ZOKXZ3AS.js → chunk-65TOHCXT.js} +4 -4
- package/dist/{chunk-4CW5EAOI.js → chunk-6JTTJIKJ.js} +3 -3
- package/dist/{chunk-6SS74UHS.js → chunk-6L7TNZ43.js} +1 -1
- package/dist/{chunk-EJXEHNB5.js → chunk-6Q4NM2LW.js} +3 -3
- package/dist/{chunk-5Y2DY6X4.js → chunk-6QSDNXGM.js} +2 -2
- package/dist/{chunk-72WOCX22.js → chunk-7ER66HZH.js} +1 -1
- package/dist/{chunk-OLYTGVCC.js → chunk-AKCJ5SNO.js} +6 -6
- package/dist/{chunk-N6JJJTPH.js → chunk-C6PPDKVI.js} +3 -3
- package/dist/{chunk-VI55VXDH.js → chunk-CE4UH4AP.js} +2 -2
- package/dist/{chunk-NOLPURUI.js → chunk-CGRPHFOV.js} +1 -1
- package/dist/{chunk-XH7UNEHO.js → chunk-COSADFEH.js} +1 -1
- package/dist/{chunk-YLJ26RR2.js → chunk-D3RS57MN.js} +3 -3
- package/dist/{chunk-6UDK5TY6.js → chunk-DMA3QUOB.js} +3 -3
- package/dist/{chunk-URNXU3FO.js → chunk-FJPC35OW.js} +1 -1
- package/dist/{chunk-35X5UDML.js → chunk-FVOCQSBG.js} +1 -1
- package/dist/{chunk-FBTUF2PH.js → chunk-GHKNUQYU.js} +2 -2
- package/dist/{chunk-DLEKCAQL.js → chunk-HU2LWGEE.js} +1 -1
- package/dist/{chunk-SOUJG6UY.js → chunk-IITCMJ4G.js} +2 -2
- package/dist/{chunk-MSMKCO4Y.js → chunk-IJXJW2VH.js} +10 -10
- package/dist/{chunk-DMU5E6HJ.js → chunk-J7JXA2LX.js} +1 -1
- package/dist/{chunk-4DYHBXX4.js → chunk-JCER3Q6P.js} +9 -9
- package/dist/{chunk-CB23AO4D.js → chunk-JGQ2ANHQ.js} +2 -2
- package/dist/{chunk-AKCE6ZRF.js → chunk-JHZAZAI3.js} +5 -5
- package/dist/{chunk-27A7L4DA.js → chunk-KR5JASA4.js} +2 -2
- package/dist/{chunk-VF3X4MDB.js → chunk-LJI7U6PM.js} +2 -2
- package/dist/{chunk-7U7ZWUTR.js → chunk-LKKYRNJT.js} +1 -1
- package/dist/{chunk-MYHG7PX2.js → chunk-LXWUYG7D.js} +1 -1
- package/dist/{chunk-VUP5BMOD.js → chunk-LZMH4EGE.js} +1 -1
- package/dist/{chunk-CTNLP4A5.js → chunk-NVLXK2I6.js} +5 -5
- package/dist/{chunk-7ITOAMCD.js → chunk-P7YDVWLL.js} +1 -1
- package/dist/{chunk-IEXWWAJY.js → chunk-PEGKBNGN.js} +5 -5
- package/dist/{chunk-UMMCHS6P.js → chunk-PMS3EBD2.js} +1 -1
- package/dist/chunk-QQJCDRD3.js +242 -0
- package/dist/chunk-QXL27RY6.js +175 -0
- package/dist/{chunk-TJMAXQ5Q.js → chunk-RJ7ECJSZ.js} +2 -2
- package/dist/{chunk-VFFHQC7W.js → chunk-RNDFGHSQ.js} +1 -1
- package/dist/{chunk-4SJIPHR3.js → chunk-RS4ZOFSF.js} +10 -7
- package/dist/{chunk-HVDMGDYV.js → chunk-SKEP3M6M.js} +2 -2
- package/dist/{chunk-UXKXGRKG.js → chunk-SPB3QRE7.js} +4 -4
- package/dist/{chunk-CXYKQAL2.js → chunk-SWGY5WNX.js} +5 -5
- package/dist/{chunk-E5JGQGLD.js → chunk-UPTEPARD.js} +2 -2
- package/dist/{chunk-CHMOVJ2M.js → chunk-UYHLMBPQ.js} +1 -1
- package/dist/{chunk-XNJ4MQF3.js → chunk-V4H33GBM.js} +6 -6
- package/dist/{chunk-34EQOFMH.js → chunk-VH6763OR.js} +3 -3
- package/dist/{chunk-DXBS2EL7.js → chunk-VQLWYKX7.js} +1 -1
- package/dist/{chunk-SD6OLZJX.js → chunk-WWDPULS3.js} +8 -8
- package/dist/{chunk-5YY3IJT4.js → chunk-XEIV5QOT.js} +92 -23
- package/dist/{chunk-APURTMSW.js → chunk-XW2B4QV2.js} +2 -2
- package/dist/{chunk-ZR7LIQKO.js → chunk-ZMKEKWNR.js} +70 -49
- package/dist/global-upgrade-ML2RHV4W.js +24 -0
- package/dist/paths-LG3IEDDM.js +71 -0
- package/dist/{reapply-DYOQAVUP.js → reapply-7PFOITE4.js} +8 -8
- package/dist/src/index.js +20 -20
- package/dist/upgrade-lock-2A2YUUEU.js +17 -0
- package/package.json +1 -1
|
@@ -1,35 +1,45 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
FINISH_UPGRADE_FLAG,
|
|
4
|
+
finishGlobalUpgrade,
|
|
5
|
+
finishUpgradeWithLock,
|
|
6
|
+
readGlobalUpgradeSubject,
|
|
7
|
+
runAutoUpdate,
|
|
8
|
+
upgradeInstalledPackage,
|
|
9
|
+
withUpgradeLock
|
|
10
|
+
} from "../chunk-QQJCDRD3.js";
|
|
11
|
+
import {
|
|
12
|
+
installWithUpgradeLock
|
|
13
|
+
} from "../chunk-QXL27RY6.js";
|
|
2
14
|
import {
|
|
3
15
|
describeCodexTrustConfirmation
|
|
4
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-VQLWYKX7.js";
|
|
5
17
|
import {
|
|
6
18
|
ensureCodexTrustAfterReapply,
|
|
7
19
|
reapplyAllAgents
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import "../chunk-
|
|
20
|
+
} from "../chunk-SWGY5WNX.js";
|
|
21
|
+
import "../chunk-KR5JASA4.js";
|
|
10
22
|
import {
|
|
11
23
|
waitForMachineReadiness
|
|
12
|
-
} from "../chunk-
|
|
13
|
-
import "../chunk-
|
|
24
|
+
} from "../chunk-AKCJ5SNO.js";
|
|
25
|
+
import "../chunk-6Q4NM2LW.js";
|
|
14
26
|
import {
|
|
15
27
|
detectProviderLiveCapabilities,
|
|
16
28
|
expectedLaunchCapabilities,
|
|
17
29
|
hasSpawnProvider,
|
|
18
30
|
resolveControlPolicy
|
|
19
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-IITCMJ4G.js";
|
|
20
32
|
import "../chunk-RIVNNBEK.js";
|
|
21
33
|
import {
|
|
22
34
|
AUTO_UPDATE_DISABLE_ENV,
|
|
23
35
|
describeAutoUpdateCheck,
|
|
24
|
-
globalInstallLocation,
|
|
25
36
|
hasPendingUpgradeFinish,
|
|
26
37
|
isAutoUpdateDisabledByEnv,
|
|
27
38
|
parseAutoUpdateFlag,
|
|
28
39
|
readAutoUpdateState,
|
|
29
|
-
updateAutoUpdateState
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
import "../chunk-YOYSXLUB.js";
|
|
40
|
+
updateAutoUpdateState
|
|
41
|
+
} from "../chunk-CE4UH4AP.js";
|
|
42
|
+
import "../chunk-5K43TBK4.js";
|
|
33
43
|
import {
|
|
34
44
|
daemonHasRemoteProof,
|
|
35
45
|
daemonServiceManagerAvailable,
|
|
@@ -40,444 +50,82 @@ import {
|
|
|
40
50
|
replaceDaemonService,
|
|
41
51
|
stopDaemonService,
|
|
42
52
|
waitForDaemonRemoteProof
|
|
43
|
-
} from "../chunk-
|
|
44
|
-
import "../chunk-
|
|
53
|
+
} from "../chunk-PEGKBNGN.js";
|
|
54
|
+
import "../chunk-D3RS57MN.js";
|
|
45
55
|
import "../chunk-XHKBHWLX.js";
|
|
46
56
|
import "../chunk-6ICPEJY5.js";
|
|
47
|
-
import "../chunk-
|
|
57
|
+
import "../chunk-RNDFGHSQ.js";
|
|
48
58
|
import "../chunk-POFBE6ZY.js";
|
|
49
59
|
import {
|
|
50
60
|
exitOnHelpFlag
|
|
51
|
-
} from "../chunk-
|
|
61
|
+
} from "../chunk-JGQ2ANHQ.js";
|
|
52
62
|
import {
|
|
53
63
|
readControlMode
|
|
54
|
-
} from "../chunk-
|
|
55
|
-
import "../chunk-
|
|
64
|
+
} from "../chunk-RJ7ECJSZ.js";
|
|
65
|
+
import "../chunk-J7JXA2LX.js";
|
|
56
66
|
import {
|
|
57
67
|
EXIT
|
|
58
68
|
} from "../chunk-KZERVKTD.js";
|
|
59
|
-
import "../chunk-
|
|
69
|
+
import "../chunk-6QSDNXGM.js";
|
|
60
70
|
import {
|
|
61
71
|
LATEST_TAG,
|
|
62
|
-
autoUpdateLock,
|
|
63
|
-
autoUpdateLog,
|
|
64
72
|
autoUpdateState,
|
|
65
73
|
claudeJson,
|
|
66
74
|
codexConfigToml,
|
|
67
75
|
cursorPluginDir,
|
|
68
|
-
execNpm,
|
|
69
76
|
fetchLatestPublishedVersion,
|
|
70
77
|
geminiSettings,
|
|
71
|
-
installPackageGlobally,
|
|
72
|
-
npmErrorMessage,
|
|
73
|
-
readGlobalCliInstallAt,
|
|
74
|
-
readGlobalPrefix,
|
|
75
78
|
vscodePluginDir
|
|
76
|
-
} from "../chunk-
|
|
77
|
-
import
|
|
78
|
-
writeJsonAtomic
|
|
79
|
-
} from "../chunk-T7E75EKA.js";
|
|
79
|
+
} from "../chunk-ZMKEKWNR.js";
|
|
80
|
+
import "../chunk-T7E75EKA.js";
|
|
80
81
|
import {
|
|
81
82
|
getApiKey
|
|
82
|
-
} from "../chunk-
|
|
83
|
+
} from "../chunk-4SB46XLF.js";
|
|
83
84
|
import {
|
|
84
85
|
NPX_LATEST_COMMAND
|
|
85
|
-
} from "../chunk-
|
|
86
|
+
} from "../chunk-FVOCQSBG.js";
|
|
86
87
|
import {
|
|
87
88
|
CANONICAL_PACKAGE,
|
|
88
89
|
LEGACY_PACKAGE,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
globalUpgradeEntry,
|
|
92
|
-
isNewerVersion,
|
|
93
|
-
isReleaseVersion,
|
|
94
|
-
isSameMajorVersion,
|
|
95
|
-
ownPackageRoot,
|
|
96
|
-
packageVersionAt
|
|
97
|
-
} from "../chunk-5YY3IJT4.js";
|
|
98
|
-
|
|
99
|
-
// src/upgrade-lock.ts
|
|
100
|
-
import { fork } from "child_process";
|
|
101
|
-
import { createHash } from "crypto";
|
|
102
|
-
import { existsSync, mkdirSync, readFileSync, realpathSync, unlinkSync } from "fs";
|
|
103
|
-
import { createServer, Server } from "net";
|
|
104
|
-
import { basename, dirname, join } from "path";
|
|
105
|
-
var LOCK_HOST = "127.0.0.1";
|
|
106
|
-
var LOCK_PORT_START = 49152;
|
|
107
|
-
var LOCK_PORT_COUNT = 16384;
|
|
108
|
-
var INHERITED_LOCK_ENV = "PUSHARY_UPGRADE_LOCK";
|
|
109
|
-
var LOCK_READY = "pushary-upgrade-lock-ready";
|
|
110
|
-
var LOCK_HANDLE = "pushary-upgrade-lock-handle";
|
|
111
|
-
var HANDOFF_TIMEOUT_MS = 1e4;
|
|
112
|
-
var FINISH_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
113
|
-
var KERNEL_LOCK_FORMAT = "kernel-v1";
|
|
114
|
-
var heldLocks = /* @__PURE__ */ new Map();
|
|
115
|
-
var canonicalLockPath = (path) => {
|
|
116
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
117
|
-
return join(realpathSync(dirname(path)), basename(path));
|
|
118
|
-
};
|
|
119
|
-
var lockPort = (path) => LOCK_PORT_START + createHash("sha256").update(path).digest().readUInt32BE(0) % LOCK_PORT_COUNT;
|
|
120
|
-
var readLockRecord = (path) => {
|
|
121
|
-
try {
|
|
122
|
-
const value = JSON.parse(readFileSync(path, "utf8"));
|
|
123
|
-
const pid = value && typeof value === "object" && "pid" in value ? value.pid : void 0;
|
|
124
|
-
return {
|
|
125
|
-
pid: typeof pid === "number" && Number.isInteger(pid) && pid > 0 ? pid : void 0,
|
|
126
|
-
installationPending: value !== null && typeof value === "object" && "installationPending" in value && value.installationPending === true,
|
|
127
|
-
usesKernelLock: value !== null && typeof value === "object" && "format" in value && value.format === KERNEL_LOCK_FORMAT
|
|
128
|
-
};
|
|
129
|
-
} catch {
|
|
130
|
-
return { pid: void 0, usesKernelLock: false, installationPending: false };
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
var isProcessAlive = (pid) => {
|
|
134
|
-
try {
|
|
135
|
-
process.kill(pid, 0);
|
|
136
|
-
return true;
|
|
137
|
-
} catch (error) {
|
|
138
|
-
return !(error instanceof Error && "code" in error && error.code === "ESRCH");
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
var rejectConnection = (socket) => {
|
|
142
|
-
socket.destroy();
|
|
143
|
-
};
|
|
144
|
-
var inheritLock = (path) => new Promise((resolve) => {
|
|
145
|
-
const done = (claim) => {
|
|
146
|
-
clearTimeout(timer);
|
|
147
|
-
process.off("message", receive);
|
|
148
|
-
process.off("disconnect", disconnected);
|
|
149
|
-
resolve(claim);
|
|
150
|
-
};
|
|
151
|
-
const disconnected = () => done({ kind: "unavailable", reason: "Upgrade parent disconnected before transferring its lock" });
|
|
152
|
-
const receive = (message, handle) => {
|
|
153
|
-
if (message !== LOCK_HANDLE || !(handle instanceof Server)) return;
|
|
154
|
-
const address = handle.address();
|
|
155
|
-
if (address === null || typeof address === "string" || address.port !== lockPort(path) || address.address !== LOCK_HOST) {
|
|
156
|
-
handle.close();
|
|
157
|
-
done({ kind: "unavailable", reason: "Invalid inherited upgrade lock" });
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
handle.on("connection", rejectConnection);
|
|
161
|
-
heldLocks.set(path, handle);
|
|
162
|
-
done({ kind: "inherited" });
|
|
163
|
-
process.disconnect?.();
|
|
164
|
-
};
|
|
165
|
-
const timer = setTimeout(() => done({ kind: "unavailable", reason: "Upgrade lock handoff timed out" }), HANDOFF_TIMEOUT_MS);
|
|
166
|
-
process.on("message", receive);
|
|
167
|
-
process.once("disconnect", disconnected);
|
|
168
|
-
if (!process.send || !process.connected) return disconnected();
|
|
169
|
-
process.send(LOCK_READY, (error) => {
|
|
170
|
-
if (error) disconnected();
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
var claimUpgradeLock = async (request = {}) => {
|
|
174
|
-
let server;
|
|
175
|
-
try {
|
|
176
|
-
const path = canonicalLockPath(request.lockPath ?? autoUpdateLock());
|
|
177
|
-
const inheritedPath = process.env[INHERITED_LOCK_ENV];
|
|
178
|
-
delete process.env[INHERITED_LOCK_ENV];
|
|
179
|
-
if (inheritedPath === path && !heldLocks.has(path)) return await inheritLock(path);
|
|
180
|
-
server = createServer(rejectConnection);
|
|
181
|
-
const listener = server;
|
|
182
|
-
await new Promise((resolve, reject) => {
|
|
183
|
-
listener.once("error", reject);
|
|
184
|
-
listener.listen({ host: LOCK_HOST, port: lockPort(path), exclusive: true }, resolve);
|
|
185
|
-
});
|
|
186
|
-
const record = readLockRecord(path);
|
|
187
|
-
if (record.installationPending) {
|
|
188
|
-
server.close();
|
|
189
|
-
return { kind: "unavailable", reason: `An earlier installation did not finish safely. Stop its npm processes (or restart the computer), then remove ${path} and retry the upgrade.` };
|
|
190
|
-
}
|
|
191
|
-
if (existsSync(path) && !record.usesKernelLock && (record.pid === void 0 || (request.isAlive ?? isProcessAlive)(record.pid))) {
|
|
192
|
-
server.close();
|
|
193
|
-
return { kind: "held", holderPid: record.pid };
|
|
194
|
-
}
|
|
195
|
-
writeJsonAtomic(path, { pid: process.pid, format: KERNEL_LOCK_FORMAT }, 384);
|
|
196
|
-
heldLocks.set(path, server);
|
|
197
|
-
return { kind: "acquired" };
|
|
198
|
-
} catch (error) {
|
|
199
|
-
server?.close();
|
|
200
|
-
if (error instanceof Error && "code" in error && error.code === "EADDRINUSE") {
|
|
201
|
-
return { kind: "held", holderPid: readLockRecord(request.lockPath ?? autoUpdateLock()).pid };
|
|
202
|
-
}
|
|
203
|
-
return { kind: "unavailable", reason: npmErrorMessage(error) };
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
var releaseAutoUpdateLock = (lockPath) => {
|
|
207
|
-
const path = canonicalLockPath(lockPath);
|
|
208
|
-
const server = heldLocks.get(path);
|
|
209
|
-
if (!server) return;
|
|
210
|
-
heldLocks.delete(path);
|
|
211
|
-
try {
|
|
212
|
-
const record = readLockRecord(path);
|
|
213
|
-
if (record.pid === process.pid && !record.installationPending) unlinkSync(path);
|
|
214
|
-
} finally {
|
|
215
|
-
server.close();
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
var finishWithUpgradeLock = (request) => new Promise((resolve, reject) => {
|
|
219
|
-
const path = canonicalLockPath(request.lockPath ?? autoUpdateLock());
|
|
220
|
-
const server = heldLocks.get(path);
|
|
221
|
-
if (!server) return reject(new Error("Cannot finish an upgrade without its lock"));
|
|
222
|
-
const child = fork(request.entry, [...request.args], {
|
|
223
|
-
execArgv: [],
|
|
224
|
-
stdio: request.stdio ?? ["inherit", "inherit", "inherit", "ipc"],
|
|
225
|
-
env: { ...process.env, ...request.env, [INHERITED_LOCK_ENV]: path }
|
|
226
|
-
});
|
|
227
|
-
const timer = setTimeout(() => child.kill("SIGKILL"), FINISH_TIMEOUT_MS);
|
|
228
|
-
child.on("message", (message) => {
|
|
229
|
-
if (message === LOCK_READY) child.send(LOCK_HANDLE, server, (error) => {
|
|
230
|
-
if (error) child.kill();
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
child.once("error", (error) => {
|
|
234
|
-
clearTimeout(timer);
|
|
235
|
-
reject(error);
|
|
236
|
-
});
|
|
237
|
-
child.once("exit", (code, signal) => {
|
|
238
|
-
clearTimeout(timer);
|
|
239
|
-
if (code === 0) resolve();
|
|
240
|
-
else reject(new Error(`Upgrade finish exited with ${signal ?? code}`));
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
var installWithUpgradeLock = (request, lockPath = autoUpdateLock(), runNpm) => {
|
|
244
|
-
const path = canonicalLockPath(lockPath);
|
|
245
|
-
if (!heldLocks.has(path)) throw new Error("Cannot install an upgrade without its lock");
|
|
246
|
-
writeJsonAtomic(path, { pid: process.pid, format: KERNEL_LOCK_FORMAT, installationPending: true }, 384);
|
|
247
|
-
installPackageGlobally(request, runNpm);
|
|
248
|
-
writeJsonAtomic(path, { pid: process.pid, format: KERNEL_LOCK_FORMAT }, 384);
|
|
249
|
-
};
|
|
90
|
+
getPackageVersion
|
|
91
|
+
} from "../chunk-XEIV5QOT.js";
|
|
250
92
|
|
|
251
93
|
// bin/pushary-upgrade.ts
|
|
252
|
-
import { existsSync
|
|
94
|
+
import { existsSync } from "fs";
|
|
253
95
|
import { homedir } from "os";
|
|
254
|
-
import { join
|
|
255
|
-
|
|
256
|
-
// src/global-upgrade.ts
|
|
257
|
-
import { existsSync as existsSync2 } from "fs";
|
|
258
|
-
|
|
259
|
-
// src/auto-update-run.ts
|
|
260
|
-
import { closeSync, mkdirSync as mkdirSync2, openSync, statSync, writeSync } from "fs";
|
|
261
|
-
import { dirname as dirname2 } from "path";
|
|
262
|
-
var FINISH_UPGRADE_FLAG = "--finish-upgrade";
|
|
263
|
-
var INSTALL_TIMEOUT_MS = 12e4;
|
|
264
|
-
var LOG_LIMIT_BYTES = 256 * 1024;
|
|
265
|
-
var UNREADABLE_INSTALLED_VERSION = "could not read the installed version";
|
|
266
|
-
var UNREACHABLE_REGISTRY = "could not read the latest version from the npm registry";
|
|
267
|
-
var MANUAL_UPGRADE_COMMAND = `${NPX_LATEST_COMMAND} upgrade`;
|
|
268
|
-
var openAutoUpdateLog = (logPath) => {
|
|
269
|
-
mkdirSync2(dirname2(logPath), { recursive: true });
|
|
270
|
-
const size = statSync(logPath, { throwIfNoEntry: false })?.size ?? 0;
|
|
271
|
-
return openSync(logPath, size > LOG_LIMIT_BYTES ? "w" : "a");
|
|
272
|
-
};
|
|
273
|
-
var appendAutoUpdateLog = (logPath, line) => {
|
|
274
|
-
try {
|
|
275
|
-
const handle = openAutoUpdateLog(logPath);
|
|
276
|
-
try {
|
|
277
|
-
writeSync(handle, `${line}
|
|
278
|
-
`);
|
|
279
|
-
} finally {
|
|
280
|
-
closeSync(handle);
|
|
281
|
-
}
|
|
282
|
-
} catch {
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
var finishInNewInstall = async (request) => {
|
|
287
|
-
const handle = openAutoUpdateLog(request.logPath);
|
|
288
|
-
try {
|
|
289
|
-
await finishWithUpgradeLock({
|
|
290
|
-
entry: request.entry,
|
|
291
|
-
args: [FINISH_UPGRADE_FLAG],
|
|
292
|
-
lockPath: request.lockPath,
|
|
293
|
-
stdio: ["ignore", handle, handle, "ipc"],
|
|
294
|
-
env: { npm_config_prefix: request.prefix }
|
|
295
|
-
});
|
|
296
|
-
} finally {
|
|
297
|
-
closeSync(handle);
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
var incompleteFinishDetail = (logPath) => `installed, but refreshing the agent configs did not finish cleanly; see ${logPath}`;
|
|
301
|
-
var newMajorDetail = (latest) => `${latest} is a new major version; run ${MANUAL_UPGRADE_COMMAND}`;
|
|
302
|
-
var finishInstalledUpgrade = async (context, from, to) => {
|
|
303
|
-
const pending = { result: "finish_pending", from, to, detail: incompleteFinishDetail(context.logPath) };
|
|
304
|
-
recordAutoUpdateCheck(context.statePath, pending, new Date(context.now()).toISOString());
|
|
305
|
-
try {
|
|
306
|
-
await context.finish({ lockPath: context.lockPath, entry: upgradeEntryFor(context.location), prefix: context.location.prefix, logPath: context.logPath });
|
|
307
|
-
return { result: "updated", from, to };
|
|
308
|
-
} catch {
|
|
309
|
-
return pending;
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
var isInstallableRelease = (latest, installed) => latest !== void 0 && isNewerVersion(latest, installed) && isSameMajorVersion(latest, installed);
|
|
313
|
-
var checkAndInstall = async (context) => {
|
|
314
|
-
const installed = packageVersionAt(context.packageRoot);
|
|
315
|
-
if (installed === void 0 || !isReleaseVersion(installed)) {
|
|
316
|
-
return { result: "failed", from: installed, detail: UNREADABLE_INSTALLED_VERSION };
|
|
317
|
-
}
|
|
318
|
-
const previous = readAutoUpdateState(context.statePath);
|
|
319
|
-
const pendingFinish = hasPendingUpgradeFinish(previous, installed);
|
|
320
|
-
const latest = await fetchLatestPublishedVersion({ packageName: context.location.packageName, fetchImpl: context.fetchImpl });
|
|
321
|
-
if (pendingFinish && !isInstallableRelease(latest, installed)) return finishInstalledUpgrade(context, previous.from, installed);
|
|
322
|
-
if (latest === void 0) return { result: "failed", from: installed, detail: UNREACHABLE_REGISTRY };
|
|
323
|
-
if (!isNewerVersion(latest, installed)) return { result: "current", from: installed };
|
|
324
|
-
if (!isSameMajorVersion(latest, installed)) {
|
|
325
|
-
return { result: "needs_manual", from: installed, to: latest, detail: newMajorDetail(latest) };
|
|
326
|
-
}
|
|
327
|
-
appendAutoUpdateLog(context.logPath, `${new Date(context.now()).toISOString()} installing ${context.location.packageName}@${latest} into ${context.location.prefix}`);
|
|
328
|
-
try {
|
|
329
|
-
installWithUpgradeLock({
|
|
330
|
-
packageName: context.location.packageName,
|
|
331
|
-
version: latest,
|
|
332
|
-
prefix: context.location.prefix,
|
|
333
|
-
timeoutMs: INSTALL_TIMEOUT_MS
|
|
334
|
-
}, context.lockPath, context.runNpm);
|
|
335
|
-
} catch (error) {
|
|
336
|
-
return { result: "failed", from: installed, to: latest, detail: npmErrorMessage(error) };
|
|
337
|
-
}
|
|
338
|
-
return finishInstalledUpgrade(context, installed, latest);
|
|
339
|
-
};
|
|
340
|
-
var recordAutoUpdateCheck = (statePath, check, at) => updateAutoUpdateState(statePath, {
|
|
341
|
-
lastCheckAt: at,
|
|
342
|
-
lastResult: check.result,
|
|
343
|
-
from: check.from,
|
|
344
|
-
to: check.to,
|
|
345
|
-
at,
|
|
346
|
-
detail: check.detail,
|
|
347
|
-
announced: check.result === "updated" ? false : void 0
|
|
348
|
-
});
|
|
349
|
-
var runAutoUpdate = async (run = {}) => {
|
|
350
|
-
if ((run.platform ?? process.platform) === "linux") return { kind: "linux" };
|
|
351
|
-
const packageRoot = run.packageRoot ?? ownPackageRoot();
|
|
352
|
-
const location = packageRoot === void 0 ? null : globalInstallLocation(packageRoot);
|
|
353
|
-
if (packageRoot === void 0 || location === null) return { kind: "not_global_install" };
|
|
354
|
-
const now = run.now ?? Date.now;
|
|
355
|
-
const lockPath = run.lockPath ?? autoUpdateLock();
|
|
356
|
-
const logPath = run.logPath ?? autoUpdateLog();
|
|
357
|
-
const claim = await claimUpgradeLock({ lockPath });
|
|
358
|
-
if (claim.kind === "unavailable") {
|
|
359
|
-
const at = new Date(now()).toISOString();
|
|
360
|
-
const state = recordAutoUpdateCheck(run.statePath ?? autoUpdateState(), { result: "failed", detail: claim.reason }, at);
|
|
361
|
-
appendAutoUpdateLog(logPath, `${at} ${describeAutoUpdateCheck(state)}`);
|
|
362
|
-
return { kind: "recorded", state };
|
|
363
|
-
}
|
|
364
|
-
if (claim.kind !== "acquired") return { kind: "locked" };
|
|
365
|
-
try {
|
|
366
|
-
const check = await checkAndInstall({
|
|
367
|
-
lockPath,
|
|
368
|
-
packageRoot,
|
|
369
|
-
statePath: run.statePath ?? autoUpdateState(),
|
|
370
|
-
location,
|
|
371
|
-
logPath,
|
|
372
|
-
now,
|
|
373
|
-
fetchImpl: run.fetchImpl ?? fetch,
|
|
374
|
-
runNpm: run.runNpm ?? execNpm,
|
|
375
|
-
finish: run.finish ?? finishInNewInstall
|
|
376
|
-
});
|
|
377
|
-
const at = new Date(now()).toISOString();
|
|
378
|
-
const state = recordAutoUpdateCheck(run.statePath ?? autoUpdateState(), check, at);
|
|
379
|
-
appendAutoUpdateLog(logPath, `${at} ${describeAutoUpdateCheck(state)}`);
|
|
380
|
-
return { kind: "recorded", state };
|
|
381
|
-
} finally {
|
|
382
|
-
releaseAutoUpdateLock(lockPath);
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
// src/global-upgrade.ts
|
|
387
|
-
var NOT_INSTALLED = { kind: "not_installed" };
|
|
388
|
-
var globalUpgradeSubject = (prefix, install) => {
|
|
389
|
-
if (prefix === void 0) return NOT_INSTALLED;
|
|
390
|
-
const commands = commandsPackage(install);
|
|
391
|
-
if (commands?.version !== void 0) return { kind: "installed", prefix, name: commands.name, version: commands.version };
|
|
392
|
-
return install.kind === "both" ? { kind: "both_installed" } : NOT_INSTALLED;
|
|
393
|
-
};
|
|
394
|
-
var readGlobalUpgradeSubject = (platform = process.platform) => {
|
|
395
|
-
const prefix = readGlobalPrefix();
|
|
396
|
-
return globalUpgradeSubject(prefix, prefix === void 0 ? { kind: "unavailable" } : readGlobalCliInstallAt(prefix, platform));
|
|
397
|
-
};
|
|
398
|
-
var finishWithThisNode = (entry) => finishWithUpgradeLock({ entry, args: [FINISH_UPGRADE_FLAG] });
|
|
399
|
-
var finishGlobalUpgrade = async (subject, platform = process.platform, runFinish = finishWithThisNode) => {
|
|
400
|
-
const entry = globalUpgradeEntry(subject.prefix, subject.name, platform);
|
|
401
|
-
if (!existsSync2(entry)) return { kind: "entry_missing", entry };
|
|
402
|
-
try {
|
|
403
|
-
await runFinish(entry);
|
|
404
|
-
return { kind: "finished" };
|
|
405
|
-
} catch {
|
|
406
|
-
return { kind: "failed" };
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
var describeHeldUpgradeLock = (holderPid) => `Another Pushary upgrade is already running${holderPid === void 0 ? "" : ` (pid ${holderPid})`}. Try again when it has finished.`;
|
|
410
|
-
var withUpgradeLock = async (run, request = {}) => {
|
|
411
|
-
const claim = await claimUpgradeLock(request);
|
|
412
|
-
if (claim.kind === "unavailable") return { kind: "refused", exitCode: EXIT.FAILED, message: `Could not lock the Pushary upgrade: ${claim.reason}` };
|
|
413
|
-
if (claim.kind === "held") return { kind: "refused", exitCode: EXIT.FAILED, message: describeHeldUpgradeLock(claim.holderPid) };
|
|
414
|
-
try {
|
|
415
|
-
await run();
|
|
416
|
-
} finally {
|
|
417
|
-
releaseAutoUpdateLock(request.lockPath ?? autoUpdateLock());
|
|
418
|
-
}
|
|
419
|
-
return { kind: "ran" };
|
|
420
|
-
};
|
|
421
|
-
var finishUpgradeWithLock = async (run, request) => {
|
|
422
|
-
const outcome = await withUpgradeLock(run, request);
|
|
423
|
-
if (outcome.kind === "refused") {
|
|
424
|
-
updateAutoUpdateState(request.statePath, { lastResult: "finish_pending", to: request.installedVersion, detail: outcome.message });
|
|
425
|
-
}
|
|
426
|
-
return outcome;
|
|
427
|
-
};
|
|
428
|
-
var describeUpgradeStart = (subject, latest) => `Upgrading ${subject.name} ${subject.version} -> ${latest ?? "latest"}`;
|
|
429
|
-
var upgradeInstalledPackage = async (subject, effects) => {
|
|
430
|
-
const pendingFinish = effects.hasPendingFinish(subject.version);
|
|
431
|
-
const latest = await effects.fetchLatest(subject.name);
|
|
432
|
-
const newerPublished = latest !== void 0 && isNewerVersion(latest, subject.version);
|
|
433
|
-
if (pendingFinish && !newerPublished) {
|
|
434
|
-
const finish = await effects.finish(subject);
|
|
435
|
-
if (finish.kind !== "finished") return { kind: "pending_finish_failed", finish };
|
|
436
|
-
effects.recordFinished();
|
|
437
|
-
}
|
|
438
|
-
if (latest !== void 0 && !newerPublished) return { kind: "current", version: subject.version };
|
|
439
|
-
effects.announce(describeUpgradeStart(subject, latest));
|
|
440
|
-
try {
|
|
441
|
-
effects.install(subject.name);
|
|
442
|
-
} catch (error) {
|
|
443
|
-
return { kind: "install_failed", detail: npmErrorMessage(error) };
|
|
444
|
-
}
|
|
445
|
-
return { kind: "installed", finish: await effects.finish(subject) };
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
// bin/pushary-upgrade.ts
|
|
96
|
+
import { join } from "path";
|
|
449
97
|
exitOnHelpFlag("upgrade");
|
|
450
98
|
var detectInstallModes = () => {
|
|
451
99
|
const candidates = [
|
|
452
100
|
{
|
|
453
101
|
label: "Cursor plugin",
|
|
454
102
|
upgrade: "updates itself through Cursor",
|
|
455
|
-
present:
|
|
103
|
+
present: existsSync(cursorPluginDir())
|
|
456
104
|
},
|
|
457
105
|
{
|
|
458
106
|
label: "VS Code plugin",
|
|
459
107
|
upgrade: `${NPX_LATEST_COMMAND} setup --agents vscode`,
|
|
460
|
-
present:
|
|
108
|
+
present: existsSync(vscodePluginDir())
|
|
461
109
|
},
|
|
462
110
|
{
|
|
463
111
|
label: "Codex config",
|
|
464
112
|
upgrade: `${NPX_LATEST_COMMAND} setup --agents codex`,
|
|
465
|
-
present:
|
|
113
|
+
present: existsSync(codexConfigToml())
|
|
466
114
|
},
|
|
467
115
|
{
|
|
468
116
|
label: "Claude Code config",
|
|
469
117
|
upgrade: `${NPX_LATEST_COMMAND} setup --agents claude_code`,
|
|
470
|
-
present:
|
|
118
|
+
present: existsSync(claudeJson())
|
|
471
119
|
},
|
|
472
120
|
{
|
|
473
121
|
label: "Gemini config",
|
|
474
122
|
upgrade: `${NPX_LATEST_COMMAND} setup --agents gemini_cli`,
|
|
475
|
-
present:
|
|
123
|
+
present: existsSync(geminiSettings())
|
|
476
124
|
},
|
|
477
125
|
{
|
|
478
126
|
label: "Hermes plugin (pip)",
|
|
479
127
|
upgrade: `${NPX_LATEST_COMMAND} setup --agents hermes`,
|
|
480
|
-
present:
|
|
128
|
+
present: existsSync(join(homedir(), ".hermes"))
|
|
481
129
|
}
|
|
482
130
|
];
|
|
483
131
|
return candidates.filter((candidate) => candidate.present).map(({ label, upgrade }) => ({ label, upgrade }));
|
package/dist/bin/pushary-wait.js
CHANGED
|
@@ -4,33 +4,33 @@ import {
|
|
|
4
4
|
} from "../chunk-CVWG2N3Y.js";
|
|
5
5
|
import {
|
|
6
6
|
exitOnFailedResponse
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-LZMH4EGE.js";
|
|
8
8
|
import {
|
|
9
9
|
createIo
|
|
10
10
|
} from "../chunk-U4TMAANR.js";
|
|
11
11
|
import {
|
|
12
12
|
exitOnHelpFlag
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-JGQ2ANHQ.js";
|
|
14
14
|
import {
|
|
15
15
|
rejectUnknownFlags
|
|
16
16
|
} from "../chunk-GMXKITVA.js";
|
|
17
|
-
import "../chunk-
|
|
18
|
-
import "../chunk-
|
|
19
|
-
import "../chunk-
|
|
17
|
+
import "../chunk-DMA3QUOB.js";
|
|
18
|
+
import "../chunk-6JTTJIKJ.js";
|
|
19
|
+
import "../chunk-J7JXA2LX.js";
|
|
20
20
|
import {
|
|
21
21
|
UsageError
|
|
22
22
|
} from "../chunk-7QLSKOSU.js";
|
|
23
23
|
import {
|
|
24
24
|
EXIT
|
|
25
25
|
} from "../chunk-KZERVKTD.js";
|
|
26
|
-
import "../chunk-
|
|
26
|
+
import "../chunk-ZMKEKWNR.js";
|
|
27
27
|
import "../chunk-T7E75EKA.js";
|
|
28
28
|
import {
|
|
29
29
|
getApiKey,
|
|
30
30
|
getBaseUrl
|
|
31
|
-
} from "../chunk-
|
|
32
|
-
import "../chunk-
|
|
33
|
-
import "../chunk-
|
|
31
|
+
} from "../chunk-4SB46XLF.js";
|
|
32
|
+
import "../chunk-FVOCQSBG.js";
|
|
33
|
+
import "../chunk-XEIV5QOT.js";
|
|
34
34
|
|
|
35
35
|
// bin/pushary-wait.ts
|
|
36
36
|
exitOnHelpFlag("wait");
|
package/dist/bin/pushary.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
installNetworkDefaults
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-6JTTJIKJ.js";
|
|
5
|
+
import "../chunk-J7JXA2LX.js";
|
|
6
6
|
import "../chunk-7QLSKOSU.js";
|
|
7
7
|
import {
|
|
8
8
|
EXIT
|
|
9
9
|
} from "../chunk-KZERVKTD.js";
|
|
10
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-ZMKEKWNR.js";
|
|
11
11
|
import "../chunk-T7E75EKA.js";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-4SB46XLF.js";
|
|
13
13
|
import {
|
|
14
14
|
COMMANDS,
|
|
15
15
|
isCommandName,
|
|
16
16
|
renderHelp
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-FVOCQSBG.js";
|
|
18
18
|
import {
|
|
19
19
|
getPackageVersion
|
|
20
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-XEIV5QOT.js";
|
|
21
21
|
|
|
22
22
|
// src/cli/runtime.ts
|
|
23
23
|
var supportsRuntime = (version) => {
|
|
@@ -2,17 +2,17 @@ import {
|
|
|
2
2
|
CLAUDE_HOOK_EVENTS,
|
|
3
3
|
GEMINI_HOOK_EVENTS,
|
|
4
4
|
hasGeminiHooks
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-D3RS57MN.js";
|
|
6
6
|
import {
|
|
7
7
|
CODEX_HOOK_EVENTS,
|
|
8
8
|
hasCodexHooks,
|
|
9
9
|
holdBudgetOf
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ZMKEKWNR.js";
|
|
11
11
|
import {
|
|
12
12
|
CURSOR_GATE_EVENTS,
|
|
13
13
|
HOOK_LOCATOR_BINARY,
|
|
14
14
|
hookCommandHoldBudget
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-XEIV5QOT.js";
|
|
16
16
|
|
|
17
17
|
// src/diagnostics/wiring.ts
|
|
18
18
|
var record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AGENT_CHOICES
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HU2LWGEE.js";
|
|
4
4
|
import {
|
|
5
5
|
isBridgeLocator
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LXWUYG7D.js";
|
|
7
7
|
import {
|
|
8
8
|
pusharyHookExecutable
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-5K43TBK4.js";
|
|
10
10
|
import {
|
|
11
11
|
BELL_HOOK_BINARY
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-COSADFEH.js";
|
|
13
13
|
|
|
14
14
|
// src/setup/hook-ownership.ts
|
|
15
15
|
var commandsIn = (value) => {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
readExistingMachineId
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-J7JXA2LX.js";
|
|
4
4
|
import {
|
|
5
5
|
NetworkError
|
|
6
6
|
} from "./chunk-7QLSKOSU.js";
|
|
7
7
|
import {
|
|
8
8
|
getBaseUrl
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4SB46XLF.js";
|
|
10
10
|
import {
|
|
11
11
|
clientContextHeaders,
|
|
12
12
|
getPackageVersion
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-XEIV5QOT.js";
|
|
14
14
|
|
|
15
15
|
// src/cli/net.ts
|
|
16
16
|
import { createRequire } from "module";
|