@pushary/agent-hooks 1.9.57 → 1.9.58
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 +12 -0
- package/dist/{api-RQAY3A5V.js → api-WVXBM4MR.js} +7 -7
- package/dist/bin/pushary-bell-hook.js +15 -15
- package/dist/bin/pushary-bell.js +3 -3
- package/dist/bin/pushary-claude.js +15 -15
- package/dist/bin/pushary-clean.js +39 -36
- package/dist/bin/pushary-codex-bridge.js +10 -10
- package/dist/bin/pushary-codex-hook.js +19 -19
- package/dist/bin/pushary-codex-session.js +8 -6
- package/dist/bin/pushary-codex.js +8 -8
- package/dist/bin/pushary-connect.js +17 -16
- package/dist/bin/pushary-daemon.js +23 -23
- package/dist/bin/pushary-disconnect.js +17 -17
- package/dist/bin/pushary-doctor.js +28 -26
- package/dist/bin/pushary-elicitation-hook.js +16 -16
- package/dist/bin/pushary-gemini-bridge.js +5 -5
- package/dist/bin/pushary-gemini-hook.js +17 -17
- package/dist/bin/pushary-hook.js +18 -18
- package/dist/bin/pushary-login.js +6 -6
- package/dist/bin/pushary-logout.js +16 -16
- package/dist/bin/pushary-mcp.js +8 -8
- package/dist/bin/pushary-mode.js +6 -6
- package/dist/bin/pushary-notification-hook.js +15 -15
- package/dist/bin/pushary-opencode-hook.js +16 -16
- package/dist/bin/pushary-permission-denied-hook.js +18 -18
- package/dist/bin/pushary-permission-hook.js +18 -18
- package/dist/bin/pushary-post-hook.js +15 -15
- package/dist/bin/pushary-prompt-hook.js +15 -15
- package/dist/bin/pushary-session-end-hook.js +15 -15
- package/dist/bin/pushary-session-start-hook.js +21 -21
- package/dist/bin/pushary-setup.js +52 -255
- package/dist/bin/pushary-status.js +21 -19
- package/dist/bin/pushary-stop-hook.js +15 -15
- package/dist/bin/pushary-stopfailure-hook.js +15 -15
- package/dist/bin/pushary-suggestions.js +6 -6
- package/dist/bin/pushary-transcript-register.js +8 -8
- package/dist/bin/pushary-upgrade.js +97 -48
- package/dist/bin/pushary-wait.js +6 -6
- package/dist/bin/pushary.js +4 -4
- package/dist/{chunk-DDQRYX2L.js → chunk-3KOPY2UQ.js} +1 -1
- package/dist/{chunk-ZU6L34DQ.js → chunk-3WNOO7BM.js} +3 -3
- package/dist/{chunk-RFAF3TOX.js → chunk-4JJ3T7IE.js} +93 -14
- package/dist/{chunk-JCMSISCC.js → chunk-4LUPZ347.js} +1 -1
- package/dist/{chunk-HCIB4YNB.js → chunk-5DZHKNBU.js} +1 -1
- package/dist/{chunk-QQYUWTYS.js → chunk-ATUZX4K7.js} +1 -1
- package/dist/{chunk-CB565EVO.js → chunk-CK5BCFQF.js} +1 -1
- package/dist/{chunk-AN6TVB2H.js → chunk-CSQJCXPX.js} +3 -3
- package/dist/chunk-CZULJ647.js +378 -0
- package/dist/{chunk-6QM54CSJ.js → chunk-DQ565WFA.js} +3 -3
- package/dist/chunk-FAGDOPQI.js +266 -0
- package/dist/{chunk-QLDTBZBP.js → chunk-HRHAZ3GE.js} +5 -5
- package/dist/{chunk-NQDEMRAS.js → chunk-HUWLEVL2.js} +2 -2
- package/dist/{chunk-SQ5G6A6K.js → chunk-IJ6XKKQW.js} +1 -1
- package/dist/{chunk-BAJ3A3BU.js → chunk-JZKEC4XJ.js} +4 -1
- package/dist/{chunk-ZZB4J6CX.js → chunk-K5CAURU5.js} +3 -3
- package/dist/{chunk-7OQ4AJC7.js → chunk-KIH5BDH5.js} +2 -7
- package/dist/{chunk-CUEUANIU.js → chunk-KSVCCSAO.js} +3 -3
- package/dist/{chunk-D2EETYAL.js → chunk-KW6EYFZV.js} +11 -366
- package/dist/{chunk-LW7IWGSV.js → chunk-MCHOBQHE.js} +4 -4
- package/dist/{chunk-TWLWDIFB.js → chunk-MYBCXDIL.js} +3 -1
- package/dist/{chunk-4QD7VE4E.js → chunk-OHD35NPC.js} +1 -1
- package/dist/{chunk-3IBUZQKM.js → chunk-PZOFPAPG.js} +1 -1
- package/dist/{chunk-YKYVDHIY.js → chunk-QDFLBTUP.js} +1 -1
- package/dist/{chunk-Z7Q36I4K.js → chunk-QP3XPS5U.js} +8 -4
- package/dist/{chunk-4YTFYILS.js → chunk-RF74KBF5.js} +4 -4
- package/dist/{chunk-K5SDLOFS.js → chunk-RGQEULXD.js} +6 -6
- package/dist/{chunk-FBKVCODG.js → chunk-S54YLXWW.js} +1 -1
- package/dist/{chunk-PZDMZ7LM.js → chunk-T2AC5VFQ.js} +3 -3
- package/dist/{chunk-OLNBYAPI.js → chunk-T2BEIPK2.js} +2 -2
- package/dist/{chunk-W6363YYZ.js → chunk-TN74MUMB.js} +3 -3
- package/dist/{chunk-2NIRYGTK.js → chunk-UMVVQXAC.js} +2 -2
- package/dist/{chunk-K45CFSYV.js → chunk-VLJ5C6IT.js} +1 -1
- package/dist/{chunk-LVZYIUSR.js → chunk-VPZ5K72D.js} +1 -1
- package/dist/{chunk-AEXACKDR.js → chunk-WVP6UQG3.js} +3 -3
- package/dist/{chunk-T45PAPOG.js → chunk-X6F4BQEE.js} +3 -3
- package/dist/{chunk-2PJENKRJ.js → chunk-XEJV3QSS.js} +76 -29
- package/dist/{chunk-IBSRULIY.js → chunk-XFUKCBPU.js} +8 -8
- package/dist/{chunk-UPFFO4F6.js → chunk-XWY4UW62.js} +3 -3
- package/dist/{chunk-DS6OR5OS.js → chunk-ZEHUWE3X.js} +3 -3
- package/dist/{chunk-OZSP4RIQ.js → chunk-ZJNU32VE.js} +21 -6
- package/dist/{chunk-A54W5A74.js → chunk-ZL3UR6M5.js} +2 -2
- package/dist/{codex-app-cards-switch-SVGTZ2UN.js → codex-app-cards-switch-TVKXJWXE.js} +16 -14
- package/dist/{codex-desktop-launch-SH7OUEEC.js → codex-desktop-launch-ROTJEEGF.js} +3 -1
- package/dist/{codex-session-launch-IQ57OL3N.js → codex-session-launch-VL6ZQA3N.js} +10 -10
- package/dist/{global-upgrade-SRCWQE7N.js → global-upgrade-IPWV5PTM.js} +13 -5
- package/dist/{identity-6KRUO2YO.js → identity-ARPAUNGN.js} +3 -3
- package/dist/{live-capabilities-RKUHAWT6.js → live-capabilities-EWTRY2HA.js} +2 -2
- package/dist/{paths-MUPQZNLG.js → paths-IZTNMJAQ.js} +4 -2
- package/dist/{reapply-YZXZCWCI.js → reapply-ILKOYYKA.js} +17 -17
- package/dist/src/index.js +13 -13
- package/dist/{upgrade-lock-JXP27UKI.js → upgrade-lock-ML73QXIG.js} +3 -5
- package/package.json +1 -1
|
@@ -3,21 +3,21 @@ import {
|
|
|
3
3
|
expectedLaunchCapabilities,
|
|
4
4
|
hasSpawnProvider,
|
|
5
5
|
resolveControlPolicy
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-3KOPY2UQ.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-QP3XPS5U.js";
|
|
14
14
|
import {
|
|
15
15
|
readControlMode,
|
|
16
16
|
readKeySource
|
|
17
17
|
} from "./chunk-IRZ5FVWG.js";
|
|
18
18
|
import {
|
|
19
19
|
getMachineId
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-IJ6XKKQW.js";
|
|
21
21
|
import {
|
|
22
22
|
getBaseUrl
|
|
23
23
|
} from "./chunk-LVDC3RUE.js";
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import {
|
|
2
|
+
callMcpTool
|
|
3
|
+
} from "./chunk-ZL3UR6M5.js";
|
|
4
|
+
import {
|
|
5
|
+
NPX_LATEST_COMMAND
|
|
6
|
+
} from "./chunk-5SFM6XB4.js";
|
|
7
|
+
import {
|
|
8
|
+
classifyConfirmResponse,
|
|
9
|
+
isAnswerSource
|
|
10
|
+
} from "./chunk-GZL3KEPC.js";
|
|
11
|
+
|
|
12
|
+
// src/reach.ts
|
|
13
|
+
var reachVerdict = (channels) => {
|
|
14
|
+
const { yours, site } = channels;
|
|
15
|
+
if (yours === null || site === null) {
|
|
16
|
+
return channels.phoneReachable || channels.webActive > 0 ? { kind: "yours" } : { kind: "nobody" };
|
|
17
|
+
}
|
|
18
|
+
if (yours.phoneReachable) return { kind: "yours" };
|
|
19
|
+
const solo = site.otherMembers === 0;
|
|
20
|
+
if (solo) {
|
|
21
|
+
return site.phoneReachable || site.webActive > 0 ? { kind: "yours" } : { kind: "nobody" };
|
|
22
|
+
}
|
|
23
|
+
if (site.appDevices === 0 && site.webActive === 0) return { kind: "nobody" };
|
|
24
|
+
if (site.webActive > 0 && !yours.webAttributable) {
|
|
25
|
+
return { kind: "unattributable", otherMembers: site.otherMembers };
|
|
26
|
+
}
|
|
27
|
+
return { kind: "others", otherMembers: site.otherMembers };
|
|
28
|
+
};
|
|
29
|
+
var reachesYou = (channels) => reachVerdict(channels).kind === "yours";
|
|
30
|
+
var plural = (count, one, many = `${one}s`) => `${count} ${count === 1 ? one : many}`;
|
|
31
|
+
var describeReach = (channels) => {
|
|
32
|
+
const verdict = reachVerdict(channels);
|
|
33
|
+
if (verdict.kind === "nobody") return "nothing can receive an approval";
|
|
34
|
+
const parts = [];
|
|
35
|
+
const own = channels.yours;
|
|
36
|
+
if (verdict.kind === "yours" && own !== null && own.appDevices > 0) {
|
|
37
|
+
const platforms = own.appPlatforms.length > 0 ? ` (${own.appPlatforms.join(", ")})` : "";
|
|
38
|
+
parts.push(`${plural(own.appDevices, "app device")}${platforms}`);
|
|
39
|
+
} else if (channels.appDevices > 0) {
|
|
40
|
+
const platforms = channels.appPlatforms.length > 0 ? ` (${channels.appPlatforms.join(", ")})` : "";
|
|
41
|
+
parts.push(`${plural(channels.appDevices, "app device")}${platforms}`);
|
|
42
|
+
}
|
|
43
|
+
if (channels.webPhone > 0) parts.push(`${plural(channels.webPhone, "browser")} on a phone`);
|
|
44
|
+
if (channels.webDesktop > 0) parts.push(`${plural(channels.webDesktop, "browser")} on a desktop`);
|
|
45
|
+
const summary = parts.length > 0 ? parts.join(", ") : "a device";
|
|
46
|
+
if (verdict.kind === "others") return `${summary}, none of them yours`;
|
|
47
|
+
if (verdict.kind === "unattributable") return `${summary}, and no way to tell whose`;
|
|
48
|
+
return summary;
|
|
49
|
+
};
|
|
50
|
+
var describeAppRepair = (verdict) => {
|
|
51
|
+
switch (verdict.kind) {
|
|
52
|
+
case "yours":
|
|
53
|
+
return null;
|
|
54
|
+
case "nobody":
|
|
55
|
+
return [
|
|
56
|
+
"Open the Pushary app, sign in, and allow notifications.",
|
|
57
|
+
`If this terminal was never paired with your phone, run: ${NPX_LATEST_COMMAND} setup --connect app`
|
|
58
|
+
];
|
|
59
|
+
case "others":
|
|
60
|
+
return [
|
|
61
|
+
`Reachable devices belong to other members of this workspace (${verdict.otherMembers}).`,
|
|
62
|
+
"Sign in on the Pushary app with your own account so approvals can reach you."
|
|
63
|
+
];
|
|
64
|
+
case "unattributable":
|
|
65
|
+
return [
|
|
66
|
+
"Something is reachable here, but not identifiably yours.",
|
|
67
|
+
"Sign in on the Pushary app so your approvals are routed to your device."
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var describeJustPairedRepair = (verdict) => {
|
|
72
|
+
if (verdict.kind === "nobody") {
|
|
73
|
+
return [
|
|
74
|
+
"The app asks for the notification permission after it grants the pairing.",
|
|
75
|
+
"Open the Pushary app and allow notifications. That is the whole remaining step."
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
return describeAppRepair(verdict) ?? [];
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// src/setup/verify.ts
|
|
82
|
+
var plural2 = (count, one) => `${count} ${one}${count === 1 ? "" : "s"}`;
|
|
83
|
+
var SETUP_AGENT_NAME = "Pushary setup";
|
|
84
|
+
var ownAppPlatforms = (channels) => channels.yours?.appPlatforms ?? channels.appPlatforms;
|
|
85
|
+
var describeRecipients = (push, channels) => {
|
|
86
|
+
const parts = [];
|
|
87
|
+
if (push.app > 0) {
|
|
88
|
+
const platforms = ownAppPlatforms(channels);
|
|
89
|
+
const suffix = platforms.length > 0 ? ` (${platforms.join(", ")})` : "";
|
|
90
|
+
parts.push(`${plural2(push.app, "app device")}${suffix}`);
|
|
91
|
+
}
|
|
92
|
+
if (push.web > 0) parts.push(plural2(push.web, "browser"));
|
|
93
|
+
return parts.length > 0 ? parts.join(" and ") : plural2(push.total, "device");
|
|
94
|
+
};
|
|
95
|
+
var classifyDelivery = (channels, push) => {
|
|
96
|
+
if (push.total <= 0) return { kind: "no-recipients" };
|
|
97
|
+
const verdict = reachVerdict(channels);
|
|
98
|
+
if (verdict.kind === "yours" && (push.app > 0 || channels.yours === null || channels.site?.otherMembers === 0)) {
|
|
99
|
+
return { kind: "delivered", recipients: push.total, deviceLabel: describeRecipients(push, channels) };
|
|
100
|
+
}
|
|
101
|
+
if (verdict.kind === "unattributable") {
|
|
102
|
+
return { kind: "unattributable", recipients: push.total, otherMembers: verdict.otherMembers };
|
|
103
|
+
}
|
|
104
|
+
if (verdict.kind === "others") {
|
|
105
|
+
return { kind: "others-only", recipients: push.total, otherMembers: verdict.otherMembers };
|
|
106
|
+
}
|
|
107
|
+
if (verdict.kind === "yours") {
|
|
108
|
+
const otherMembers = channels.site?.otherMembers ?? 0;
|
|
109
|
+
return { kind: "unattributable", recipients: push.total, otherMembers };
|
|
110
|
+
}
|
|
111
|
+
return { kind: "delivered", recipients: push.total, deviceLabel: describeRecipients(push, channels) };
|
|
112
|
+
};
|
|
113
|
+
var sendTestNotification = async (apiKey) => {
|
|
114
|
+
const result = await callMcpTool(apiKey, "send_notification", {
|
|
115
|
+
title: "Pushary is connected",
|
|
116
|
+
body: "This setup notification reached you. Agent hooks still need a real-agent check.",
|
|
117
|
+
agentName: SETUP_AGENT_NAME
|
|
118
|
+
}, { timeoutMs: 2e4 });
|
|
119
|
+
const toCount = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
120
|
+
const app = toCount(result.delivery?.mobile?.recipients);
|
|
121
|
+
const web = toCount(result.delivery?.web?.recipients);
|
|
122
|
+
return { app, web, total: typeof result.sent === "number" ? result.sent : app + web };
|
|
123
|
+
};
|
|
124
|
+
var verifyDelivery = async (apiKey, channels, deps = {}) => {
|
|
125
|
+
const send = deps.send ?? sendTestNotification;
|
|
126
|
+
try {
|
|
127
|
+
return classifyDelivery(channels, await send(apiKey));
|
|
128
|
+
} catch (err) {
|
|
129
|
+
return { kind: "error", detail: err instanceof Error ? err.message : "send failed" };
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
var describeVerifyOutcome = (outcome) => {
|
|
133
|
+
switch (outcome.kind) {
|
|
134
|
+
case "delivered":
|
|
135
|
+
return { ok: true, message: `Delivered to ${outcome.deviceLabel}. Push works.`, next: [] };
|
|
136
|
+
case "no-recipients":
|
|
137
|
+
return {
|
|
138
|
+
ok: false,
|
|
139
|
+
message: "Nothing to deliver to. Agents are configured; approvals will fall back to the terminal.",
|
|
140
|
+
next: [
|
|
141
|
+
"Run pushary pair to pair your phone.",
|
|
142
|
+
"Then pushary doctor --roundtrip to test a synthetic question and answer."
|
|
143
|
+
]
|
|
144
|
+
};
|
|
145
|
+
case "others-only":
|
|
146
|
+
return {
|
|
147
|
+
ok: false,
|
|
148
|
+
message: `Delivered to ${plural2(outcome.recipients, "device")} on this site, none of them yours.`,
|
|
149
|
+
next: [
|
|
150
|
+
`Approvals for your agent would wake one of your ${plural2(outcome.otherMembers, "teammate")}.`,
|
|
151
|
+
"Run pushary pair to pair your own phone."
|
|
152
|
+
]
|
|
153
|
+
};
|
|
154
|
+
case "unattributable":
|
|
155
|
+
return {
|
|
156
|
+
ok: false,
|
|
157
|
+
message: `Delivered to ${plural2(outcome.recipients, "device")} on this site, and no way to tell whose.`,
|
|
158
|
+
next: [
|
|
159
|
+
"Browser subscriptions carry no owner, and this site has other members.",
|
|
160
|
+
"Install the Pushary app and pair it with pushary pair, or run pushary doctor --roundtrip to prove it reaches you."
|
|
161
|
+
]
|
|
162
|
+
};
|
|
163
|
+
case "error":
|
|
164
|
+
return {
|
|
165
|
+
ok: false,
|
|
166
|
+
message: `Could not send the test notification (${outcome.detail}).`,
|
|
167
|
+
next: ["Agents are configured. Run pushary doctor once the connection is back."]
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
var ROUND_TRIP_QUESTION = "Pushary delivery test. Answer either way to test returning an answer. This does not test your agent hooks.";
|
|
172
|
+
var ROUND_TRIP_TIMEOUT_MS = 55e3;
|
|
173
|
+
var reportNoInterrupt = async () => {
|
|
174
|
+
};
|
|
175
|
+
var defaultAsk = (apiKey, agentName) => (
|
|
176
|
+
// wait:false so the poll is ours: the blocking form returns on the SITE's
|
|
177
|
+
// policy timeout, which a user may have set to seconds, and a setup check
|
|
178
|
+
// reporting "unanswered" after three seconds would be a lie about the product.
|
|
179
|
+
callMcpTool(apiKey, "ask_user", {
|
|
180
|
+
question: ROUND_TRIP_QUESTION,
|
|
181
|
+
type: "confirm",
|
|
182
|
+
agentName,
|
|
183
|
+
wait: false
|
|
184
|
+
}, { timeoutMs: 15e3 })
|
|
185
|
+
);
|
|
186
|
+
var defaultWait = (apiKey, correlationId) => callMcpTool(apiKey, "wait_for_answer", {
|
|
187
|
+
correlationId,
|
|
188
|
+
timeoutMs: ROUND_TRIP_TIMEOUT_MS
|
|
189
|
+
}, { timeoutMs: ROUND_TRIP_TIMEOUT_MS + 5e3 });
|
|
190
|
+
var defaultCancel = async (apiKey, correlationId) => {
|
|
191
|
+
await callMcpTool(apiKey, "cancel_question", { correlationId }, { timeoutMs: 1e4 }).catch(() => {
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
var answeredRoundTrip = (answer, correlationId, latencyMs) => {
|
|
195
|
+
if (answer.value === void 0 || classifyConfirmResponse(answer.value) === null) {
|
|
196
|
+
return { kind: "error", detail: "the server reported an answer without a valid Yes, No or defer value" };
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
kind: "answered",
|
|
200
|
+
value: answer.value,
|
|
201
|
+
latencyMs,
|
|
202
|
+
correlationId,
|
|
203
|
+
...isAnswerSource(answer.answerSource) ? { answerSource: answer.answerSource } : {}
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
var verifyRoundTrip = async (apiKey, agentName = SETUP_AGENT_NAME, deps = {}) => {
|
|
207
|
+
const ask = deps.ask ?? defaultAsk;
|
|
208
|
+
const wait = deps.wait ?? defaultWait;
|
|
209
|
+
const cancel = deps.cancel ?? defaultCancel;
|
|
210
|
+
const interrupted = deps.interrupted ?? reportNoInterrupt;
|
|
211
|
+
const now = deps.now ?? Date.now;
|
|
212
|
+
const started = now();
|
|
213
|
+
let asked;
|
|
214
|
+
try {
|
|
215
|
+
asked = await ask(apiKey, agentName);
|
|
216
|
+
} catch (err) {
|
|
217
|
+
return { kind: "error", detail: err instanceof Error ? err.message : "ask failed" };
|
|
218
|
+
}
|
|
219
|
+
let shutdown;
|
|
220
|
+
const stop = (code) => {
|
|
221
|
+
if (shutdown) return;
|
|
222
|
+
shutdown = (async () => {
|
|
223
|
+
let timer;
|
|
224
|
+
try {
|
|
225
|
+
await Promise.race([
|
|
226
|
+
Promise.all([
|
|
227
|
+
cancel(apiKey, asked.correlationId).catch(() => {
|
|
228
|
+
}),
|
|
229
|
+
interrupted(code).catch(() => {
|
|
230
|
+
})
|
|
231
|
+
]),
|
|
232
|
+
new Promise((resolve) => {
|
|
233
|
+
timer = setTimeout(resolve, 4e3);
|
|
234
|
+
})
|
|
235
|
+
]);
|
|
236
|
+
} finally {
|
|
237
|
+
clearTimeout(timer);
|
|
238
|
+
process.stderr.write("Delivery test interrupted. Cleanup was attempted; an unresolved question expires automatically.\n");
|
|
239
|
+
process.exit(code);
|
|
240
|
+
}
|
|
241
|
+
})();
|
|
242
|
+
};
|
|
243
|
+
const onInterrupt = () => stop(130);
|
|
244
|
+
const onTerminate = () => stop(143);
|
|
245
|
+
if (asked.correlationId) {
|
|
246
|
+
process.on("SIGINT", onInterrupt);
|
|
247
|
+
process.on("SIGTERM", onTerminate);
|
|
248
|
+
}
|
|
249
|
+
let answerObserved = false;
|
|
250
|
+
try {
|
|
251
|
+
if (asked.noDevices || asked.warning) return { kind: "no-recipients" };
|
|
252
|
+
if (asked.mode === "notify_only" || asked.status === "notified") return { kind: "notify-only" };
|
|
253
|
+
if (!asked.correlationId) return { kind: "error", detail: "no correlationId returned" };
|
|
254
|
+
const answer = asked.answered === true ? asked : await wait(apiKey, asked.correlationId);
|
|
255
|
+
if (answer.answered === true) {
|
|
256
|
+
const outcome = answeredRoundTrip(answer, asked.correlationId, now() - started);
|
|
257
|
+
answerObserved = outcome.kind === "answered";
|
|
258
|
+
return outcome;
|
|
259
|
+
}
|
|
260
|
+
return { kind: "unanswered" };
|
|
261
|
+
} catch (err) {
|
|
262
|
+
return { kind: "error", detail: err instanceof Error ? err.message : "wait failed" };
|
|
263
|
+
} finally {
|
|
264
|
+
if (shutdown) await shutdown;
|
|
265
|
+
process.off("SIGINT", onInterrupt);
|
|
266
|
+
process.off("SIGTERM", onTerminate);
|
|
267
|
+
if (!answerObserved && asked.correlationId) await cancel(apiKey, asked.correlationId).catch(() => {
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
var describeAnswerSource = (source) => {
|
|
272
|
+
switch (source) {
|
|
273
|
+
case "mobile_app":
|
|
274
|
+
case "mobile_background":
|
|
275
|
+
return "Answered on your phone.";
|
|
276
|
+
case "mac_app":
|
|
277
|
+
return "Answered on your Mac.";
|
|
278
|
+
case "sandbox":
|
|
279
|
+
return "This was a simulated sandbox answer.";
|
|
280
|
+
default:
|
|
281
|
+
return source ? `Answer source: ${source}. This was a synthetic test.` : "The answering surface was not reported. This was a synthetic test.";
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
var NOTIFICATION_ANSWER_STEPS = /* @__PURE__ */ new Map([
|
|
285
|
+
["ios", "Press and hold the notification, then tap Approve."],
|
|
286
|
+
["android", "Expand the notification, then tap Approve."]
|
|
287
|
+
]);
|
|
288
|
+
var EITHER_PHONE_ANSWER_STEP = "Press and hold the notification on iPhone, or expand it on Android, then tap Approve.";
|
|
289
|
+
var notificationAnswerStep = (appPlatforms) => {
|
|
290
|
+
const platforms = [...new Set(appPlatforms)];
|
|
291
|
+
const [onlyPlatform] = platforms;
|
|
292
|
+
if (onlyPlatform === void 0) return null;
|
|
293
|
+
if (platforms.length > 1) return EITHER_PHONE_ANSWER_STEP;
|
|
294
|
+
return NOTIFICATION_ANSWER_STEPS.get(onlyPlatform) ?? EITHER_PHONE_ANSWER_STEP;
|
|
295
|
+
};
|
|
296
|
+
var WAITING_FOR_TAP = "Waiting for you to tap the notification";
|
|
297
|
+
var WAITING_FOR_ANSWER = "Waiting for your answer";
|
|
298
|
+
var describeAnswerTestPrompt = (appPlatforms) => {
|
|
299
|
+
const step = notificationAnswerStep(appPlatforms);
|
|
300
|
+
return { step, waiting: step === null ? WAITING_FOR_TAP : WAITING_FOR_ANSWER };
|
|
301
|
+
};
|
|
302
|
+
var CHECK_THE_NOTIFICATION_OPENED = "Check the notification actually opened something you could tap, then run pushary doctor --roundtrip.";
|
|
303
|
+
var unansweredNextStep = (appPlatforms) => {
|
|
304
|
+
const step = notificationAnswerStep(appPlatforms);
|
|
305
|
+
return step === null ? CHECK_THE_NOTIFICATION_OPENED : `To send another one, run pushary doctor --roundtrip. ${step}`;
|
|
306
|
+
};
|
|
307
|
+
var describeRoundTripOutcome = (outcome, appPlatforms = []) => {
|
|
308
|
+
switch (outcome.kind) {
|
|
309
|
+
case "answered":
|
|
310
|
+
return {
|
|
311
|
+
ok: true,
|
|
312
|
+
message: `Answered "${outcome.value}" in ${(outcome.latencyMs / 1e3).toFixed(1)}s. ${describeAnswerSource(outcome.answerSource)}`,
|
|
313
|
+
next: []
|
|
314
|
+
};
|
|
315
|
+
case "unanswered":
|
|
316
|
+
return {
|
|
317
|
+
ok: false,
|
|
318
|
+
message: "The question was sent and nothing came back.",
|
|
319
|
+
next: [
|
|
320
|
+
"A push that arrives and cannot be answered is the most common way this breaks, so this is worth resolving now.",
|
|
321
|
+
unansweredNextStep(appPlatforms)
|
|
322
|
+
]
|
|
323
|
+
};
|
|
324
|
+
case "notify-only":
|
|
325
|
+
return {
|
|
326
|
+
ok: true,
|
|
327
|
+
message: "Sent. This site is in notify-only mode, so questions never wait for an answer.",
|
|
328
|
+
next: ["Switch with pushary mode push_first if you want approvals to hold for your phone."]
|
|
329
|
+
};
|
|
330
|
+
case "no-recipients":
|
|
331
|
+
return {
|
|
332
|
+
ok: false,
|
|
333
|
+
message: "Nothing to ask. No phone or browser is connected to this site.",
|
|
334
|
+
next: [
|
|
335
|
+
"Run pushary pair to pair your phone.",
|
|
336
|
+
"Or pushary pair --app if you already have the Pushary app."
|
|
337
|
+
]
|
|
338
|
+
};
|
|
339
|
+
case "error":
|
|
340
|
+
return {
|
|
341
|
+
ok: false,
|
|
342
|
+
message: `Could not complete the round trip (${outcome.detail}).`,
|
|
343
|
+
next: ["Agents are configured. Run pushary doctor --roundtrip once the connection is back."]
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
var describeRoundTrip = (outcome, appPlatforms = []) => {
|
|
348
|
+
const report = describeRoundTripOutcome(outcome, appPlatforms);
|
|
349
|
+
return { ...report, next: [...report.next, "Agent hook activation remains unverified. Restart your agent and check one real approval."] };
|
|
350
|
+
};
|
|
351
|
+
var roundTripEvidence = (outcome) => ({
|
|
352
|
+
kind: outcome?.kind ?? "skipped",
|
|
353
|
+
...outcome?.kind === "answered" ? {
|
|
354
|
+
correlationId: outcome.correlationId ?? null,
|
|
355
|
+
answerSource: outcome.answerSource ?? null,
|
|
356
|
+
value: outcome.value,
|
|
357
|
+
latencyMs: outcome.latencyMs
|
|
358
|
+
} : {},
|
|
359
|
+
hookActivation: "unverified"
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
export {
|
|
363
|
+
reachVerdict,
|
|
364
|
+
reachesYou,
|
|
365
|
+
describeReach,
|
|
366
|
+
describeAppRepair,
|
|
367
|
+
describeJustPairedRepair,
|
|
368
|
+
SETUP_AGENT_NAME,
|
|
369
|
+
ownAppPlatforms,
|
|
370
|
+
verifyDelivery,
|
|
371
|
+
describeVerifyOutcome,
|
|
372
|
+
verifyRoundTrip,
|
|
373
|
+
notificationAnswerStep,
|
|
374
|
+
describeAnswerTestPrompt,
|
|
375
|
+
describeRoundTripOutcome,
|
|
376
|
+
describeRoundTrip,
|
|
377
|
+
roundTripEvidence
|
|
378
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SubscriptionRequiredError,
|
|
3
3
|
callMcpTool
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ZL3UR6M5.js";
|
|
5
5
|
import {
|
|
6
6
|
CLIENT_REPORT_DISABLE_ENV,
|
|
7
7
|
isDisabledByEnv
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
installNetworkDefaults,
|
|
11
11
|
isNetworkFailure
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-5DZHKNBU.js";
|
|
13
13
|
import {
|
|
14
14
|
clientReportClaims
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-MYBCXDIL.js";
|
|
16
16
|
import {
|
|
17
17
|
getApiKey,
|
|
18
18
|
getBaseUrl
|