@pushary/agent-hooks 0.62.1 → 0.62.3
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 +66 -0
- package/dist/bin/pushary-claude.js +5 -2
- package/dist/bin/pushary-clean.js +3 -2
- package/dist/bin/pushary-codex-hook.js +5 -2
- package/dist/bin/pushary-codex.js +5 -2
- package/dist/bin/pushary-connect.js +14 -12
- package/dist/bin/pushary-daemon.js +5 -4
- package/dist/bin/pushary-doctor.js +18 -13
- package/dist/bin/pushary-gemini-hook.js +5 -2
- package/dist/bin/pushary-hook.js +8 -5
- package/dist/bin/pushary-login.js +13 -10
- package/dist/bin/pushary-logout.js +9 -8
- package/dist/bin/pushary-mode.js +29 -6
- package/dist/bin/pushary-notification-hook.js +5 -2
- package/dist/bin/pushary-permission-denied-hook.js +6 -3
- package/dist/bin/pushary-permission-hook.js +6 -3
- package/dist/bin/pushary-post-hook.js +5 -2
- package/dist/bin/pushary-prompt-hook.js +5 -2
- package/dist/bin/pushary-session-end-hook.js +5 -2
- package/dist/bin/pushary-session-start-hook.js +5 -2
- package/dist/bin/pushary-setup.js +33 -20
- package/dist/bin/pushary-stats.js +3 -2
- package/dist/bin/pushary-status.js +20 -7
- package/dist/bin/pushary-stop-hook.js +5 -2
- package/dist/bin/pushary-stopfailure-hook.js +5 -2
- package/dist/bin/pushary-suggestions.js +27 -2
- package/dist/bin/pushary-upgrade.js +6 -12
- package/dist/bin/pushary-wait.js +29 -6
- package/dist/bin/pushary.js +9 -2
- package/dist/{chunk-HIIBSYFJ.js → chunk-5ZDYDU2Q.js} +5 -1
- package/dist/{chunk-IIZZYUWK.js → chunk-674M3JQF.js} +4 -2
- package/dist/{chunk-HNTKTK5B.js → chunk-BSZYIAZL.js} +4 -0
- package/dist/{chunk-YJ7YZRVV.js → chunk-G4TARJAY.js} +8 -54
- package/dist/{chunk-N4DA4CJB.js → chunk-GMXKITVA.js} +13 -0
- package/dist/{chunk-SP7OZXCQ.js → chunk-KVUBLB6K.js} +9 -13
- package/dist/chunk-KZERVKTD.js +16 -0
- package/dist/{chunk-3O27ZSRE.js → chunk-NGZMVCXN.js} +1 -1
- package/dist/chunk-SAF6HGAA.js +57 -0
- package/dist/{chunk-5SO3CEGJ.js → chunk-SDXF5I46.js} +1 -1
- package/dist/{chunk-ONVEYEVR.js → chunk-SR52774M.js} +2 -2
- package/dist/{chunk-QHOVJXOT.js → chunk-Z3Z4VK5F.js} +2 -1
- package/dist/src/index.js +6 -3
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
runBrowserLogin
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-Z3Z4VK5F.js";
|
|
5
5
|
import {
|
|
6
6
|
addClaudeMcpServer,
|
|
7
7
|
addPusharyHooks,
|
|
@@ -35,14 +35,13 @@ import {
|
|
|
35
35
|
connectViaAppPairing,
|
|
36
36
|
printConnectInstructions,
|
|
37
37
|
setHumanStream
|
|
38
|
-
} from "../chunk-
|
|
38
|
+
} from "../chunk-NGZMVCXN.js";
|
|
39
39
|
import "../chunk-3EGEA4KH.js";
|
|
40
|
-
import {
|
|
41
|
-
parseFlags
|
|
42
|
-
} from "../chunk-N4DA4CJB.js";
|
|
43
40
|
import {
|
|
44
41
|
KEY_FILE_MODE,
|
|
45
42
|
exportLine,
|
|
43
|
+
keyPrefix,
|
|
44
|
+
readKeySource,
|
|
46
45
|
writeKey
|
|
47
46
|
} from "../chunk-COC6NPWG.js";
|
|
48
47
|
import {
|
|
@@ -54,10 +53,10 @@ import {
|
|
|
54
53
|
import {
|
|
55
54
|
checkApiKey,
|
|
56
55
|
describeKeyCheck
|
|
57
|
-
} from "../chunk-
|
|
56
|
+
} from "../chunk-G4TARJAY.js";
|
|
58
57
|
import {
|
|
59
|
-
|
|
60
|
-
} from "../chunk-
|
|
58
|
+
parseFlags
|
|
59
|
+
} from "../chunk-GMXKITVA.js";
|
|
61
60
|
import {
|
|
62
61
|
installClaudeAlias,
|
|
63
62
|
resolveShellRc
|
|
@@ -70,19 +69,26 @@ import {
|
|
|
70
69
|
resolveGlobalBinary
|
|
71
70
|
} from "../chunk-MUEW424A.js";
|
|
72
71
|
import {
|
|
73
|
-
EXIT,
|
|
74
72
|
getPackageVersion,
|
|
73
|
+
isNewerVersion,
|
|
75
74
|
renderCommandHelp
|
|
76
|
-
} from "../chunk-
|
|
75
|
+
} from "../chunk-KVUBLB6K.js";
|
|
77
76
|
import {
|
|
78
77
|
reportEvent
|
|
79
|
-
} from "../chunk-
|
|
80
|
-
import "../chunk-
|
|
78
|
+
} from "../chunk-5ZDYDU2Q.js";
|
|
79
|
+
import "../chunk-BSZYIAZL.js";
|
|
80
|
+
import "../chunk-SAF6HGAA.js";
|
|
81
|
+
import {
|
|
82
|
+
UsageError
|
|
83
|
+
} from "../chunk-7QLSKOSU.js";
|
|
81
84
|
import {
|
|
82
85
|
isValidApiKey
|
|
83
86
|
} from "../chunk-DQAN3JQP.js";
|
|
84
87
|
import "../chunk-RN3NOEJF.js";
|
|
85
88
|
import "../chunk-2UMNXADU.js";
|
|
89
|
+
import {
|
|
90
|
+
EXIT
|
|
91
|
+
} from "../chunk-KZERVKTD.js";
|
|
86
92
|
|
|
87
93
|
// bin/pushary-setup.ts
|
|
88
94
|
import { existsSync, readFileSync, writeFileSync, mkdirSync, cpSync, rmSync, renameSync } from "fs";
|
|
@@ -382,7 +388,7 @@ var checkForUpdates = async (current) => {
|
|
|
382
388
|
});
|
|
383
389
|
const data = await res.json();
|
|
384
390
|
const latest = data.version;
|
|
385
|
-
if (latest && latest
|
|
391
|
+
if (latest && isNewerVersion(latest, current)) {
|
|
386
392
|
console.log(` ${yellow("!")} Update available: ${dim(current)} \u2192 ${green(latest)}`);
|
|
387
393
|
console.log(` ${dim("Run:")} npx @pushary/agent-hooks@latest upgrade`);
|
|
388
394
|
console.log();
|
|
@@ -1062,8 +1068,15 @@ var main = async () => {
|
|
|
1062
1068
|
const flagKey = await readKeyFromStdin(options) ?? options.key ?? void 0;
|
|
1063
1069
|
const envKey = process.env.PUSHARY_API_KEY?.trim();
|
|
1064
1070
|
let trimmedKey;
|
|
1065
|
-
|
|
1071
|
+
let keyFromPairing = false;
|
|
1072
|
+
if (flagKey && isValidApiKey(flagKey)) {
|
|
1073
|
+
const masked = `${flagKey.slice(0, 8)}...${flagKey.slice(-4)}`;
|
|
1074
|
+
console.log(` ${check} Using API key: ${dim(masked)}`);
|
|
1075
|
+
console.log();
|
|
1076
|
+
trimmedKey = flagKey;
|
|
1077
|
+
} else if (connectMode === "app") {
|
|
1066
1078
|
console.log(` ${dim("Pairing with your Pushary app.")}`);
|
|
1079
|
+
const previous = readKeySource();
|
|
1067
1080
|
const paired = await connectViaAppPairing();
|
|
1068
1081
|
if (!paired) {
|
|
1069
1082
|
console.log();
|
|
@@ -1072,15 +1085,15 @@ var main = async () => {
|
|
|
1072
1085
|
process.exit(1);
|
|
1073
1086
|
}
|
|
1074
1087
|
trimmedKey = paired.apiKey;
|
|
1088
|
+
keyFromPairing = true;
|
|
1075
1089
|
if (paired.handle) {
|
|
1076
1090
|
console.log(` ${check} Connected to ${cyan("@" + paired.handle)}`);
|
|
1077
1091
|
}
|
|
1092
|
+
if (previous.key && previous.key !== trimmedKey) {
|
|
1093
|
+
console.log(` ${yellow("!")} The key this machine used before (${keyPrefix(previous.key)}) is still active.`);
|
|
1094
|
+
console.log(` ${dim("Revoke it at")} ${cyan("pushary.com/dashboard/agent/settings")} ${dim("if nothing else uses it.")}`);
|
|
1095
|
+
}
|
|
1078
1096
|
console.log();
|
|
1079
|
-
} else if (flagKey && isValidApiKey(flagKey)) {
|
|
1080
|
-
const masked = `${flagKey.slice(0, 8)}...${flagKey.slice(-4)}`;
|
|
1081
|
-
console.log(` ${check} Using API key: ${dim(masked)}`);
|
|
1082
|
-
console.log();
|
|
1083
|
-
trimmedKey = flagKey;
|
|
1084
1097
|
} else if (envKey && isValidApiKey(envKey)) {
|
|
1085
1098
|
const masked = `${envKey.slice(0, 8)}...${envKey.slice(-4)}`;
|
|
1086
1099
|
console.log(` ${check} Found API key in environment: ${dim(masked)}`);
|
|
@@ -1135,7 +1148,7 @@ var main = async () => {
|
|
|
1135
1148
|
`);
|
|
1136
1149
|
process.exit(EXIT.USAGE);
|
|
1137
1150
|
}
|
|
1138
|
-
const keyCheck =
|
|
1151
|
+
const keyCheck = keyFromPairing ? null : await verifyKeyOrExit(trimmedKey, options);
|
|
1139
1152
|
const agents = await resolveAgents(options);
|
|
1140
1153
|
if (options.dryRun) {
|
|
1141
1154
|
reportDryRun(trimmedKey, agents, keyCheck);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
exitOnHelpFlag
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-674M3JQF.js";
|
|
5
|
+
import "../chunk-KVUBLB6K.js";
|
|
6
6
|
import {
|
|
7
7
|
readLedgerSummary
|
|
8
8
|
} from "../chunk-WLGEY4UX.js";
|
|
@@ -10,6 +10,7 @@ import "../chunk-DQAN3JQP.js";
|
|
|
10
10
|
import {
|
|
11
11
|
getApiKey
|
|
12
12
|
} from "../chunk-2UMNXADU.js";
|
|
13
|
+
import "../chunk-KZERVKTD.js";
|
|
13
14
|
|
|
14
15
|
// bin/pushary-stats.ts
|
|
15
16
|
exitOnHelpFlag("stats");
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
describeReach,
|
|
4
4
|
fetchChannels,
|
|
5
5
|
reachVerdict
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-NGZMVCXN.js";
|
|
7
7
|
import "../chunk-3EGEA4KH.js";
|
|
8
8
|
import {
|
|
9
9
|
readKeySource
|
|
@@ -12,21 +12,28 @@ import "../chunk-6MTNS63X.js";
|
|
|
12
12
|
import {
|
|
13
13
|
checkApiKey,
|
|
14
14
|
describeKeyCheck
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-G4TARJAY.js";
|
|
16
16
|
import {
|
|
17
17
|
createIo
|
|
18
18
|
} from "../chunk-TX7KBKT7.js";
|
|
19
|
-
import
|
|
19
|
+
import {
|
|
20
|
+
rejectUnknownFlags
|
|
21
|
+
} from "../chunk-GMXKITVA.js";
|
|
20
22
|
import "../chunk-BC3VCZ3E.js";
|
|
21
23
|
import {
|
|
22
24
|
exitOnHelpFlag
|
|
23
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-674M3JQF.js";
|
|
26
|
+
import "../chunk-KVUBLB6K.js";
|
|
27
|
+
import "../chunk-BSZYIAZL.js";
|
|
28
|
+
import "../chunk-SAF6HGAA.js";
|
|
24
29
|
import {
|
|
25
|
-
|
|
26
|
-
} from "../chunk-
|
|
27
|
-
import "../chunk-HNTKTK5B.js";
|
|
30
|
+
UsageError
|
|
31
|
+
} from "../chunk-7QLSKOSU.js";
|
|
28
32
|
import "../chunk-DQAN3JQP.js";
|
|
29
33
|
import "../chunk-2UMNXADU.js";
|
|
34
|
+
import {
|
|
35
|
+
EXIT
|
|
36
|
+
} from "../chunk-KZERVKTD.js";
|
|
30
37
|
|
|
31
38
|
// src/status.ts
|
|
32
39
|
var keySourceLine = (source) => {
|
|
@@ -171,6 +178,7 @@ var statusJson = (facts, report) => ({
|
|
|
171
178
|
exitOnHelpFlag("status");
|
|
172
179
|
var { bold, dim, green, red, yellow } = createIo();
|
|
173
180
|
var args = process.argv.slice(2);
|
|
181
|
+
rejectUnknownFlags(args.filter((a) => a !== "status"), ["--json"]);
|
|
174
182
|
var json = args.includes("--json");
|
|
175
183
|
var main = async () => {
|
|
176
184
|
const source = readKeySource();
|
|
@@ -202,6 +210,11 @@ var main = async () => {
|
|
|
202
210
|
process.exit(report.exitCode);
|
|
203
211
|
};
|
|
204
212
|
main().catch((err) => {
|
|
213
|
+
if (err instanceof UsageError) {
|
|
214
|
+
process.stderr.write(` ! ${err.message}
|
|
215
|
+
`);
|
|
216
|
+
process.exit(EXIT.USAGE);
|
|
217
|
+
}
|
|
205
218
|
console.error(` ${yellow("!")} status failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
206
219
|
process.exit(1);
|
|
207
220
|
});
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
handleStop
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-5ZDYDU2Q.js";
|
|
5
|
+
import "../chunk-BSZYIAZL.js";
|
|
6
|
+
import "../chunk-SAF6HGAA.js";
|
|
7
|
+
import "../chunk-7QLSKOSU.js";
|
|
6
8
|
import "../chunk-DQAN3JQP.js";
|
|
7
9
|
import "../chunk-RN3NOEJF.js";
|
|
8
10
|
import "../chunk-2UMNXADU.js";
|
|
11
|
+
import "../chunk-KZERVKTD.js";
|
|
9
12
|
|
|
10
13
|
// bin/pushary-stop-hook.ts
|
|
11
14
|
var main = async () => {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
handleStopFailure
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-5ZDYDU2Q.js";
|
|
5
|
+
import "../chunk-BSZYIAZL.js";
|
|
6
|
+
import "../chunk-SAF6HGAA.js";
|
|
7
|
+
import "../chunk-7QLSKOSU.js";
|
|
6
8
|
import "../chunk-DQAN3JQP.js";
|
|
7
9
|
import "../chunk-RN3NOEJF.js";
|
|
8
10
|
import "../chunk-2UMNXADU.js";
|
|
11
|
+
import "../chunk-KZERVKTD.js";
|
|
9
12
|
|
|
10
13
|
// bin/pushary-stopfailure-hook.ts
|
|
11
14
|
var main = async () => {
|
|
@@ -2,14 +2,23 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createIo
|
|
4
4
|
} from "../chunk-TX7KBKT7.js";
|
|
5
|
+
import {
|
|
6
|
+
rejectUnknownFlags
|
|
7
|
+
} from "../chunk-GMXKITVA.js";
|
|
5
8
|
import {
|
|
6
9
|
exitOnHelpFlag
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
10
|
+
} from "../chunk-674M3JQF.js";
|
|
11
|
+
import "../chunk-KVUBLB6K.js";
|
|
12
|
+
import {
|
|
13
|
+
UsageError
|
|
14
|
+
} from "../chunk-7QLSKOSU.js";
|
|
9
15
|
import {
|
|
10
16
|
getApiKey,
|
|
11
17
|
getBaseUrl
|
|
12
18
|
} from "../chunk-2UMNXADU.js";
|
|
19
|
+
import {
|
|
20
|
+
EXIT
|
|
21
|
+
} from "../chunk-KZERVKTD.js";
|
|
13
22
|
|
|
14
23
|
// bin/pushary-suggestions.ts
|
|
15
24
|
exitOnHelpFlag("suggestions");
|
|
@@ -22,6 +31,17 @@ var errorMessage = async (res) => {
|
|
|
22
31
|
return `HTTP ${res.status}`;
|
|
23
32
|
}
|
|
24
33
|
};
|
|
34
|
+
{
|
|
35
|
+
const raw = process.argv.slice(2);
|
|
36
|
+
const positional = raw[0] === "suggestions" ? raw.slice(1) : raw;
|
|
37
|
+
try {
|
|
38
|
+
rejectUnknownFlags(positional, []);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
process.stderr.write(` ! ${err instanceof Error ? err.message : String(err)}
|
|
41
|
+
`);
|
|
42
|
+
process.exit(EXIT.USAGE);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
25
45
|
var main = async () => {
|
|
26
46
|
const apiKey = getApiKey();
|
|
27
47
|
const baseUrl = getBaseUrl();
|
|
@@ -69,6 +89,11 @@ var main = async () => {
|
|
|
69
89
|
}
|
|
70
90
|
};
|
|
71
91
|
main().catch((err) => {
|
|
92
|
+
if (err instanceof UsageError) {
|
|
93
|
+
process.stderr.write(` ! ${err.message}
|
|
94
|
+
`);
|
|
95
|
+
process.exit(EXIT.USAGE);
|
|
96
|
+
}
|
|
72
97
|
console.error(err instanceof Error ? err.message : String(err));
|
|
73
98
|
process.exit(1);
|
|
74
99
|
});
|
|
@@ -31,12 +31,15 @@ import {
|
|
|
31
31
|
} from "../chunk-MUEW424A.js";
|
|
32
32
|
import {
|
|
33
33
|
exitOnHelpFlag
|
|
34
|
-
} from "../chunk-
|
|
35
|
-
import
|
|
34
|
+
} from "../chunk-674M3JQF.js";
|
|
35
|
+
import {
|
|
36
|
+
isNewerVersion
|
|
37
|
+
} from "../chunk-KVUBLB6K.js";
|
|
36
38
|
import "../chunk-DQAN3JQP.js";
|
|
37
39
|
import {
|
|
38
40
|
getApiKey
|
|
39
41
|
} from "../chunk-2UMNXADU.js";
|
|
42
|
+
import "../chunk-KZERVKTD.js";
|
|
40
43
|
|
|
41
44
|
// bin/pushary-upgrade.ts
|
|
42
45
|
import { existsSync as existsSync2 } from "fs";
|
|
@@ -238,15 +241,6 @@ var fetchLatestVersion = async () => {
|
|
|
238
241
|
return void 0;
|
|
239
242
|
}
|
|
240
243
|
};
|
|
241
|
-
var isNewer = (a, b) => {
|
|
242
|
-
const pa = a.split(".").map((n) => parseInt(n, 10) || 0);
|
|
243
|
-
const pb = b.split(".").map((n) => parseInt(n, 10) || 0);
|
|
244
|
-
for (let i = 0; i < 3; i++) {
|
|
245
|
-
if ((pa[i] ?? 0) > (pb[i] ?? 0)) return true;
|
|
246
|
-
if ((pa[i] ?? 0) < (pb[i] ?? 0)) return false;
|
|
247
|
-
}
|
|
248
|
-
return false;
|
|
249
|
-
};
|
|
250
244
|
var main = async () => {
|
|
251
245
|
const installed = getInstalledVersion();
|
|
252
246
|
if (!installed) {
|
|
@@ -267,7 +261,7 @@ var main = async () => {
|
|
|
267
261
|
return;
|
|
268
262
|
}
|
|
269
263
|
const latest = await fetchLatestVersion();
|
|
270
|
-
if (latest && !
|
|
264
|
+
if (latest && !isNewerVersion(latest, installed)) {
|
|
271
265
|
console.log(`Already on the latest version (${installed}).`);
|
|
272
266
|
return;
|
|
273
267
|
}
|
package/dist/bin/pushary-wait.js
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
exitOnFailedResponse
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-SR52774M.js";
|
|
5
5
|
import {
|
|
6
6
|
describeWaitLadder
|
|
7
7
|
} from "../chunk-IIENZE2J.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-G4TARJAY.js";
|
|
9
9
|
import {
|
|
10
10
|
createIo
|
|
11
11
|
} from "../chunk-TX7KBKT7.js";
|
|
12
|
-
import
|
|
12
|
+
import {
|
|
13
|
+
rejectUnknownFlags
|
|
14
|
+
} from "../chunk-GMXKITVA.js";
|
|
13
15
|
import {
|
|
14
16
|
exitOnHelpFlag
|
|
15
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-674M3JQF.js";
|
|
18
|
+
import "../chunk-KVUBLB6K.js";
|
|
19
|
+
import "../chunk-SAF6HGAA.js";
|
|
16
20
|
import {
|
|
17
|
-
|
|
18
|
-
} from "../chunk-
|
|
21
|
+
UsageError
|
|
22
|
+
} from "../chunk-7QLSKOSU.js";
|
|
19
23
|
import "../chunk-DQAN3JQP.js";
|
|
20
24
|
import {
|
|
21
25
|
getApiKey,
|
|
22
26
|
getBaseUrl
|
|
23
27
|
} from "../chunk-2UMNXADU.js";
|
|
28
|
+
import {
|
|
29
|
+
EXIT
|
|
30
|
+
} from "../chunk-KZERVKTD.js";
|
|
24
31
|
|
|
25
32
|
// bin/pushary-wait.ts
|
|
26
33
|
exitOnHelpFlag("wait");
|
|
@@ -61,6 +68,17 @@ var setWindow = async (baseUrl, headers, seconds) => {
|
|
|
61
68
|
const data = await res.json();
|
|
62
69
|
return data.defaultPushFirstSeconds;
|
|
63
70
|
};
|
|
71
|
+
{
|
|
72
|
+
const raw = process.argv.slice(2);
|
|
73
|
+
const positional = raw[0] === "wait" ? raw.slice(1) : raw;
|
|
74
|
+
try {
|
|
75
|
+
rejectUnknownFlags(positional, []);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
process.stderr.write(` ! ${err instanceof Error ? err.message : String(err)}
|
|
78
|
+
`);
|
|
79
|
+
process.exit(EXIT.USAGE);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
64
82
|
var main = async () => {
|
|
65
83
|
const apiKey = getApiKey();
|
|
66
84
|
const baseUrl = getBaseUrl();
|
|
@@ -90,6 +108,11 @@ var main = async () => {
|
|
|
90
108
|
console.log(` ${green("\u2713")} Default push window set to ${cyan(`${value}s`)} ${dim("\u2014 ping your phone that long, then the terminal takes over")}`);
|
|
91
109
|
};
|
|
92
110
|
main().catch((err) => {
|
|
111
|
+
if (err instanceof UsageError) {
|
|
112
|
+
process.stderr.write(` ! ${err.message}
|
|
113
|
+
`);
|
|
114
|
+
process.exit(EXIT.USAGE);
|
|
115
|
+
}
|
|
93
116
|
console.error(` ${yellow("!")} ${err instanceof Error ? err.message : err}`);
|
|
94
117
|
process.exit(1);
|
|
95
118
|
});
|
package/dist/bin/pushary.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
COMMANDS,
|
|
4
|
-
EXIT,
|
|
5
4
|
getPackageVersion,
|
|
6
5
|
isCommandName,
|
|
7
6
|
renderHelp
|
|
8
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-KVUBLB6K.js";
|
|
8
|
+
import {
|
|
9
|
+
installProxyDispatcher
|
|
10
|
+
} from "../chunk-SAF6HGAA.js";
|
|
11
|
+
import "../chunk-7QLSKOSU.js";
|
|
12
|
+
import {
|
|
13
|
+
EXIT
|
|
14
|
+
} from "../chunk-KZERVKTD.js";
|
|
9
15
|
|
|
10
16
|
// bin/pushary.ts
|
|
11
17
|
var LOADERS = {
|
|
@@ -25,6 +31,7 @@ var LOADERS = {
|
|
|
25
31
|
upgrade: () => import("./pushary-upgrade.js"),
|
|
26
32
|
hook: () => import("./pushary-hook.js")
|
|
27
33
|
};
|
|
34
|
+
installProxyDispatcher();
|
|
28
35
|
var argv = process.argv.slice(2);
|
|
29
36
|
var command = argv[0] ?? "";
|
|
30
37
|
var wants = (...names) => argv.some((arg) => names.includes(arg));
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
callMcpTool,
|
|
3
3
|
withRetry
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BSZYIAZL.js";
|
|
5
|
+
import {
|
|
6
|
+
installProxyDispatcher
|
|
7
|
+
} from "./chunk-SAF6HGAA.js";
|
|
5
8
|
import {
|
|
6
9
|
ACTION_BODY_MAX,
|
|
7
10
|
DECISION_LINE_MAX,
|
|
@@ -204,6 +207,7 @@ var fetchModeState = async (apiKey, sessionId) => {
|
|
|
204
207
|
var fetchModeOverride = async (apiKey) => (await fetchModeState(apiKey)).mode;
|
|
205
208
|
|
|
206
209
|
// src/api.ts
|
|
210
|
+
installProxyDispatcher();
|
|
207
211
|
var askUser = async (apiKey, params, timeoutMs = 15e3) => {
|
|
208
212
|
const result = await callMcpTool(apiKey, "ask_user", { ...params, wait: false }, { maxRetries: 3, timeoutMs });
|
|
209
213
|
if (!isAskUserResponse(result)) throw new Error("Invalid ask_user response");
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
installProxyDispatcher
|
|
3
|
+
} from "./chunk-SAF6HGAA.js";
|
|
1
4
|
import {
|
|
2
5
|
getBaseUrl
|
|
3
6
|
} from "./chunk-2UMNXADU.js";
|
|
@@ -31,6 +34,7 @@ var withRetry = async (fn, options = {}) => {
|
|
|
31
34
|
};
|
|
32
35
|
|
|
33
36
|
// src/mcp-http.ts
|
|
37
|
+
installProxyDispatcher();
|
|
34
38
|
var parseSseJson = (body) => {
|
|
35
39
|
const messages = [];
|
|
36
40
|
for (const event of body.split(/\r?\n\r?\n/)) {
|
|
@@ -1,68 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
pusharyFetch
|
|
3
|
+
} from "./chunk-SAF6HGAA.js";
|
|
1
4
|
import {
|
|
2
5
|
NetworkError
|
|
3
6
|
} from "./chunk-7QLSKOSU.js";
|
|
4
|
-
import {
|
|
5
|
-
EXIT
|
|
6
|
-
} from "./chunk-SP7OZXCQ.js";
|
|
7
7
|
import {
|
|
8
8
|
isValidApiKey
|
|
9
9
|
} from "./chunk-DQAN3JQP.js";
|
|
10
10
|
import {
|
|
11
11
|
getBaseUrl
|
|
12
12
|
} from "./chunk-2UMNXADU.js";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var requireCjs = createRequire(import.meta.url);
|
|
17
|
-
var PROXY_VARS = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"];
|
|
18
|
-
var proxyFromEnv = () => {
|
|
19
|
-
for (const name of PROXY_VARS) {
|
|
20
|
-
const value = process.env[name]?.trim();
|
|
21
|
-
if (value) return value;
|
|
22
|
-
}
|
|
23
|
-
return void 0;
|
|
24
|
-
};
|
|
25
|
-
var installed = false;
|
|
26
|
-
var installProxyDispatcher = () => {
|
|
27
|
-
if (installed) return;
|
|
28
|
-
installed = true;
|
|
29
|
-
if (!proxyFromEnv()) return;
|
|
30
|
-
try {
|
|
31
|
-
const { EnvHttpProxyAgent, setGlobalDispatcher } = requireCjs("undici");
|
|
32
|
-
setGlobalDispatcher(new EnvHttpProxyAgent());
|
|
33
|
-
} catch {
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var isNetworkFailure = (err) => {
|
|
37
|
-
if (!(err instanceof Error)) return false;
|
|
38
|
-
const code = err.code;
|
|
39
|
-
if (code && ["ENOTFOUND", "ECONNREFUSED", "ECONNRESET", "ETIMEDOUT", "EAI_AGAIN", "EPROTO", "CERT_HAS_EXPIRED", "UNABLE_TO_VERIFY_LEAF_SIGNATURE"].includes(code)) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
return err.name === "AbortError" || err.name === "TimeoutError" || /fetch failed/i.test(err.message);
|
|
43
|
-
};
|
|
44
|
-
var DEFAULT_TIMEOUT_MS = 15e3;
|
|
45
|
-
var pusharyFetch = async (url, init = {}) => {
|
|
46
|
-
installProxyDispatcher();
|
|
47
|
-
const { timeoutMs = DEFAULT_TIMEOUT_MS, signal, ...rest } = init;
|
|
48
|
-
try {
|
|
49
|
-
return await fetch(url, {
|
|
50
|
-
...rest,
|
|
51
|
-
signal: signal ?? AbortSignal.timeout(timeoutMs)
|
|
52
|
-
});
|
|
53
|
-
} catch (err) {
|
|
54
|
-
if (isNetworkFailure(err)) {
|
|
55
|
-
const proxy = proxyFromEnv();
|
|
56
|
-
const via = proxy ? ` (via proxy ${proxy})` : "";
|
|
57
|
-
throw new NetworkError(`Could not reach ${new URL(url).host}${via}: ${err instanceof Error ? err.message : String(err)}`);
|
|
58
|
-
}
|
|
59
|
-
throw err;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
13
|
+
import {
|
|
14
|
+
EXIT
|
|
15
|
+
} from "./chunk-KZERVKTD.js";
|
|
62
16
|
|
|
63
17
|
// src/session.ts
|
|
64
18
|
var IDENTITY_PATH = "/api/v1/server/identity";
|
|
65
|
-
var
|
|
19
|
+
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
66
20
|
var SUBSCRIPTION_REQUIRED_CODE = "subscription_required";
|
|
67
21
|
var DEFAULT_UPGRADE_PATH = "/dashboard/settings?tab=billing";
|
|
68
22
|
var KEY_SCOPES = ["full_access", "connector", "bound"];
|
|
@@ -120,7 +74,7 @@ var checkApiKey = async (apiKey, options = {}) => {
|
|
|
120
74
|
if (!isValidApiKey(apiKey)) return { kind: "malformed" };
|
|
121
75
|
const baseUrl = options.baseUrl ?? getBaseUrl();
|
|
122
76
|
const fetchImpl = options.fetchImpl ?? pusharyFetch;
|
|
123
|
-
const timeoutMs = options.timeoutMs ??
|
|
77
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
124
78
|
let response;
|
|
125
79
|
try {
|
|
126
80
|
response = await fetchImpl(`${baseUrl.replace(/\/+$/, "")}${IDENTITY_PATH}`, {
|
|
@@ -9,6 +9,18 @@ var known = (spec, name) => {
|
|
|
9
9
|
if (spec.values.includes(name)) return "value";
|
|
10
10
|
return void 0;
|
|
11
11
|
};
|
|
12
|
+
var rejectUnknownFlags = (args, allowed) => {
|
|
13
|
+
for (const token of args) {
|
|
14
|
+
if (token === "--") break;
|
|
15
|
+
if (!token.startsWith("-")) continue;
|
|
16
|
+
const name = token.includes("=") ? token.slice(0, token.indexOf("=")) : token;
|
|
17
|
+
if (!allowed.includes(name)) {
|
|
18
|
+
throw new UsageError(
|
|
19
|
+
`Unknown flag: ${name}${allowed.length > 0 ? `. This command accepts ${allowed.join(", ")}` : ". This command takes no flags"}`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
12
24
|
var parseFlags = (argv, spec) => {
|
|
13
25
|
const bools = /* @__PURE__ */ new Set();
|
|
14
26
|
const values = /* @__PURE__ */ new Map();
|
|
@@ -53,5 +65,6 @@ var parseFlags = (argv, spec) => {
|
|
|
53
65
|
};
|
|
54
66
|
|
|
55
67
|
export {
|
|
68
|
+
rejectUnknownFlags,
|
|
56
69
|
parseFlags
|
|
57
70
|
};
|
|
@@ -200,18 +200,14 @@ var getPackageVersion = () => {
|
|
|
200
200
|
return "0.0.0";
|
|
201
201
|
}
|
|
202
202
|
};
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
PROBLEMS_FOUND: 5,
|
|
212
|
-
NO_DEVICE: 6,
|
|
213
|
-
INPUT_REQUIRED: 7,
|
|
214
|
-
UNREACHABLE: 8
|
|
203
|
+
var isNewerVersion = (candidate, current) => {
|
|
204
|
+
const a = candidate.split(".").map((part) => parseInt(part, 10) || 0);
|
|
205
|
+
const b = current.split(".").map((part) => parseInt(part, 10) || 0);
|
|
206
|
+
for (let i = 0; i < 3; i++) {
|
|
207
|
+
if ((a[i] ?? 0) > (b[i] ?? 0)) return true;
|
|
208
|
+
if ((a[i] ?? 0) < (b[i] ?? 0)) return false;
|
|
209
|
+
}
|
|
210
|
+
return false;
|
|
215
211
|
};
|
|
216
212
|
|
|
217
213
|
export {
|
|
@@ -220,5 +216,5 @@ export {
|
|
|
220
216
|
renderHelp,
|
|
221
217
|
renderCommandHelp,
|
|
222
218
|
getPackageVersion,
|
|
223
|
-
|
|
219
|
+
isNewerVersion
|
|
224
220
|
};
|