@pushary/agent-hooks 1.9.0 → 1.9.2
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/data/cursor-plugin/.cursor-plugin/plugin.json +1 -1
- package/data/cursor-plugin/CHANGELOG.md +4 -0
- package/data/cursor-plugin/scripts/pushary-gate.mjs +1 -1
- package/data/vscode-plugin/.claude-plugin/plugin.json +1 -1
- package/data/vscode-plugin/CHANGELOG.md +4 -0
- package/data/vscode-plugin/scripts/pushary-gate.mjs +1 -1
- 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 +99 -48
- 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 +26 -23
- 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 +69 -52
- 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-7TQQSQZ7.js → chunk-2E4SRGYD.js} +17 -12
- package/dist/{chunk-TUZ7WKOF.js → chunk-2XK6D4WL.js} +1 -1
- package/dist/{chunk-42E4DE6C.js → chunk-35N53QLA.js} +10 -9
- package/dist/{chunk-VV4SBPCQ.js → chunk-3O4EBTR3.js} +1 -1
- package/dist/{chunk-XGS2DHGF.js → chunk-4KMTRXNL.js} +2 -2
- package/dist/chunk-6S727YUV.js +242 -0
- package/dist/{chunk-K75TP4JY.js → chunk-73BH4SZY.js} +2 -2
- package/dist/{chunk-SDSKTRIV.js → chunk-ABIW72ST.js} +1 -1
- package/dist/{chunk-HHNFGWR5.js → chunk-AL4NHBZ6.js} +1 -1
- package/dist/{chunk-YFS4HYCI.js → chunk-B6BLCHJW.js} +3 -3
- package/dist/{chunk-JOQEPWDH.js → chunk-BFVE3WPB.js} +2 -2
- package/dist/{chunk-IQUBCAEK.js → chunk-BK3R5NRE.js} +1 -1
- package/dist/{chunk-ET6QSY3H.js → chunk-CEHDCHXK.js} +1 -1
- package/dist/{chunk-P25O4K3J.js → chunk-COVPHB56.js} +7 -5
- package/dist/{chunk-MBVV3RX3.js → chunk-CTYCABBH.js} +1 -1
- package/dist/{chunk-RZXQFAWR.js → chunk-DKDZXJHZ.js} +1 -1
- package/dist/chunk-EO23EUOK.js +14 -0
- package/dist/{chunk-CKPDSFY3.js → chunk-ESME4HN2.js} +5 -5
- package/dist/{chunk-NAJ3UV4E.js → chunk-EUNYNLDU.js} +3 -3
- package/dist/{chunk-MQJWO3AA.js → chunk-FHLRRCUZ.js} +3 -3
- package/dist/{chunk-7LLNRCOK.js → chunk-FWQM6V7Z.js} +1 -1
- package/dist/{chunk-CFAD2LTH.js → chunk-HLNSTJND.js} +2 -2
- package/dist/{chunk-R76C43H7.js → chunk-HZ57E6LS.js} +84 -50
- package/dist/{chunk-ZMVLKPT7.js → chunk-HZYUDXIH.js} +5 -5
- package/dist/{chunk-OXQKXZJ3.js → chunk-IH5NZMN4.js} +2 -2
- package/dist/{chunk-2V64X5RE.js → chunk-IVPVCCFT.js} +1 -1
- package/dist/chunk-JXLANQLV.js +175 -0
- package/dist/{chunk-OLG6FJV2.js → chunk-KP45FGHD.js} +4 -4
- package/dist/{chunk-EG46RJRF.js → chunk-L52OIZXV.js} +1 -1
- package/dist/{chunk-IJJ3HHFT.js → chunk-MZXXLIF6.js} +1 -1
- package/dist/{chunk-YJZDIFON.js → chunk-N2ATGXI4.js} +2 -2
- package/dist/{chunk-WFVNXGZ6.js → chunk-PN3F7LOB.js} +8 -8
- package/dist/{chunk-4ZXYWEEH.js → chunk-Q36G3P7I.js} +1 -1
- package/dist/{chunk-XXVMUMKT.js → chunk-QDCEEQUS.js} +5 -5
- package/dist/{chunk-VYNTRHB6.js → chunk-RTKPR4UA.js} +1 -1
- package/dist/{chunk-MBNMO5IR.js → chunk-SFKU5DXZ.js} +2 -2
- package/dist/{chunk-JW7DKTT6.js → chunk-SI327OZF.js} +44 -16
- package/dist/{chunk-MGXXQHCM.js → chunk-U4DLXAGD.js} +1 -1
- package/dist/{chunk-US3RDXK7.js → chunk-UBCTOE5X.js} +2 -2
- package/dist/{chunk-4GMZOGH4.js → chunk-UBNJYMTG.js} +7 -6
- package/dist/{chunk-HSM5FIA3.js → chunk-UX2YSFKS.js} +1 -1
- package/dist/{chunk-P6VDRQF3.js → chunk-V3P2VSX7.js} +3 -3
- package/dist/{chunk-HNMMKFYN.js → chunk-VMGLXL74.js} +10 -10
- package/dist/{chunk-LQESQPIT.js → chunk-WCHFDVCC.js} +5 -5
- package/dist/{chunk-3OFHFVPX.js → chunk-WM2MEFCA.js} +1 -1
- package/dist/{chunk-CPBRXBLG.js → chunk-XOXW4D6P.js} +3 -3
- package/dist/{chunk-BG4QCOHQ.js → chunk-XXSAGQAV.js} +4 -4
- package/dist/{chunk-HQWPMVR4.js → chunk-Y4AUVOR7.js} +3 -3
- package/dist/{chunk-75CEJ4WP.js → chunk-Y6DSV2OS.js} +3 -3
- package/dist/{chunk-KETBIX7I.js → chunk-Y73RBCQD.js} +1 -1
- package/dist/{chunk-4PCF34AB.js → chunk-ZFDGCEKO.js} +89 -24
- package/dist/{chunk-ZRHA4PGN.js → chunk-ZNUNWWCN.js} +4 -2
- package/dist/{chunk-K7DY2DQN.js → chunk-ZSOFZDLY.js} +6 -6
- package/dist/global-upgrade-N24WINE7.js +24 -0
- package/dist/paths-53PCHAOJ.js +71 -0
- package/dist/{reapply-FYCVOWCW.js → reapply-2SU2ZHEK.js} +8 -8
- package/dist/src/index.js +20 -20
- package/dist/upgrade-lock-F6SM6IEZ.js +17 -0
- package/package.json +1 -1
|
@@ -3,27 +3,27 @@ import {
|
|
|
3
3
|
expectedLaunchCapabilities,
|
|
4
4
|
hasSpawnProvider,
|
|
5
5
|
resolveControlPolicy
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HLNSTJND.js";
|
|
7
7
|
import {
|
|
8
8
|
daemonHasRemoteProof,
|
|
9
9
|
daemonServiceManagerAvailable,
|
|
10
10
|
hasDaemonServiceDefinition,
|
|
11
11
|
readDaemonNeedsLogin,
|
|
12
12
|
readDaemonStatus
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-WCHFDVCC.js";
|
|
14
14
|
import {
|
|
15
15
|
readControlMode,
|
|
16
16
|
readKeySource
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-ZNUNWWCN.js";
|
|
18
18
|
import {
|
|
19
19
|
getMachineId
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-3O4EBTR3.js";
|
|
21
21
|
import {
|
|
22
22
|
getBaseUrl
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-L52OIZXV.js";
|
|
24
24
|
import {
|
|
25
25
|
getPackageVersion
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-ZFDGCEKO.js";
|
|
27
27
|
|
|
28
28
|
// src/machines.ts
|
|
29
29
|
import { hostname } from "os";
|
|
@@ -67,7 +67,11 @@ var parseMachine = (value) => {
|
|
|
67
67
|
online: raw.online === true
|
|
68
68
|
};
|
|
69
69
|
};
|
|
70
|
-
var
|
|
70
|
+
var serverClockOffsetMs = (response, receivedAt) => {
|
|
71
|
+
const serverTime = Date.parse(response.headers.get("date") ?? "");
|
|
72
|
+
return Number.isFinite(serverTime) ? serverTime - receivedAt : 0;
|
|
73
|
+
};
|
|
74
|
+
var machineReadiness = (machines, machineId, expectedCapabilities, now = Date.now(), clockOffsetMs = 0) => {
|
|
71
75
|
const machine = machines.find((item) => item.machineId === machineId);
|
|
72
76
|
if (!machine) return { kind: "not-ready", detail: "this machine has not heartbeated to the server" };
|
|
73
77
|
if (!machine.online) return { kind: "not-ready", detail: "the server reports this machine offline" };
|
|
@@ -77,15 +81,15 @@ var machineReadiness = (machines, machineId, expectedCapabilities, now = Date.no
|
|
|
77
81
|
if (machine.lastControlAt === null || !Number.isFinite(Date.parse(machine.lastControlAt))) {
|
|
78
82
|
return { kind: "not-ready", detail: "the server has not observed this machine polling the control queue" };
|
|
79
83
|
}
|
|
80
|
-
if (!daemonHasRemoteProof({ kind: "running", lastSuccessfulHeartbeatAt: machine.lastSeenAt, lastSuccessfulControlAt: machine.lastControlAt }, now)) {
|
|
84
|
+
if (!daemonHasRemoteProof({ kind: "running", lastSuccessfulHeartbeatAt: machine.lastSeenAt, lastSuccessfulControlAt: machine.lastControlAt }, now + clockOffsetMs)) {
|
|
81
85
|
return { kind: "not-ready", detail: "the heartbeat or control-queue proof is stale; wake this machine and retry pushary doctor" };
|
|
82
86
|
}
|
|
83
87
|
const missing = expectedCapabilities.filter((capability) => !machine.capabilities.includes(capability));
|
|
84
|
-
return missing.length === 0 ? { kind: "ready", machine } : { kind: "not-ready", detail: `the server is missing capabilities: ${missing.join(", ")}` };
|
|
88
|
+
return missing.length === 0 ? { kind: "ready", machine, clockOffsetMs } : { kind: "not-ready", detail: `the server is missing capabilities: ${missing.join(", ")}` };
|
|
85
89
|
};
|
|
86
90
|
var readMachineReadiness = async (apiKey, expectedCapabilities, deps = {}) => {
|
|
87
91
|
const listed = await listMachines(apiKey, deps);
|
|
88
|
-
return listed.kind === "ok" ? machineReadiness(listed.machines, deps.machineId ?? getMachineId(), expectedCapabilities, deps.now?.()) : listed.kind === "unsupported" ? { kind: "unsupported", detail: "the server does not report machine readiness yet" } : listed;
|
|
92
|
+
return listed.kind === "ok" ? machineReadiness(listed.machines, deps.machineId ?? getMachineId(), expectedCapabilities, deps.now?.(), listed.clockOffsetMs) : listed.kind === "unsupported" ? { kind: "unsupported", detail: "the server does not report machine readiness yet" } : listed;
|
|
89
93
|
};
|
|
90
94
|
var waitForMachineReadiness = async (apiKey, expectedCapabilities, deps = {}) => {
|
|
91
95
|
const attempts = deps.attempts ?? 21;
|
|
@@ -106,11 +110,12 @@ var listMachines = async (apiKey, deps = {}) => {
|
|
|
106
110
|
headers: { Authorization: `Bearer ${apiKey}` },
|
|
107
111
|
signal: AbortSignal.timeout(1e4)
|
|
108
112
|
});
|
|
113
|
+
const clockOffsetMs = serverClockOffsetMs(res, (deps.now ?? Date.now)());
|
|
109
114
|
if (res.status === 404) return { kind: "unsupported" };
|
|
110
115
|
if (!res.ok) return { kind: "failed", detail: `HTTP ${res.status}` };
|
|
111
116
|
const body = await res.json().catch(() => null);
|
|
112
117
|
const list = body && Array.isArray(body.machines) ? body.machines : [];
|
|
113
|
-
return { kind: "ok", machines: list.map(parseMachine).filter((m) => m !== null) };
|
|
118
|
+
return { kind: "ok", machines: list.map(parseMachine).filter((m) => m !== null), clockOffsetMs };
|
|
114
119
|
} catch (err) {
|
|
115
120
|
return { kind: "failed", detail: err instanceof Error ? err.message : "network error" };
|
|
116
121
|
}
|
|
@@ -136,7 +141,7 @@ var readManagedControlEvidence = (apiKey, providers, serverProof) => {
|
|
|
136
141
|
const keyCurrent = Boolean(apiKey) && readKeySource().key === apiKey && readDaemonNeedsLogin().kind !== "blocked";
|
|
137
142
|
const policy = resolveControlPolicy({ mode: readControlMode(), providerAvailable, managerAvailable, servicePresent: serviceInstalled || daemon.kind !== "absent" });
|
|
138
143
|
const localProof = daemonHasRemoteProof(daemon, now);
|
|
139
|
-
const remote = serverProof?.kind === "ready" ? machineReadiness([serverProof.machine], daemon.machineId ?? "", expectedLaunchCapabilities(providers), now) : serverProof;
|
|
144
|
+
const remote = serverProof?.kind === "ready" ? machineReadiness([serverProof.machine], daemon.machineId ?? "", expectedLaunchCapabilities(providers), now, serverProof.clockOffsetMs) : serverProof;
|
|
140
145
|
return {
|
|
141
146
|
ready: keyCurrent && policy === "enabled" && providerAvailable && managerAvailable && serviceInstalled && localProof && remote?.kind === "ready",
|
|
142
147
|
keyCurrent,
|
|
@@ -14,36 +14,36 @@ import {
|
|
|
14
14
|
IDLE_PROMPT_NOTIFICATION,
|
|
15
15
|
NOTIFICATION_PUSH_TYPES,
|
|
16
16
|
POSTTOOLUSE_MIRROR_ONLY_TOOLS
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-RTKPR4UA.js";
|
|
18
18
|
import {
|
|
19
19
|
cancelQuestion,
|
|
20
20
|
isPolicyConfig,
|
|
21
21
|
sendNotification,
|
|
22
22
|
waitForAnswer
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-HZYUDXIH.js";
|
|
24
24
|
import {
|
|
25
25
|
clientErrorKindOf,
|
|
26
26
|
reportClientError
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-XXSAGQAV.js";
|
|
28
28
|
import {
|
|
29
29
|
withRetry
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-XOXW4D6P.js";
|
|
31
31
|
import {
|
|
32
32
|
getMachineId
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-3O4EBTR3.js";
|
|
34
34
|
import {
|
|
35
35
|
reportedInstallSource
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-UBCTOE5X.js";
|
|
37
37
|
import {
|
|
38
38
|
canonicalJson
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-HZ57E6LS.js";
|
|
40
40
|
import {
|
|
41
41
|
writeFileAtomic
|
|
42
42
|
} from "./chunk-T7E75EKA.js";
|
|
43
43
|
import {
|
|
44
44
|
getApiKey,
|
|
45
45
|
getBaseUrl
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-L52OIZXV.js";
|
|
47
47
|
import {
|
|
48
48
|
ACTION_BODY_MAX,
|
|
49
49
|
AGENT_LABELS_BY_TYPE,
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
resolvePolicy,
|
|
71
71
|
toToolLookup,
|
|
72
72
|
truncateLine
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-ZFDGCEKO.js";
|
|
74
74
|
|
|
75
75
|
// src/policy.ts
|
|
76
76
|
import { createHash } from "crypto";
|
|
@@ -576,6 +576,7 @@ var rawActionBody = (toolName, toolInput) => {
|
|
|
576
576
|
if (toolName === "Bash" || toolName === "PowerShell" || toolName === "Monitor" || toolName === "run_shell_command" || toolName === "shell" || toolName === "apply_patch") {
|
|
577
577
|
return firstString(toolInput.command);
|
|
578
578
|
}
|
|
579
|
+
if (toolName === "write_stdin" || toolName === "request_permissions") return JSON.stringify(toolInput, null, 2);
|
|
579
580
|
return firstString(toolInput.url, toolInput.href);
|
|
580
581
|
};
|
|
581
582
|
var deriveActionBody = (toolName, toolInput) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pusharyHookExecutable
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EUNYNLDU.js";
|
|
4
4
|
import {
|
|
5
5
|
isProtectedByScope,
|
|
6
6
|
registerHookEntry
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-HZ57E6LS.js";
|
|
8
8
|
|
|
9
9
|
// src/skills-cli.ts
|
|
10
10
|
import { execSync } from "child_process";
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import {
|
|
2
|
+
claimUpgradeLock,
|
|
3
|
+
finishWithUpgradeLock,
|
|
4
|
+
installWithUpgradeLock,
|
|
5
|
+
releaseAutoUpdateLock
|
|
6
|
+
} from "./chunk-JXLANQLV.js";
|
|
7
|
+
import {
|
|
8
|
+
describeAutoUpdateCheck,
|
|
9
|
+
globalInstallLocation,
|
|
10
|
+
hasPendingUpgradeFinish,
|
|
11
|
+
readAutoUpdateState,
|
|
12
|
+
updateAutoUpdateState,
|
|
13
|
+
upgradeEntryFor
|
|
14
|
+
} from "./chunk-COVPHB56.js";
|
|
15
|
+
import {
|
|
16
|
+
EXIT
|
|
17
|
+
} from "./chunk-KZERVKTD.js";
|
|
18
|
+
import {
|
|
19
|
+
autoUpdateLock,
|
|
20
|
+
autoUpdateLog,
|
|
21
|
+
autoUpdateState,
|
|
22
|
+
execNpm,
|
|
23
|
+
fetchLatestPublishedVersion,
|
|
24
|
+
npmErrorMessage,
|
|
25
|
+
readGlobalCliInstallAt,
|
|
26
|
+
readGlobalPrefix
|
|
27
|
+
} from "./chunk-HZ57E6LS.js";
|
|
28
|
+
import {
|
|
29
|
+
NPX_LATEST_COMMAND
|
|
30
|
+
} from "./chunk-ABIW72ST.js";
|
|
31
|
+
import {
|
|
32
|
+
commandsPackage,
|
|
33
|
+
globalUpgradeEntry,
|
|
34
|
+
isNewerVersion,
|
|
35
|
+
isReleaseVersion,
|
|
36
|
+
isSameMajorVersion,
|
|
37
|
+
ownPackageRoot,
|
|
38
|
+
packageVersionAt
|
|
39
|
+
} from "./chunk-ZFDGCEKO.js";
|
|
40
|
+
|
|
41
|
+
// src/global-upgrade.ts
|
|
42
|
+
import { existsSync } from "fs";
|
|
43
|
+
|
|
44
|
+
// src/auto-update-run.ts
|
|
45
|
+
import { closeSync, mkdirSync, openSync, statSync, writeSync } from "fs";
|
|
46
|
+
import { dirname } from "path";
|
|
47
|
+
var FINISH_UPGRADE_FLAG = "--finish-upgrade";
|
|
48
|
+
var INSTALL_TIMEOUT_MS = 12e4;
|
|
49
|
+
var LOG_LIMIT_BYTES = 256 * 1024;
|
|
50
|
+
var UNREADABLE_INSTALLED_VERSION = "could not read the installed version";
|
|
51
|
+
var UNREACHABLE_REGISTRY = "could not read the latest version from the npm registry";
|
|
52
|
+
var MANUAL_UPGRADE_COMMAND = `${NPX_LATEST_COMMAND} upgrade`;
|
|
53
|
+
var openAutoUpdateLog = (logPath) => {
|
|
54
|
+
mkdirSync(dirname(logPath), { recursive: true });
|
|
55
|
+
const size = statSync(logPath, { throwIfNoEntry: false })?.size ?? 0;
|
|
56
|
+
return openSync(logPath, size > LOG_LIMIT_BYTES ? "w" : "a");
|
|
57
|
+
};
|
|
58
|
+
var appendAutoUpdateLog = (logPath, line) => {
|
|
59
|
+
try {
|
|
60
|
+
const handle = openAutoUpdateLog(logPath);
|
|
61
|
+
try {
|
|
62
|
+
writeSync(handle, `${line}
|
|
63
|
+
`);
|
|
64
|
+
} finally {
|
|
65
|
+
closeSync(handle);
|
|
66
|
+
}
|
|
67
|
+
} catch {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var finishInNewInstall = async (request) => {
|
|
72
|
+
const handle = openAutoUpdateLog(request.logPath);
|
|
73
|
+
try {
|
|
74
|
+
await finishWithUpgradeLock({
|
|
75
|
+
entry: request.entry,
|
|
76
|
+
args: [FINISH_UPGRADE_FLAG],
|
|
77
|
+
lockPath: request.lockPath,
|
|
78
|
+
stdio: ["ignore", handle, handle, "ipc"],
|
|
79
|
+
env: { npm_config_prefix: request.prefix }
|
|
80
|
+
});
|
|
81
|
+
} finally {
|
|
82
|
+
closeSync(handle);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var incompleteFinishDetail = (logPath) => `installed, but refreshing the agent configs did not finish cleanly; see ${logPath}`;
|
|
86
|
+
var newMajorDetail = (latest) => `${latest} is a new major version; run ${MANUAL_UPGRADE_COMMAND}`;
|
|
87
|
+
var finishInstalledUpgrade = async (context, from, to) => {
|
|
88
|
+
const pending = { result: "finish_pending", from, to, detail: incompleteFinishDetail(context.logPath) };
|
|
89
|
+
recordAutoUpdateCheck(context.statePath, pending, new Date(context.now()).toISOString());
|
|
90
|
+
try {
|
|
91
|
+
await context.finish({ lockPath: context.lockPath, entry: upgradeEntryFor(context.location), prefix: context.location.prefix, logPath: context.logPath });
|
|
92
|
+
return { result: "updated", from, to };
|
|
93
|
+
} catch {
|
|
94
|
+
return pending;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
var isInstallableRelease = (latest, installed) => latest !== void 0 && isNewerVersion(latest, installed) && isSameMajorVersion(latest, installed);
|
|
98
|
+
var checkAndInstall = async (context) => {
|
|
99
|
+
const installed = packageVersionAt(context.packageRoot);
|
|
100
|
+
if (installed === void 0 || !isReleaseVersion(installed)) {
|
|
101
|
+
return { result: "failed", from: installed, detail: UNREADABLE_INSTALLED_VERSION };
|
|
102
|
+
}
|
|
103
|
+
const previous = readAutoUpdateState(context.statePath);
|
|
104
|
+
const pendingFinish = hasPendingUpgradeFinish(previous, installed);
|
|
105
|
+
const latest = await fetchLatestPublishedVersion({ packageName: context.location.packageName, fetchImpl: context.fetchImpl });
|
|
106
|
+
if (pendingFinish && !isInstallableRelease(latest, installed)) return finishInstalledUpgrade(context, previous.from, installed);
|
|
107
|
+
if (latest === void 0) return { result: "failed", from: installed, detail: UNREACHABLE_REGISTRY };
|
|
108
|
+
if (!isNewerVersion(latest, installed)) return { result: "current", from: installed };
|
|
109
|
+
if (!isSameMajorVersion(latest, installed)) {
|
|
110
|
+
return { result: "needs_manual", from: installed, to: latest, detail: newMajorDetail(latest) };
|
|
111
|
+
}
|
|
112
|
+
appendAutoUpdateLog(context.logPath, `${new Date(context.now()).toISOString()} installing ${context.location.packageName}@${latest} into ${context.location.prefix}`);
|
|
113
|
+
try {
|
|
114
|
+
installWithUpgradeLock({
|
|
115
|
+
packageName: context.location.packageName,
|
|
116
|
+
version: latest,
|
|
117
|
+
prefix: context.location.prefix,
|
|
118
|
+
timeoutMs: INSTALL_TIMEOUT_MS
|
|
119
|
+
}, context.lockPath, context.runNpm);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
return { result: "failed", from: installed, to: latest, detail: npmErrorMessage(error) };
|
|
122
|
+
}
|
|
123
|
+
return finishInstalledUpgrade(context, installed, latest);
|
|
124
|
+
};
|
|
125
|
+
var recordAutoUpdateCheck = (statePath, check, at) => updateAutoUpdateState(statePath, {
|
|
126
|
+
lastCheckAt: at,
|
|
127
|
+
lastResult: check.result,
|
|
128
|
+
from: check.from,
|
|
129
|
+
to: check.to,
|
|
130
|
+
at,
|
|
131
|
+
detail: check.detail,
|
|
132
|
+
announced: check.result === "updated" ? false : void 0
|
|
133
|
+
});
|
|
134
|
+
var runAutoUpdate = async (run = {}) => {
|
|
135
|
+
if ((run.platform ?? process.platform) === "linux") return { kind: "linux" };
|
|
136
|
+
const packageRoot = run.packageRoot ?? ownPackageRoot();
|
|
137
|
+
const location = packageRoot === void 0 ? null : globalInstallLocation(packageRoot);
|
|
138
|
+
if (packageRoot === void 0 || location === null) return { kind: "not_global_install" };
|
|
139
|
+
const now = run.now ?? Date.now;
|
|
140
|
+
const lockPath = run.lockPath ?? autoUpdateLock();
|
|
141
|
+
const logPath = run.logPath ?? autoUpdateLog();
|
|
142
|
+
const claim = await claimUpgradeLock({ lockPath });
|
|
143
|
+
if (claim.kind === "unavailable") {
|
|
144
|
+
const at = new Date(now()).toISOString();
|
|
145
|
+
const state = recordAutoUpdateCheck(run.statePath ?? autoUpdateState(), { result: "failed", detail: claim.reason }, at);
|
|
146
|
+
appendAutoUpdateLog(logPath, `${at} ${describeAutoUpdateCheck(state)}`);
|
|
147
|
+
return { kind: "recorded", state };
|
|
148
|
+
}
|
|
149
|
+
if (claim.kind !== "acquired") return { kind: "locked" };
|
|
150
|
+
try {
|
|
151
|
+
const check = await checkAndInstall({
|
|
152
|
+
lockPath,
|
|
153
|
+
packageRoot,
|
|
154
|
+
statePath: run.statePath ?? autoUpdateState(),
|
|
155
|
+
location,
|
|
156
|
+
logPath,
|
|
157
|
+
now,
|
|
158
|
+
fetchImpl: run.fetchImpl ?? fetch,
|
|
159
|
+
runNpm: run.runNpm ?? execNpm,
|
|
160
|
+
finish: run.finish ?? finishInNewInstall
|
|
161
|
+
});
|
|
162
|
+
const at = new Date(now()).toISOString();
|
|
163
|
+
const state = recordAutoUpdateCheck(run.statePath ?? autoUpdateState(), check, at);
|
|
164
|
+
appendAutoUpdateLog(logPath, `${at} ${describeAutoUpdateCheck(state)}`);
|
|
165
|
+
return { kind: "recorded", state };
|
|
166
|
+
} finally {
|
|
167
|
+
releaseAutoUpdateLock(lockPath);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// src/global-upgrade.ts
|
|
172
|
+
var NOT_INSTALLED = { kind: "not_installed" };
|
|
173
|
+
var globalUpgradeSubject = (prefix, install) => {
|
|
174
|
+
if (prefix === void 0) return NOT_INSTALLED;
|
|
175
|
+
const commands = commandsPackage(install);
|
|
176
|
+
if (commands?.version !== void 0) return { kind: "installed", prefix, name: commands.name, version: commands.version };
|
|
177
|
+
return install.kind === "both" ? { kind: "both_installed" } : NOT_INSTALLED;
|
|
178
|
+
};
|
|
179
|
+
var readGlobalUpgradeSubject = (platform = process.platform) => {
|
|
180
|
+
const prefix = readGlobalPrefix();
|
|
181
|
+
return globalUpgradeSubject(prefix, prefix === void 0 ? { kind: "unavailable" } : readGlobalCliInstallAt(prefix, platform));
|
|
182
|
+
};
|
|
183
|
+
var finishWithThisNode = (entry) => finishWithUpgradeLock({ entry, args: [FINISH_UPGRADE_FLAG] });
|
|
184
|
+
var finishGlobalUpgrade = async (subject, platform = process.platform, runFinish = finishWithThisNode) => {
|
|
185
|
+
const entry = globalUpgradeEntry(subject.prefix, subject.name, platform);
|
|
186
|
+
if (!existsSync(entry)) return { kind: "entry_missing", entry };
|
|
187
|
+
try {
|
|
188
|
+
await runFinish(entry);
|
|
189
|
+
return { kind: "finished" };
|
|
190
|
+
} catch {
|
|
191
|
+
return { kind: "failed" };
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
var describeHeldUpgradeLock = (holderPid) => `Another Pushary upgrade is already running${holderPid === void 0 ? "" : ` (pid ${holderPid})`}. Try again when it has finished.`;
|
|
195
|
+
var withUpgradeLock = async (run, request = {}) => {
|
|
196
|
+
const claim = await claimUpgradeLock(request);
|
|
197
|
+
if (claim.kind === "unavailable") return { kind: "refused", exitCode: EXIT.FAILED, message: `Could not lock the Pushary upgrade: ${claim.reason}` };
|
|
198
|
+
if (claim.kind === "held") return { kind: "refused", exitCode: EXIT.FAILED, message: describeHeldUpgradeLock(claim.holderPid) };
|
|
199
|
+
try {
|
|
200
|
+
await run();
|
|
201
|
+
} finally {
|
|
202
|
+
releaseAutoUpdateLock(request.lockPath ?? autoUpdateLock());
|
|
203
|
+
}
|
|
204
|
+
return { kind: "ran" };
|
|
205
|
+
};
|
|
206
|
+
var finishUpgradeWithLock = async (run, request) => {
|
|
207
|
+
const outcome = await withUpgradeLock(run, request);
|
|
208
|
+
if (outcome.kind === "refused") {
|
|
209
|
+
updateAutoUpdateState(request.statePath, { lastResult: "finish_pending", to: request.installedVersion, detail: outcome.message });
|
|
210
|
+
}
|
|
211
|
+
return outcome;
|
|
212
|
+
};
|
|
213
|
+
var describeUpgradeStart = (subject, latest) => `Upgrading ${subject.name} ${subject.version} -> ${latest ?? "latest"}`;
|
|
214
|
+
var upgradeInstalledPackage = async (subject, effects) => {
|
|
215
|
+
const pendingFinish = effects.hasPendingFinish(subject.version);
|
|
216
|
+
const latest = await effects.fetchLatest(subject.name);
|
|
217
|
+
const newerPublished = latest !== void 0 && isNewerVersion(latest, subject.version);
|
|
218
|
+
if (pendingFinish && !newerPublished) {
|
|
219
|
+
const finish = await effects.finish(subject);
|
|
220
|
+
if (finish.kind !== "finished") return { kind: "pending_finish_failed", finish };
|
|
221
|
+
effects.recordFinished();
|
|
222
|
+
}
|
|
223
|
+
if (latest !== void 0 && !newerPublished) return { kind: "current", version: subject.version };
|
|
224
|
+
effects.announce(describeUpgradeStart(subject, latest));
|
|
225
|
+
try {
|
|
226
|
+
effects.install(subject.name);
|
|
227
|
+
} catch (error) {
|
|
228
|
+
return { kind: "install_failed", detail: npmErrorMessage(error) };
|
|
229
|
+
}
|
|
230
|
+
return { kind: "installed", finish: await effects.finish(subject) };
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export {
|
|
234
|
+
FINISH_UPGRADE_FLAG,
|
|
235
|
+
runAutoUpdate,
|
|
236
|
+
globalUpgradeSubject,
|
|
237
|
+
readGlobalUpgradeSubject,
|
|
238
|
+
finishGlobalUpgrade,
|
|
239
|
+
withUpgradeLock,
|
|
240
|
+
finishUpgradeWithLock,
|
|
241
|
+
upgradeInstalledPackage
|
|
242
|
+
};
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./chunk-KZERVKTD.js";
|
|
4
4
|
import {
|
|
5
5
|
renderCommandHelp
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ABIW72ST.js";
|
|
7
7
|
import {
|
|
8
8
|
getPackageVersion
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZFDGCEKO.js";
|
|
10
10
|
|
|
11
11
|
// src/cli/usage.ts
|
|
12
12
|
var exitOnHelpFlag = (command) => {
|
|
@@ -5,16 +5,16 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
NOTIFICATION_MATCHED_TYPES,
|
|
7
7
|
POSTTOOLUSE_MIRRORED_TOOLS
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-RTKPR4UA.js";
|
|
9
9
|
import {
|
|
10
10
|
isProtectedByScope,
|
|
11
11
|
registerHookEntry
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-HZ57E6LS.js";
|
|
13
13
|
import {
|
|
14
14
|
CLAUDE_PRETOOLUSE_MATCHER,
|
|
15
15
|
HOOK_BUDGETS,
|
|
16
16
|
HOOK_LOCATOR_BINARY
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-ZFDGCEKO.js";
|
|
18
18
|
|
|
19
19
|
// src/gemini-config.ts
|
|
20
20
|
var GEMINI_HOOK_BINARY = "pushary-gemini-hook";
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
decodePublicKey,
|
|
4
4
|
generateSessionKey,
|
|
5
5
|
wrapSessionKey
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-U4DLXAGD.js";
|
|
7
7
|
import {
|
|
8
8
|
fetchTranscriptRecipients,
|
|
9
9
|
uploadTranscriptRecords
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-UX2YSFKS.js";
|
|
11
11
|
|
|
12
12
|
// src/live-session.ts
|
|
13
13
|
var MAX_TRANSCRIPT_QUEUE = 100;
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-POFBE6ZY.js";
|
|
4
4
|
import {
|
|
5
5
|
autoUpdateState
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HZ57E6LS.js";
|
|
7
7
|
import {
|
|
8
8
|
readJsonSafe,
|
|
9
9
|
writeJsonAtomic
|
|
@@ -14,13 +14,14 @@ import {
|
|
|
14
14
|
cliPackagePathSegments,
|
|
15
15
|
globalUpgradeEntry,
|
|
16
16
|
ownPackageRoot
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-ZFDGCEKO.js";
|
|
18
18
|
|
|
19
19
|
// src/auto-update.ts
|
|
20
20
|
import { spawn } from "child_process";
|
|
21
21
|
import { dirname } from "path";
|
|
22
22
|
var AUTO_UPDATE_DISABLE_ENV = "PUSHARY_DISABLE_AUTOUPDATE";
|
|
23
23
|
var AUTO_UPDATE_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
24
|
+
var PENDING_FINISH_RETRY_MS = 5 * 60 * 1e3;
|
|
24
25
|
var AUTO_UPDATE_FLAG = "--auto";
|
|
25
26
|
var NON_GLOBAL_INSTALL_SEGMENTS = ["/_npx/", "/.volta/"];
|
|
26
27
|
var AUTO_UPDATE_RESULTS = ["updated", "current", "needs_manual", "failed", "finish_pending"];
|
|
@@ -75,11 +76,11 @@ var globalInstallLocation = (packageRoot) => {
|
|
|
75
76
|
return null;
|
|
76
77
|
};
|
|
77
78
|
var upgradeEntryFor = (location, platform = process.platform) => globalUpgradeEntry(location.prefix, location.packageName, platform);
|
|
78
|
-
var checkedWithinInterval = (lastCheckAt, now) => {
|
|
79
|
+
var checkedWithinInterval = (lastCheckAt, now, interval) => {
|
|
79
80
|
const last = lastCheckAt === void 0 ? Number.NaN : Date.parse(lastCheckAt);
|
|
80
81
|
if (Number.isNaN(last)) return false;
|
|
81
82
|
const elapsed = now - last;
|
|
82
|
-
return elapsed >= 0 && elapsed <
|
|
83
|
+
return elapsed >= 0 && elapsed < interval;
|
|
83
84
|
};
|
|
84
85
|
var autoUpdateDecision = (input) => {
|
|
85
86
|
if (input.isSubagentStart) return { kind: "skip", reason: "subagent_start" };
|
|
@@ -87,7 +88,8 @@ var autoUpdateDecision = (input) => {
|
|
|
87
88
|
if (offReason !== null) return { kind: "skip", reason: offReason };
|
|
88
89
|
const location = input.packageRoot === void 0 ? null : globalInstallLocation(input.packageRoot);
|
|
89
90
|
if (location === null) return { kind: "skip", reason: "not_global_install" };
|
|
90
|
-
|
|
91
|
+
const interval = input.state.lastResult === "finish_pending" ? PENDING_FINISH_RETRY_MS : AUTO_UPDATE_INTERVAL_MS;
|
|
92
|
+
if (checkedWithinInterval(input.state.lastCheckAt, input.now, interval)) return { kind: "skip", reason: "checked_recently" };
|
|
91
93
|
return { kind: "check", ...location };
|
|
92
94
|
};
|
|
93
95
|
var parseAutoUpdateFlag = (args) => {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/cli/json.ts
|
|
2
|
+
var writeStdoutFully = (text) => new Promise((resolve, reject) => {
|
|
3
|
+
const settle = (error) => {
|
|
4
|
+
if (!error) process.stdout.off("error", settle);
|
|
5
|
+
if (error && (!("code" in error) || error.code !== "EPIPE")) reject(error);
|
|
6
|
+
else resolve();
|
|
7
|
+
};
|
|
8
|
+
process.stdout.once("error", settle);
|
|
9
|
+
process.stdout.write(text, settle);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
writeStdoutFully
|
|
14
|
+
};
|
|
@@ -3,28 +3,28 @@ import {
|
|
|
3
3
|
addPusharyToolPermissions,
|
|
4
4
|
isPusharyHook,
|
|
5
5
|
removeClaudeMcpServers
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FHLRRCUZ.js";
|
|
7
7
|
import {
|
|
8
8
|
CLAUDE_HOOK_EVENTS,
|
|
9
9
|
addGeminiMcpServer,
|
|
10
10
|
removeGeminiMcpServer
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-B6BLCHJW.js";
|
|
12
12
|
import {
|
|
13
13
|
CLAUDE_CODE_AGENT,
|
|
14
14
|
parseApplyPatchFiles
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-35N53QLA.js";
|
|
16
16
|
import {
|
|
17
17
|
guardBinary,
|
|
18
18
|
holdBudgetOf,
|
|
19
19
|
registerHookEntry
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-HZ57E6LS.js";
|
|
21
21
|
import {
|
|
22
22
|
PHONE_ANSWERED_TOOLS,
|
|
23
23
|
hookCompatibleProfile,
|
|
24
24
|
hookCompatibleProfileBySource,
|
|
25
25
|
toToolLookup,
|
|
26
26
|
withHookHoldBudget
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-ZFDGCEKO.js";
|
|
28
28
|
|
|
29
29
|
// src/compatible-config.ts
|
|
30
30
|
import { homedir } from "os";
|
|
@@ -2,17 +2,17 @@ import {
|
|
|
2
2
|
CLAUDE_HOOK_EVENTS,
|
|
3
3
|
GEMINI_HOOK_EVENTS,
|
|
4
4
|
hasGeminiHooks
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-B6BLCHJW.js";
|
|
6
6
|
import {
|
|
7
7
|
CODEX_HOOK_EVENTS,
|
|
8
8
|
hasCodexHooks,
|
|
9
9
|
holdBudgetOf
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-HZ57E6LS.js";
|
|
11
11
|
import {
|
|
12
12
|
CURSOR_GATE_EVENTS,
|
|
13
13
|
HOOK_LOCATOR_BINARY,
|
|
14
14
|
hookCommandHoldBudget
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ZFDGCEKO.js";
|
|
16
16
|
|
|
17
17
|
// src/diagnostics/wiring.ts
|
|
18
18
|
var record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
|