@pushary/agent-hooks 1.4.1 → 1.5.0
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 +20 -0
- package/README.md +27 -0
- package/data/vscode-plugin/README.md +1 -1
- package/data/vscode-plugin/scripts/pushary-gate.mjs +2 -2
- package/dist/bin/pushary-bell-hook.js +22 -21
- package/dist/bin/pushary-bell.js +10 -10
- package/dist/bin/pushary-claude.js +28 -24
- package/dist/bin/pushary-clean.js +30 -26
- package/dist/bin/pushary-codex-bridge.js +16 -14
- package/dist/bin/pushary-codex-hook.js +41 -31
- package/dist/bin/pushary-codex.js +15 -10
- package/dist/bin/pushary-connect.js +11 -11
- package/dist/bin/pushary-cowork.js +6 -6
- package/dist/bin/pushary-daemon.js +31 -28
- package/dist/bin/pushary-disconnect.js +16 -16
- package/dist/bin/pushary-doctor.js +81 -38
- package/dist/bin/pushary-elicitation-hook.js +23 -22
- package/dist/bin/pushary-gemini-bridge.js +13 -11
- package/dist/bin/pushary-gemini-hook.js +29 -24
- package/dist/bin/pushary-hook.js +30 -30
- package/dist/bin/pushary-login.js +14 -14
- package/dist/bin/pushary-logout.js +8 -8
- package/dist/bin/pushary-mode.js +7 -7
- package/dist/bin/pushary-notification-hook.js +26 -25
- package/dist/bin/pushary-opencode-hook.js +25 -24
- package/dist/bin/pushary-permission-denied-hook.js +30 -29
- package/dist/bin/pushary-permission-hook.js +29 -28
- package/dist/bin/pushary-post-hook.js +26 -25
- package/dist/bin/pushary-prompt-hook.js +26 -25
- package/dist/bin/pushary-session-end-hook.js +26 -25
- package/dist/bin/pushary-session-start-hook.js +32 -27
- package/dist/bin/pushary-setup.js +85 -59
- package/dist/bin/pushary-stats.js +6 -6
- package/dist/bin/pushary-status.js +15 -15
- package/dist/bin/pushary-stop-hook.js +26 -25
- package/dist/bin/pushary-stopfailure-hook.js +26 -25
- package/dist/bin/pushary-suggestions.js +4 -4
- package/dist/bin/pushary-transcript-register.js +20 -19
- package/dist/bin/pushary-transcripts.js +8 -8
- package/dist/bin/pushary-upgrade.js +231 -37
- package/dist/bin/pushary-wait.js +7 -7
- package/dist/bin/pushary.js +8 -8
- package/dist/{chunk-MN3XOVRK.js → chunk-2QT3GCU4.js} +1 -1
- package/dist/{chunk-LUT2EZLG.js → chunk-3NBODGQS.js} +1 -1
- package/dist/{chunk-43JKGLZZ.js → chunk-3ZSGKLSO.js} +2 -2
- package/dist/{chunk-QBS6LGEK.js → chunk-43LJSM4F.js} +2 -2
- package/dist/{chunk-SWFF5U2N.js → chunk-43ZDACBO.js} +1 -1
- package/dist/{chunk-HK3IXIQJ.js → chunk-5HYNICS7.js} +1 -1
- package/dist/{chunk-EQRS3SGM.js → chunk-66H2QQAK.js} +1 -1
- package/dist/{chunk-3BPB2HYZ.js → chunk-7XT76LWT.js} +7 -7
- package/dist/{chunk-ALFT7H5B.js → chunk-CQYHOHOK.js} +56 -5
- package/dist/{chunk-3UA6FPRC.js → chunk-DLJN5XEU.js} +3 -3
- package/dist/{chunk-BZBUPZC6.js → chunk-DTQNDR7C.js} +1 -1
- package/dist/{chunk-SAF6NNXY.js → chunk-DYHXOXUF.js} +43 -6
- package/dist/{chunk-FAH3D74E.js → chunk-EA3IELHP.js} +6 -0
- package/dist/{chunk-ED5TA2FJ.js → chunk-EADZPVYW.js} +3 -3
- package/dist/{chunk-I6HRQOMT.js → chunk-F57RGL7K.js} +8 -8
- package/dist/{chunk-LNGYW6G4.js → chunk-FDHMNT24.js} +20 -16
- package/dist/{chunk-37VLIYLI.js → chunk-H5LHTC5X.js} +1 -1
- package/dist/{chunk-EYRGBYZG.js → chunk-HETOKNIL.js} +1 -1
- package/dist/{chunk-K6I5M2ME.js → chunk-HU5LSYL2.js} +2 -2
- package/dist/{chunk-SKXLIVFM.js → chunk-HVBF35GT.js} +2 -2
- package/dist/{chunk-DINDL2CF.js → chunk-HWJW3CPO.js} +25 -5
- package/dist/{chunk-GOFDGTEI.js → chunk-IYTQ4B5I.js} +18 -45
- package/dist/{chunk-WIOXWUUH.js → chunk-J4J45VPZ.js} +3 -3
- package/dist/{chunk-HQLAZWJJ.js → chunk-JF736N4C.js} +5 -5
- package/dist/{chunk-LYXX5NSB.js → chunk-K3QVDAZW.js} +1 -1
- package/dist/{chunk-KI36MAT6.js → chunk-KEOLNHR3.js} +2 -2
- package/dist/{chunk-S3EP4B35.js → chunk-KJRALILH.js} +28 -11
- package/dist/{chunk-PHHGHHOW.js → chunk-MYP4UUFH.js} +1 -1
- package/dist/{chunk-TNS3YLFE.js → chunk-NFKVRMTM.js} +8 -8
- package/dist/{chunk-TF4IOINR.js → chunk-NTQSICPJ.js} +3 -3
- package/dist/{chunk-4FN6VV56.js → chunk-ORLJNJEO.js} +2 -2
- package/dist/{chunk-2UMNXADU.js → chunk-OSJEMXSR.js} +5 -1
- package/dist/chunk-OSSDK5RS.js +162 -0
- package/dist/{chunk-TWWLVOPB.js → chunk-P4BNYJ5Q.js} +5 -5
- package/dist/{chunk-KEMEBTCJ.js → chunk-PCGZXWGQ.js} +4 -4
- package/dist/{chunk-2GMI6JH6.js → chunk-PNNBMH4E.js} +5 -5
- package/dist/{chunk-LGXUGYUH.js → chunk-PYCQXCI5.js} +2 -2
- package/dist/{chunk-JOVWYVSR.js → chunk-SOCEY746.js} +1 -1
- package/dist/{chunk-FVKFDTN6.js → chunk-T4QY64OR.js} +19 -14
- package/dist/{chunk-R3AMKNIW.js → chunk-TFKBFQCE.js} +1 -1
- package/dist/{chunk-CRNAXFQ6.js → chunk-TIWURSLS.js} +1 -1
- package/dist/{chunk-VYUDGQM7.js → chunk-TUXFIVOH.js} +1 -1
- package/dist/{chunk-3T52B2OF.js → chunk-UQHUUZ5H.js} +1 -1
- package/dist/{chunk-TI3ZWXZG.js → chunk-USQDVBEV.js} +2 -2
- package/dist/{chunk-WEO5JCB4.js → chunk-UYDTFCHW.js} +1 -1
- package/dist/{chunk-D7ERHWYB.js → chunk-XWEONSLV.js} +1 -1
- package/dist/{chunk-GKIUEIDX.js → chunk-YQMFGWBD.js} +1 -1
- package/dist/{reapply-BAWDJTG7.js → reapply-D2TFN6XK.js} +9 -8
- package/dist/src/index.js +18 -16
- package/package.json +1 -1
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
registerTranscript
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-NFKVRMTM.js";
|
|
5
5
|
import "../chunk-SGZJ5LYH.js";
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-PCGZXWGQ.js";
|
|
7
|
+
import "../chunk-TFKBFQCE.js";
|
|
8
|
+
import "../chunk-K3QVDAZW.js";
|
|
9
|
+
import "../chunk-NTQSICPJ.js";
|
|
10
|
+
import "../chunk-7XT76LWT.js";
|
|
11
|
+
import "../chunk-EADZPVYW.js";
|
|
12
|
+
import "../chunk-SOCEY746.js";
|
|
13
|
+
import "../chunk-TIWURSLS.js";
|
|
14
|
+
import "../chunk-66H2QQAK.js";
|
|
15
|
+
import "../chunk-2QT3GCU4.js";
|
|
16
16
|
import "../chunk-XHKBHWLX.js";
|
|
17
|
-
import "../chunk-
|
|
18
|
-
import "../chunk-
|
|
19
|
-
import "../chunk-
|
|
17
|
+
import "../chunk-UYDTFCHW.js";
|
|
18
|
+
import "../chunk-UQHUUZ5H.js";
|
|
19
|
+
import "../chunk-DYHXOXUF.js";
|
|
20
20
|
import "../chunk-GMXKITVA.js";
|
|
21
|
-
import "../chunk-
|
|
22
|
-
import "../chunk-TI3ZWXZG.js";
|
|
21
|
+
import "../chunk-USQDVBEV.js";
|
|
23
22
|
import "../chunk-7QLSKOSU.js";
|
|
24
23
|
import "../chunk-KZERVKTD.js";
|
|
25
|
-
import "../chunk-
|
|
24
|
+
import "../chunk-HU5LSYL2.js";
|
|
26
25
|
import "../chunk-T7E75EKA.js";
|
|
27
|
-
import "../chunk-
|
|
28
|
-
import "../chunk-
|
|
26
|
+
import "../chunk-OSJEMXSR.js";
|
|
27
|
+
import "../chunk-T4QY64OR.js";
|
|
28
|
+
import "../chunk-EA3IELHP.js";
|
|
29
|
+
import "../chunk-HWJW3CPO.js";
|
|
29
30
|
|
|
30
31
|
// bin/pushary-transcript-register.ts
|
|
31
32
|
var raw = "";
|
|
@@ -6,18 +6,18 @@ import {
|
|
|
6
6
|
} from "../chunk-SGZJ5LYH.js";
|
|
7
7
|
import {
|
|
8
8
|
transcriptsEnabled
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-2QT3GCU4.js";
|
|
10
10
|
import {
|
|
11
11
|
exitOnHelpFlag
|
|
12
|
-
} from "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-DINDL2CF.js";
|
|
15
|
-
import "../chunk-TI3ZWXZG.js";
|
|
12
|
+
} from "../chunk-P4BNYJ5Q.js";
|
|
13
|
+
import "../chunk-USQDVBEV.js";
|
|
16
14
|
import "../chunk-KZERVKTD.js";
|
|
17
|
-
import "../chunk-
|
|
15
|
+
import "../chunk-HU5LSYL2.js";
|
|
18
16
|
import "../chunk-T7E75EKA.js";
|
|
19
|
-
import "../chunk-
|
|
20
|
-
import "../chunk-
|
|
17
|
+
import "../chunk-OSJEMXSR.js";
|
|
18
|
+
import "../chunk-T4QY64OR.js";
|
|
19
|
+
import "../chunk-EA3IELHP.js";
|
|
20
|
+
import "../chunk-HWJW3CPO.js";
|
|
21
21
|
|
|
22
22
|
// bin/pushary-transcripts.ts
|
|
23
23
|
exitOnHelpFlag("transcripts");
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
reapplyAllAgents
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-PNNBMH4E.js";
|
|
5
|
+
import "../chunk-3NBODGQS.js";
|
|
6
6
|
import {
|
|
7
7
|
waitForMachineReadiness
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import "../chunk-
|
|
8
|
+
} from "../chunk-F57RGL7K.js";
|
|
9
|
+
import "../chunk-J4J45VPZ.js";
|
|
10
10
|
import {
|
|
11
11
|
detectProviderLiveCapabilities,
|
|
12
12
|
hasSpawnProvider,
|
|
13
13
|
resolveControlPolicy
|
|
14
|
-
} from "../chunk-
|
|
15
|
-
import
|
|
14
|
+
} from "../chunk-KEOLNHR3.js";
|
|
15
|
+
import {
|
|
16
|
+
AUTO_UPDATE_DISABLE_ENV,
|
|
17
|
+
describeAutoUpdateCheck,
|
|
18
|
+
globalInstallPrefix,
|
|
19
|
+
isAutoUpdateDisabledByEnv,
|
|
20
|
+
parseAutoUpdateFlag,
|
|
21
|
+
updateAutoUpdateState,
|
|
22
|
+
upgradeEntryFor
|
|
23
|
+
} from "../chunk-OSSDK5RS.js";
|
|
24
|
+
import "../chunk-NTQSICPJ.js";
|
|
16
25
|
import {
|
|
17
26
|
daemonHasRemoteProof,
|
|
18
27
|
daemonServiceManagerAvailable,
|
|
@@ -23,46 +32,207 @@ import {
|
|
|
23
32
|
replaceDaemonService,
|
|
24
33
|
stopDaemonService,
|
|
25
34
|
waitForDaemonRemoteProof
|
|
26
|
-
} from "../chunk-
|
|
27
|
-
import "../chunk-
|
|
35
|
+
} from "../chunk-7XT76LWT.js";
|
|
36
|
+
import "../chunk-EADZPVYW.js";
|
|
28
37
|
import {
|
|
29
38
|
needsShell
|
|
30
39
|
} from "../chunk-XHKBHWLX.js";
|
|
31
|
-
import "../chunk-
|
|
32
|
-
import "../chunk-
|
|
40
|
+
import "../chunk-UYDTFCHW.js";
|
|
41
|
+
import "../chunk-UQHUUZ5H.js";
|
|
33
42
|
import {
|
|
43
|
+
LATEST_TAG,
|
|
44
|
+
autoUpdateLock,
|
|
45
|
+
autoUpdateLog,
|
|
46
|
+
autoUpdateState,
|
|
34
47
|
claudeJson,
|
|
35
48
|
codexConfigToml,
|
|
36
49
|
cursorPluginDir,
|
|
37
50
|
execNpm,
|
|
51
|
+
fetchLatestPublishedVersion,
|
|
38
52
|
geminiSettings,
|
|
53
|
+
installAgentHooksGlobally,
|
|
39
54
|
npmErrorMessage,
|
|
40
55
|
resolveGlobalBinary,
|
|
41
56
|
vscodePluginDir
|
|
42
|
-
} from "../chunk-
|
|
57
|
+
} from "../chunk-DYHXOXUF.js";
|
|
43
58
|
import {
|
|
44
59
|
exitOnHelpFlag
|
|
45
|
-
} from "../chunk-
|
|
46
|
-
import "../chunk-FAH3D74E.js";
|
|
47
|
-
import {
|
|
48
|
-
isNewerVersion
|
|
49
|
-
} from "../chunk-DINDL2CF.js";
|
|
60
|
+
} from "../chunk-P4BNYJ5Q.js";
|
|
50
61
|
import {
|
|
51
62
|
readControlMode
|
|
52
|
-
} from "../chunk-
|
|
53
|
-
import
|
|
54
|
-
|
|
63
|
+
} from "../chunk-USQDVBEV.js";
|
|
64
|
+
import {
|
|
65
|
+
EXIT
|
|
66
|
+
} from "../chunk-KZERVKTD.js";
|
|
67
|
+
import "../chunk-HU5LSYL2.js";
|
|
55
68
|
import "../chunk-T7E75EKA.js";
|
|
56
69
|
import {
|
|
57
70
|
getApiKey
|
|
58
|
-
} from "../chunk-
|
|
59
|
-
import "../chunk-
|
|
71
|
+
} from "../chunk-OSJEMXSR.js";
|
|
72
|
+
import "../chunk-T4QY64OR.js";
|
|
73
|
+
import {
|
|
74
|
+
NPX_LATEST_COMMAND
|
|
75
|
+
} from "../chunk-EA3IELHP.js";
|
|
76
|
+
import {
|
|
77
|
+
isNewerVersion,
|
|
78
|
+
isReleaseVersion,
|
|
79
|
+
isSameMajorVersion,
|
|
80
|
+
ownPackageRoot,
|
|
81
|
+
packageVersionAt
|
|
82
|
+
} from "../chunk-HWJW3CPO.js";
|
|
60
83
|
|
|
61
84
|
// bin/pushary-upgrade.ts
|
|
62
85
|
import { existsSync } from "fs";
|
|
63
86
|
import { homedir } from "os";
|
|
64
87
|
import { join } from "path";
|
|
88
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
89
|
+
|
|
90
|
+
// src/auto-update-run.ts
|
|
65
91
|
import { execFileSync } from "child_process";
|
|
92
|
+
import { closeSync, mkdirSync, openSync, statSync, unlinkSync, writeSync } from "fs";
|
|
93
|
+
import { dirname } from "path";
|
|
94
|
+
var FINISH_UPGRADE_FLAG = "--finish-upgrade";
|
|
95
|
+
var LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
96
|
+
var INSTALL_TIMEOUT_MS = 12e4;
|
|
97
|
+
var FINISH_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
98
|
+
var LOG_LIMIT_BYTES = 256 * 1024;
|
|
99
|
+
var UNREADABLE_INSTALLED_VERSION = "could not read the installed version";
|
|
100
|
+
var UNREACHABLE_REGISTRY = "could not read the latest version from the npm registry";
|
|
101
|
+
var MANUAL_UPGRADE_COMMAND = `${NPX_LATEST_COMMAND} upgrade`;
|
|
102
|
+
var isAlreadyExists = (error) => error instanceof Error && "code" in error && error.code === "EEXIST";
|
|
103
|
+
var createLock = (lockPath, now) => {
|
|
104
|
+
const handle = openSync(lockPath, "wx");
|
|
105
|
+
try {
|
|
106
|
+
writeSync(handle, `${JSON.stringify({ pid: process.pid, at: new Date(now).toISOString() })}
|
|
107
|
+
`);
|
|
108
|
+
} finally {
|
|
109
|
+
closeSync(handle);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
var tryCreateLock = (lockPath, now) => {
|
|
113
|
+
try {
|
|
114
|
+
createLock(lockPath, now);
|
|
115
|
+
return "acquired";
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (isAlreadyExists(error)) return "held";
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
var isStaleLock = (lockPath, now) => {
|
|
122
|
+
const modifiedAt = statSync(lockPath, { throwIfNoEntry: false })?.mtimeMs;
|
|
123
|
+
return modifiedAt !== void 0 && now - modifiedAt > LOCK_STALE_MS;
|
|
124
|
+
};
|
|
125
|
+
var acquireAutoUpdateLock = (lockPath, now) => {
|
|
126
|
+
mkdirSync(dirname(lockPath), { recursive: true });
|
|
127
|
+
if (tryCreateLock(lockPath, now) === "acquired") return "acquired";
|
|
128
|
+
if (!isStaleLock(lockPath, now)) return "held";
|
|
129
|
+
try {
|
|
130
|
+
unlinkSync(lockPath);
|
|
131
|
+
} catch {
|
|
132
|
+
return "held";
|
|
133
|
+
}
|
|
134
|
+
return tryCreateLock(lockPath, now);
|
|
135
|
+
};
|
|
136
|
+
var releaseAutoUpdateLock = (lockPath) => {
|
|
137
|
+
try {
|
|
138
|
+
unlinkSync(lockPath);
|
|
139
|
+
} catch {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
var openAutoUpdateLog = (logPath) => {
|
|
144
|
+
mkdirSync(dirname(logPath), { recursive: true });
|
|
145
|
+
const size = statSync(logPath, { throwIfNoEntry: false })?.size ?? 0;
|
|
146
|
+
return openSync(logPath, size > LOG_LIMIT_BYTES ? "w" : "a");
|
|
147
|
+
};
|
|
148
|
+
var appendAutoUpdateLog = (logPath, line) => {
|
|
149
|
+
try {
|
|
150
|
+
const handle = openAutoUpdateLog(logPath);
|
|
151
|
+
try {
|
|
152
|
+
writeSync(handle, `${line}
|
|
153
|
+
`);
|
|
154
|
+
} finally {
|
|
155
|
+
closeSync(handle);
|
|
156
|
+
}
|
|
157
|
+
} catch {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
var finishInNewInstall = (request) => {
|
|
162
|
+
const handle = openAutoUpdateLog(request.logPath);
|
|
163
|
+
try {
|
|
164
|
+
execFileSync(process.execPath, [request.entry, FINISH_UPGRADE_FLAG], {
|
|
165
|
+
stdio: ["ignore", handle, handle],
|
|
166
|
+
env: { ...process.env, npm_config_prefix: request.prefix },
|
|
167
|
+
timeout: FINISH_TIMEOUT_MS
|
|
168
|
+
});
|
|
169
|
+
} finally {
|
|
170
|
+
closeSync(handle);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var incompleteFinishDetail = (logPath) => `installed, but refreshing the agent configs did not finish cleanly; see ${logPath}`;
|
|
174
|
+
var newMajorDetail = (latest) => `${latest} is a new major version; run ${MANUAL_UPGRADE_COMMAND}`;
|
|
175
|
+
var checkAndInstall = async (context) => {
|
|
176
|
+
const installed = packageVersionAt(context.packageRoot);
|
|
177
|
+
if (installed === void 0 || !isReleaseVersion(installed)) {
|
|
178
|
+
return { result: "failed", from: installed, detail: UNREADABLE_INSTALLED_VERSION };
|
|
179
|
+
}
|
|
180
|
+
const latest = await fetchLatestPublishedVersion({ fetchImpl: context.fetchImpl });
|
|
181
|
+
if (latest === void 0) return { result: "failed", from: installed, detail: UNREACHABLE_REGISTRY };
|
|
182
|
+
if (!isNewerVersion(latest, installed)) return { result: "current", from: installed };
|
|
183
|
+
if (!isSameMajorVersion(latest, installed)) {
|
|
184
|
+
return { result: "needs_manual", from: installed, to: latest, detail: newMajorDetail(latest) };
|
|
185
|
+
}
|
|
186
|
+
appendAutoUpdateLog(context.logPath, `${new Date(context.now()).toISOString()} installing ${latest} into ${context.prefix}`);
|
|
187
|
+
try {
|
|
188
|
+
installAgentHooksGlobally({ version: latest, prefix: context.prefix, timeoutMs: INSTALL_TIMEOUT_MS }, context.runNpm);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
return { result: "failed", from: installed, to: latest, detail: npmErrorMessage(error) };
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
context.finish({ entry: upgradeEntryFor(context.prefix), prefix: context.prefix, logPath: context.logPath });
|
|
194
|
+
} catch {
|
|
195
|
+
return { result: "updated", from: installed, to: latest, detail: incompleteFinishDetail(context.logPath) };
|
|
196
|
+
}
|
|
197
|
+
return { result: "updated", from: installed, to: latest };
|
|
198
|
+
};
|
|
199
|
+
var recordAutoUpdateCheck = (statePath, check, at) => updateAutoUpdateState(statePath, {
|
|
200
|
+
lastCheckAt: at,
|
|
201
|
+
lastResult: check.result,
|
|
202
|
+
from: check.from,
|
|
203
|
+
to: check.to,
|
|
204
|
+
at,
|
|
205
|
+
detail: check.detail,
|
|
206
|
+
announced: check.result === "updated" ? false : void 0
|
|
207
|
+
});
|
|
208
|
+
var runAutoUpdate = async (run = {}) => {
|
|
209
|
+
const packageRoot = run.packageRoot ?? ownPackageRoot();
|
|
210
|
+
const prefix = packageRoot === void 0 ? null : globalInstallPrefix(packageRoot);
|
|
211
|
+
if (packageRoot === void 0 || prefix === null) return { kind: "not_global_install" };
|
|
212
|
+
const now = run.now ?? Date.now;
|
|
213
|
+
const lockPath = run.lockPath ?? autoUpdateLock();
|
|
214
|
+
const logPath = run.logPath ?? autoUpdateLog();
|
|
215
|
+
if (acquireAutoUpdateLock(lockPath, now()) === "held") return { kind: "locked" };
|
|
216
|
+
try {
|
|
217
|
+
const check = await checkAndInstall({
|
|
218
|
+
packageRoot,
|
|
219
|
+
prefix,
|
|
220
|
+
logPath,
|
|
221
|
+
now,
|
|
222
|
+
fetchImpl: run.fetchImpl ?? fetch,
|
|
223
|
+
runNpm: run.runNpm ?? execNpm,
|
|
224
|
+
finish: run.finish ?? finishInNewInstall
|
|
225
|
+
});
|
|
226
|
+
const at = new Date(now()).toISOString();
|
|
227
|
+
const state = recordAutoUpdateCheck(run.statePath ?? autoUpdateState(), check, at);
|
|
228
|
+
appendAutoUpdateLog(logPath, `${at} ${describeAutoUpdateCheck(state)}`);
|
|
229
|
+
return { kind: "recorded", state };
|
|
230
|
+
} finally {
|
|
231
|
+
releaseAutoUpdateLock(lockPath);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// bin/pushary-upgrade.ts
|
|
66
236
|
exitOnHelpFlag("upgrade");
|
|
67
237
|
var detectInstallModes = () => {
|
|
68
238
|
const candidates = [
|
|
@@ -106,18 +276,6 @@ var getInstalledVersion = () => {
|
|
|
106
276
|
return "";
|
|
107
277
|
}
|
|
108
278
|
};
|
|
109
|
-
var fetchLatestVersion = async () => {
|
|
110
|
-
try {
|
|
111
|
-
const res = await fetch("https://registry.npmjs.org/@pushary/agent-hooks/latest", {
|
|
112
|
-
signal: AbortSignal.timeout(5e3)
|
|
113
|
-
});
|
|
114
|
-
if (!res.ok) return void 0;
|
|
115
|
-
const data = await res.json();
|
|
116
|
-
return data.version;
|
|
117
|
-
} catch {
|
|
118
|
-
return void 0;
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
279
|
var finishUpgrade = async () => {
|
|
122
280
|
let apiKey;
|
|
123
281
|
try {
|
|
@@ -183,11 +341,47 @@ var finishUpgrade = async () => {
|
|
|
183
341
|
console.log(controlPolicy === "disabled" ? "Done. Your hooks use the new global install; phone-start remains disabled." : controlPolicy === "unsupported" || controlPolicy === "preserve-absent" ? "Done. Your hooks use the new global install; no background service was added." : "Done. Your hooks and background service use the new global install.");
|
|
184
342
|
console.log("Verify with: pushary doctor");
|
|
185
343
|
};
|
|
344
|
+
var AUTO_UPDATE_ON_MESSAGE = "Automatic updates are on. Pushary checks for a new version once a day, when an agent session starts.";
|
|
345
|
+
var AUTO_UPDATE_OFF_MESSAGE = "Automatic updates are off. Turn them back on with: pushary upgrade --auto=on";
|
|
346
|
+
var AUTO_UPDATE_RUN_MESSAGES = {
|
|
347
|
+
not_global_install: `This copy of Pushary is not a global npm install, so it does not update itself. Run: ${NPX_LATEST_COMMAND} upgrade`,
|
|
348
|
+
locked: "Another automatic update is already running."
|
|
349
|
+
};
|
|
350
|
+
var setAutomaticUpdates = (enabled) => {
|
|
351
|
+
updateAutoUpdateState(autoUpdateState(), { disabled: !enabled });
|
|
352
|
+
console.log(enabled ? AUTO_UPDATE_ON_MESSAGE : AUTO_UPDATE_OFF_MESSAGE);
|
|
353
|
+
if (enabled && isAutoUpdateDisabledByEnv(process.env)) {
|
|
354
|
+
console.log(`${AUTO_UPDATE_DISABLE_ENV} is set in this shell, and it keeps them off wherever it is set.`);
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
var runAutomaticUpdate = async () => {
|
|
358
|
+
const outcome = await runAutoUpdate();
|
|
359
|
+
if (outcome.kind !== "recorded") {
|
|
360
|
+
console.log(AUTO_UPDATE_RUN_MESSAGES[outcome.kind]);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
console.log(`Automatic update: ${describeAutoUpdateCheck(outcome.state)}`);
|
|
364
|
+
if (outcome.state.lastResult === "failed") process.exitCode = 1;
|
|
365
|
+
};
|
|
186
366
|
var main = async () => {
|
|
187
|
-
if (process.argv.includes(
|
|
367
|
+
if (process.argv.includes(FINISH_UPGRADE_FLAG)) {
|
|
188
368
|
await finishUpgrade();
|
|
189
369
|
return;
|
|
190
370
|
}
|
|
371
|
+
const autoFlag = parseAutoUpdateFlag(process.argv.slice(2));
|
|
372
|
+
if (autoFlag.kind === "invalid") {
|
|
373
|
+
console.error(`--auto takes on or off (got ${autoFlag.value || "nothing"}).`);
|
|
374
|
+
process.exitCode = EXIT.USAGE;
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
if (autoFlag.kind === "set") {
|
|
378
|
+
setAutomaticUpdates(autoFlag.enabled);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
if (autoFlag.kind === "run") {
|
|
382
|
+
await runAutomaticUpdate();
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
191
385
|
const installed = getInstalledVersion();
|
|
192
386
|
if (!installed) {
|
|
193
387
|
const found = detectInstallModes();
|
|
@@ -206,14 +400,14 @@ var main = async () => {
|
|
|
206
400
|
console.log("Check the result with: pushary doctor");
|
|
207
401
|
return;
|
|
208
402
|
}
|
|
209
|
-
const latest = await
|
|
403
|
+
const latest = await fetchLatestPublishedVersion();
|
|
210
404
|
if (latest && !isNewerVersion(latest, installed)) {
|
|
211
405
|
console.log(`Already on the latest version (${installed}).`);
|
|
212
406
|
return;
|
|
213
407
|
}
|
|
214
408
|
console.log(`Upgrading @pushary/agent-hooks ${installed} -> ${latest ?? "latest"}`);
|
|
215
409
|
try {
|
|
216
|
-
|
|
410
|
+
installAgentHooksGlobally({ version: LATEST_TAG, timeoutMs: 12e4 });
|
|
217
411
|
} catch (err) {
|
|
218
412
|
console.error(`Upgrade failed: ${npmErrorMessage(err)}`);
|
|
219
413
|
process.exit(1);
|
|
@@ -223,7 +417,7 @@ var main = async () => {
|
|
|
223
417
|
console.error("Upgrade installed, but the new pushary-upgrade binary could not be found on PATH.");
|
|
224
418
|
process.exit(1);
|
|
225
419
|
}
|
|
226
|
-
|
|
420
|
+
execFileSync2(upgradedBinary, [FINISH_UPGRADE_FLAG], {
|
|
227
421
|
stdio: "inherit",
|
|
228
422
|
shell: needsShell(upgradedBinary)
|
|
229
423
|
});
|
package/dist/bin/pushary-wait.js
CHANGED
|
@@ -4,19 +4,17 @@ import {
|
|
|
4
4
|
} from "../chunk-CVWG2N3Y.js";
|
|
5
5
|
import {
|
|
6
6
|
exitOnFailedResponse
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
7
|
+
} from "../chunk-XWEONSLV.js";
|
|
8
|
+
import "../chunk-43LJSM4F.js";
|
|
9
9
|
import {
|
|
10
10
|
createIo
|
|
11
11
|
} from "../chunk-5RUIFDTP.js";
|
|
12
12
|
import {
|
|
13
13
|
exitOnHelpFlag
|
|
14
|
-
} from "../chunk-
|
|
15
|
-
import "../chunk-FAH3D74E.js";
|
|
14
|
+
} from "../chunk-P4BNYJ5Q.js";
|
|
16
15
|
import {
|
|
17
16
|
rejectUnknownFlags
|
|
18
17
|
} from "../chunk-GMXKITVA.js";
|
|
19
|
-
import "../chunk-DINDL2CF.js";
|
|
20
18
|
import "../chunk-SAF6HGAA.js";
|
|
21
19
|
import {
|
|
22
20
|
UsageError
|
|
@@ -27,8 +25,10 @@ import {
|
|
|
27
25
|
import {
|
|
28
26
|
getApiKey,
|
|
29
27
|
getBaseUrl
|
|
30
|
-
} from "../chunk-
|
|
31
|
-
import "../chunk-
|
|
28
|
+
} from "../chunk-OSJEMXSR.js";
|
|
29
|
+
import "../chunk-T4QY64OR.js";
|
|
30
|
+
import "../chunk-EA3IELHP.js";
|
|
31
|
+
import "../chunk-HWJW3CPO.js";
|
|
32
32
|
|
|
33
33
|
// bin/pushary-wait.ts
|
|
34
34
|
exitOnHelpFlag("wait");
|
package/dist/bin/pushary.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
COMMANDS,
|
|
4
|
-
isCommandName,
|
|
5
|
-
renderHelp
|
|
6
|
-
} from "../chunk-FAH3D74E.js";
|
|
7
|
-
import {
|
|
8
|
-
getPackageVersion
|
|
9
|
-
} from "../chunk-DINDL2CF.js";
|
|
10
2
|
import {
|
|
11
3
|
installProxyDispatcher
|
|
12
4
|
} from "../chunk-SAF6HGAA.js";
|
|
@@ -14,6 +6,14 @@ import "../chunk-7QLSKOSU.js";
|
|
|
14
6
|
import {
|
|
15
7
|
EXIT
|
|
16
8
|
} from "../chunk-KZERVKTD.js";
|
|
9
|
+
import {
|
|
10
|
+
COMMANDS,
|
|
11
|
+
isCommandName,
|
|
12
|
+
renderHelp
|
|
13
|
+
} from "../chunk-EA3IELHP.js";
|
|
14
|
+
import {
|
|
15
|
+
getPackageVersion
|
|
16
|
+
} from "../chunk-HWJW3CPO.js";
|
|
17
17
|
|
|
18
18
|
// src/cli/runtime.ts
|
|
19
19
|
var supportsRuntime = (version) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SETUP_FLAGS
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TFKBFQCE.js";
|
|
4
4
|
import {
|
|
5
5
|
parseFlags
|
|
6
6
|
} from "./chunk-GMXKITVA.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
CLAUDE_CONNECTOR_URL,
|
|
15
15
|
COWORK_CONNECTOR_LIMIT,
|
|
16
16
|
COWORK_STANDING_INSTRUCTIONS
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-T4QY64OR.js";
|
|
18
18
|
|
|
19
19
|
// src/cli/cowork.ts
|
|
20
20
|
import { readFileSync } from "fs";
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
} from "./chunk-KZERVKTD.js";
|
|
10
10
|
import {
|
|
11
11
|
getBaseUrl
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-OSJEMXSR.js";
|
|
13
13
|
import {
|
|
14
14
|
isValidApiKey,
|
|
15
15
|
normalizeKeyScope
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-T4QY64OR.js";
|
|
17
17
|
|
|
18
18
|
// src/session.ts
|
|
19
19
|
var samePusharyAccount = (left, right) => left.kind === "ok" && right.kind === "ok" && left.identity.workspaceId !== "" && left.identity.workspaceId === right.identity.workspaceId && left.identity.siteId === right.identity.siteId;
|
|
@@ -4,17 +4,14 @@ import {
|
|
|
4
4
|
} from "./chunk-XHKBHWLX.js";
|
|
5
5
|
import {
|
|
6
6
|
getMachineId
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-UQHUUZ5H.js";
|
|
8
8
|
import {
|
|
9
9
|
pusharyDir,
|
|
10
10
|
resolveGlobalBinary
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import {
|
|
13
|
-
getPackageVersion
|
|
14
|
-
} from "./chunk-DINDL2CF.js";
|
|
11
|
+
} from "./chunk-DYHXOXUF.js";
|
|
15
12
|
import {
|
|
16
13
|
readControlMode
|
|
17
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-USQDVBEV.js";
|
|
18
15
|
import {
|
|
19
16
|
readJsonSafe,
|
|
20
17
|
writeFileAtomic,
|
|
@@ -23,7 +20,10 @@ import {
|
|
|
23
20
|
} from "./chunk-T7E75EKA.js";
|
|
24
21
|
import {
|
|
25
22
|
getApiKey
|
|
26
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-OSJEMXSR.js";
|
|
24
|
+
import {
|
|
25
|
+
getPackageVersion
|
|
26
|
+
} from "./chunk-HWJW3CPO.js";
|
|
27
27
|
|
|
28
28
|
// src/daemon-lifecycle.ts
|
|
29
29
|
import { dirname, join, win32 as win32Path } from "path";
|