@pushary/agent-hooks 0.89.7 → 0.89.9
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 +30 -0
- package/dist/bin/pushary-bell-hook.js +3 -3
- package/dist/bin/pushary-bell.js +3 -3
- package/dist/bin/pushary-claude.js +5 -5
- package/dist/bin/pushary-clean.js +13 -10
- package/dist/bin/pushary-codex-bridge.js +3 -3
- package/dist/bin/pushary-codex-hook.js +3 -3
- package/dist/bin/pushary-codex.js +3 -3
- package/dist/bin/pushary-connect.js +2 -2
- package/dist/bin/pushary-daemon.js +49 -14
- package/dist/bin/pushary-doctor.js +29 -8
- package/dist/bin/pushary-elicitation-hook.js +2 -2
- package/dist/bin/pushary-gemini-bridge.js +3 -3
- package/dist/bin/pushary-gemini-hook.js +3 -3
- package/dist/bin/pushary-hook.js +4 -4
- package/dist/bin/pushary-login.js +2 -2
- package/dist/bin/pushary-logout.js +2 -2
- package/dist/bin/pushary-notification-hook.js +3 -3
- package/dist/bin/pushary-opencode-hook.js +3 -3
- package/dist/bin/pushary-permission-denied-hook.js +4 -4
- package/dist/bin/pushary-permission-hook.js +4 -4
- package/dist/bin/pushary-post-hook.js +3 -3
- package/dist/bin/pushary-prompt-hook.js +3 -3
- package/dist/bin/pushary-session-end-hook.js +3 -3
- package/dist/bin/pushary-session-start-hook.js +3 -3
- package/dist/bin/pushary-setup.js +20 -7
- package/dist/bin/pushary-status.js +4 -4
- package/dist/bin/pushary-stop-hook.js +3 -3
- package/dist/bin/pushary-stopfailure-hook.js +3 -3
- package/dist/bin/pushary-upgrade.js +16 -8
- package/dist/{chunk-BPKMGE7L.js → chunk-4XZCDSNG.js} +1 -1
- package/dist/{chunk-ZH7TWAYK.js → chunk-543KNJKC.js} +390 -37
- package/dist/{chunk-2M66JVZM.js → chunk-DKDDLF5P.js} +1 -1
- package/dist/{chunk-2MEJBUOI.js → chunk-EA3E74P2.js} +1 -1
- package/dist/{chunk-5YUVKPTS.js → chunk-EJT2ER6G.js} +2 -2
- package/dist/{chunk-WQGMUIDW.js → chunk-FX5QSMPY.js} +1 -1
- package/dist/{chunk-42TTFZLV.js → chunk-TF247BET.js} +1 -1
- package/dist/{chunk-TESGYWEM.js → chunk-U5TQCQ25.js} +32 -1
- package/dist/{chunk-L3YUHEB6.js → chunk-V6N4Q223.js} +1 -1
- package/dist/{chunk-6MTNS63X.js → chunk-XX2V4QS5.js} +12 -1
- package/dist/src/index.js +4 -4
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMachineId
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DKDDLF5P.js";
|
|
4
4
|
import {
|
|
5
5
|
getPackageVersion
|
|
6
6
|
} from "./chunk-DINDL2CF.js";
|
|
@@ -46,9 +46,38 @@ var parseMachine = (value) => {
|
|
|
46
46
|
repoKey: typeof raw.repoKey === "string" ? raw.repoKey : null,
|
|
47
47
|
capabilities: Array.isArray(raw.capabilities) ? raw.capabilities.filter((c) => typeof c === "string") : [],
|
|
48
48
|
lastSeenAt: typeof raw.lastSeenAt === "string" ? raw.lastSeenAt : "",
|
|
49
|
+
lastControlAt: typeof raw.lastControlAt === "string" ? raw.lastControlAt : raw.lastControlAt === null ? null : void 0,
|
|
49
50
|
online: raw.online === true
|
|
50
51
|
};
|
|
51
52
|
};
|
|
53
|
+
var machineReadiness = (machines, machineId, expectedCapabilities) => {
|
|
54
|
+
const machine = machines.find((item) => item.machineId === machineId);
|
|
55
|
+
if (!machine) return { kind: "not-ready", detail: "this machine has not heartbeated to the server" };
|
|
56
|
+
if (!machine.online) return { kind: "not-ready", detail: "the server reports this machine offline" };
|
|
57
|
+
if (machine.lastControlAt === void 0) {
|
|
58
|
+
return { kind: "unsupported", detail: "the server does not report control readiness yet" };
|
|
59
|
+
}
|
|
60
|
+
if (machine.lastControlAt === null || !Number.isFinite(Date.parse(machine.lastControlAt))) {
|
|
61
|
+
return { kind: "not-ready", detail: "the server has not observed this machine polling the control queue" };
|
|
62
|
+
}
|
|
63
|
+
const missing = expectedCapabilities.filter((capability) => !machine.capabilities.includes(capability));
|
|
64
|
+
return missing.length === 0 ? { kind: "ready", machine } : { kind: "not-ready", detail: `the server is missing capabilities: ${missing.join(", ")}` };
|
|
65
|
+
};
|
|
66
|
+
var readMachineReadiness = async (apiKey, expectedCapabilities, deps = {}) => {
|
|
67
|
+
const listed = await listMachines(apiKey, deps);
|
|
68
|
+
return listed.kind === "ok" ? machineReadiness(listed.machines, deps.machineId ?? getMachineId(), expectedCapabilities) : listed.kind === "unsupported" ? { kind: "unsupported", detail: "the server does not report machine readiness yet" } : listed;
|
|
69
|
+
};
|
|
70
|
+
var waitForMachineReadiness = async (apiKey, expectedCapabilities, deps = {}) => {
|
|
71
|
+
const attempts = deps.attempts ?? 21;
|
|
72
|
+
const sleep = deps.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
73
|
+
let result = { kind: "not-ready", detail: "this machine has not heartbeated to the server" };
|
|
74
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
75
|
+
result = await readMachineReadiness(apiKey, expectedCapabilities, deps);
|
|
76
|
+
if (result.kind === "ready" || result.kind === "unsupported" || result.kind === "failed" && /^HTTP (?:401|403)$/.test(result.detail)) return result;
|
|
77
|
+
if (attempt + 1 < attempts) await sleep(250);
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
};
|
|
52
81
|
var listMachines = async (apiKey, deps = {}) => {
|
|
53
82
|
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
54
83
|
const baseUrl = deps.baseUrl ?? getBaseUrl();
|
|
@@ -81,6 +110,8 @@ var describeLastSeen = (iso, now = Date.now()) => {
|
|
|
81
110
|
export {
|
|
82
111
|
HEARTBEAT_INTERVAL_MS,
|
|
83
112
|
sendHeartbeat,
|
|
113
|
+
readMachineReadiness,
|
|
114
|
+
waitForMachineReadiness,
|
|
84
115
|
listMachines,
|
|
85
116
|
describeLastSeen
|
|
86
117
|
};
|
|
@@ -46,10 +46,21 @@ var writeFileAtomic = (filePath, contents, mode) => {
|
|
|
46
46
|
};
|
|
47
47
|
var writeJsonAtomic = (filePath, data, mode) => writeFileAtomic(filePath, `${JSON.stringify(data, null, 2)}
|
|
48
48
|
`, mode);
|
|
49
|
+
var writeJsonAtomicDurable = (filePath, data, mode) => {
|
|
50
|
+
writeJsonAtomic(filePath, data, mode);
|
|
51
|
+
if (process.platform === "win32") return;
|
|
52
|
+
const directory = openSync(dirname(filePath), "r");
|
|
53
|
+
try {
|
|
54
|
+
fsyncSync(directory);
|
|
55
|
+
} finally {
|
|
56
|
+
closeSync(directory);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
49
59
|
|
|
50
60
|
export {
|
|
51
61
|
readJsonSafe,
|
|
52
62
|
backupFile,
|
|
53
63
|
writeFileAtomic,
|
|
54
|
-
writeJsonAtomic
|
|
64
|
+
writeJsonAtomic,
|
|
65
|
+
writeJsonAtomicDurable
|
|
55
66
|
};
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
handlePreToolUse
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-EJT2ER6G.js";
|
|
4
4
|
import "../chunk-ATBKJNWS.js";
|
|
5
5
|
import "../chunk-VZKXBFUA.js";
|
|
6
6
|
import "../chunk-YHG74UFF.js";
|
|
@@ -12,21 +12,21 @@ import {
|
|
|
12
12
|
handlePostToolUse,
|
|
13
13
|
handleStop,
|
|
14
14
|
reportEvent
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-4XZCDSNG.js";
|
|
16
16
|
import {
|
|
17
17
|
askUser,
|
|
18
18
|
cancelQuestion,
|
|
19
19
|
waitForAnswer
|
|
20
20
|
} from "../chunk-GKAKAOKC.js";
|
|
21
21
|
import "../chunk-KOPUTJQC.js";
|
|
22
|
-
import "../chunk-
|
|
22
|
+
import "../chunk-DKDDLF5P.js";
|
|
23
23
|
import "../chunk-GMI5QZLG.js";
|
|
24
24
|
import "../chunk-BSZYIAZL.js";
|
|
25
25
|
import "../chunk-SAF6HGAA.js";
|
|
26
26
|
import "../chunk-OFRNZWC4.js";
|
|
27
27
|
import "../chunk-7QLSKOSU.js";
|
|
28
28
|
import "../chunk-KZERVKTD.js";
|
|
29
|
-
import "../chunk-
|
|
29
|
+
import "../chunk-XX2V4QS5.js";
|
|
30
30
|
import {
|
|
31
31
|
getApiKey,
|
|
32
32
|
getBaseUrl
|