@pushary/agent-hooks 0.59.0 → 0.61.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 +113 -0
- package/README.md +52 -9
- package/dist/bin/pushary-claude.js +3 -3
- package/dist/bin/pushary-clean.js +26 -11
- package/dist/bin/pushary-codex-hook.js +3 -3
- package/dist/bin/pushary-codex.js +3 -3
- package/dist/bin/pushary-connect.d.ts +1 -0
- package/dist/bin/pushary-connect.js +92 -0
- package/dist/bin/pushary-daemon.js +7 -2
- package/dist/bin/pushary-doctor.js +142 -46
- package/dist/bin/pushary-gemini-hook.js +3 -3
- package/dist/bin/pushary-hook.js +9 -4
- package/dist/bin/pushary-login.d.ts +1 -0
- package/dist/bin/pushary-login.js +156 -0
- package/dist/bin/pushary-logout.d.ts +1 -0
- package/dist/bin/pushary-logout.js +102 -0
- package/dist/bin/pushary-mode.js +24 -13
- package/dist/bin/pushary-notification-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 +858 -547
- package/dist/bin/pushary-stats.js +6 -1
- package/dist/bin/pushary-status.d.ts +1 -0
- package/dist/bin/pushary-status.js +206 -0
- package/dist/bin/pushary-stop-hook.js +3 -3
- package/dist/bin/pushary-stopfailure-hook.js +3 -3
- package/dist/bin/pushary-suggestions.js +10 -5
- package/dist/bin/pushary-upgrade.js +11 -6
- package/dist/bin/pushary-wait.js +21 -12
- package/dist/bin/pushary.js +42 -60
- package/dist/{chunk-NKXSILEW.js → chunk-2UMNXADU.js} +18 -2
- package/dist/chunk-3EGEA4KH.js +44 -0
- package/dist/chunk-7QLSKOSU.js +19 -0
- package/dist/chunk-B26DNXCA.js +235 -0
- package/dist/chunk-GX64YGU3.js +544 -0
- package/dist/{chunk-BE5X3WXL.js → chunk-HI4AGGE6.js} +2 -2
- package/dist/{chunk-DWED7BS3.js → chunk-HNTKTK5B.js} +1 -1
- package/dist/chunk-HUJQSP4F.js +18 -0
- package/dist/{chunk-J7JWI3KU.js → chunk-MUEW424A.js} +19 -1
- package/dist/chunk-N4DA4CJB.js +57 -0
- package/dist/chunk-QHOVJXOT.js +255 -0
- package/dist/chunk-R6C4USIV.js +44 -0
- package/dist/{chunk-BVAWO6RE.js → chunk-S4TFBJ5O.js} +8 -0
- package/dist/chunk-SML23YOT.js +216 -0
- package/dist/chunk-TX7KBKT7.js +79 -0
- package/dist/chunk-UKNAAVEE.js +217 -0
- package/dist/{chunk-WNRYRN2R.js → chunk-VFBYRR2N.js} +2 -2
- package/dist/src/index.js +4 -4
- package/package.json +11 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.61.0
|
|
4
|
+
|
|
5
|
+
The largest release since the CLI shipped. Setup no longer asks you to paste an
|
|
6
|
+
API key, the key is checked against the server before anything is written to your
|
|
7
|
+
machine, and commands exit with codes that mean something.
|
|
8
|
+
|
|
9
|
+
### Read this first: exit codes changed
|
|
10
|
+
|
|
11
|
+
Commands that used to print a failure and exit `0` now exit non-zero. If you run
|
|
12
|
+
any of these in CI or chained behind `&&`, this is the part that affects you.
|
|
13
|
+
|
|
14
|
+
| Command | Was | Now |
|
|
15
|
+
| --- | --- | --- |
|
|
16
|
+
| any unknown command or `pushary` typo | `0`, printed help | `2` |
|
|
17
|
+
| `doctor` with a failing check | `0` | `5` |
|
|
18
|
+
| `setup` with a revoked key | `0` | `4` |
|
|
19
|
+
| `setup` with an expired or locked plan | `0` | `5` |
|
|
20
|
+
| `mode`, `wait` with a rejected key | `0` | non-zero |
|
|
21
|
+
| `status` with no key configured | did not exist | `3` |
|
|
22
|
+
|
|
23
|
+
The full ladder: `0` ok, `1` failed, `2` usage, `3` not configured,
|
|
24
|
+
`4` unauthenticated, `5` problems found, `6` no device, `7` input required,
|
|
25
|
+
`8` unreachable, `130` interrupted.
|
|
26
|
+
|
|
27
|
+
`pushary doctor && deploy` used to succeed against a machine doctor had just
|
|
28
|
+
declared broken. That is the change worth knowing about.
|
|
29
|
+
|
|
30
|
+
### Sign in instead of pasting a key
|
|
31
|
+
|
|
32
|
+
`pushary setup` opens a browser, shows you a code, and receives the key sealed to
|
|
33
|
+
a keypair generated on your machine. The key is never pasted, never shown in a
|
|
34
|
+
terminal, and never transits in a form the server could read.
|
|
35
|
+
|
|
36
|
+
- `pushary login` and `pushary logout` as standalone commands
|
|
37
|
+
- Pasting a key still works, as a fallback and via `--key`
|
|
38
|
+
- `--key-stdin` reads the key from stdin, so it stays out of your shell history
|
|
39
|
+
and out of the process list
|
|
40
|
+
|
|
41
|
+
### New commands
|
|
42
|
+
|
|
43
|
+
- `pushary status` reports what this machine is connected to, with `--json`
|
|
44
|
+
- `pushary login`, `pushary logout`, `pushary connect`
|
|
45
|
+
|
|
46
|
+
### Setup
|
|
47
|
+
|
|
48
|
+
- The key is verified against the server before a single file is written. A
|
|
49
|
+
revoked key or a locked plan stops the run instead of producing a config that
|
|
50
|
+
looks finished and never delivers.
|
|
51
|
+
- `--yes` runs setup with no prompts, for CI and images
|
|
52
|
+
- `--agents claude_code,codex,...` picks agents without asking
|
|
53
|
+
- `--dry-run` prints what it would do and touches nothing
|
|
54
|
+
- Agent detection is real, so an agent you do not have is reported as skipped
|
|
55
|
+
rather than counted as configured
|
|
56
|
+
- Ctrl-C in a trailing prompt no longer reports the whole run as failed
|
|
57
|
+
- A stale `PUSHARY_API_KEY` export in your shell profile is now replaced rather
|
|
58
|
+
than skipped. It used to win forever over a newly rotated key.
|
|
59
|
+
|
|
60
|
+
### Delivery is proved to your phone, not just to the workspace
|
|
61
|
+
|
|
62
|
+
Setup and doctor now check that an approval reaches **you**, not merely that
|
|
63
|
+
somebody in the workspace has a device. On a shared site where the only reachable
|
|
64
|
+
channel cannot be attributed to you, that is said plainly rather than reported as
|
|
65
|
+
success.
|
|
66
|
+
|
|
67
|
+
### Diagnostics
|
|
68
|
+
|
|
69
|
+
- `pushary doctor --json` for one machine-readable envelope
|
|
70
|
+
- `pushary doctor --roundtrip` sends a real approval and waits for the tap. It
|
|
71
|
+
works without a TTY, where the old confirm prompt could not run at all.
|
|
72
|
+
- `pushary doctor --no-push` for a check that stays silent
|
|
73
|
+
- doctor reads the same key the hooks will actually use, honoring
|
|
74
|
+
`PUSHARY_CONFIG_FILE`, and reports a Claude or Cursor config holding a
|
|
75
|
+
different key
|
|
76
|
+
|
|
77
|
+
### Correctness
|
|
78
|
+
|
|
79
|
+
- `--help` and `--version` print and exit instead of running the command.
|
|
80
|
+
`pushary daemon --help` used to start a daemon; `pushary hook --help` used to
|
|
81
|
+
block forever on stdin.
|
|
82
|
+
- Unknown flags are rejected on the commands that parse them, instead of being
|
|
83
|
+
coerced into a plausible wrong value. `--connect` with an unrecognized mode used
|
|
84
|
+
to silently mean `web`.
|
|
85
|
+
- Every file this CLI writes is written atomically, so an interrupted setup can
|
|
86
|
+
no longer truncate a large `~/.claude.json`
|
|
87
|
+
- An unparseable agent config is left alone instead of being overwritten
|
|
88
|
+
- Files holding your key are created `0600`
|
|
89
|
+
- `CODEX_HOME` is honored when locating `config.toml`
|
|
90
|
+
- Hermes setup works on Windows
|
|
91
|
+
- The Cursor plugin is staged and verified before the old one is replaced
|
|
92
|
+
- `installGlobally` pins the exact running version instead of drifting to latest
|
|
93
|
+
- `pushary clean` removes only the export line it wrote, not every line in your
|
|
94
|
+
shell profile that mentions the key variable
|
|
95
|
+
- Requests honor `HTTP_PROXY` and `HTTPS_PROXY`
|
|
96
|
+
- Color honors `NO_COLOR` and `FORCE_COLOR`, and turns itself off when output is
|
|
97
|
+
not a terminal
|
|
98
|
+
- `--json` output is machine-readable on stdout, with human text on stderr, so a
|
|
99
|
+
pipe never receives a spinner
|
|
100
|
+
|
|
101
|
+
### Pairing
|
|
102
|
+
|
|
103
|
+
The pairing QR now points at a real web page, so scanning it on a phone without
|
|
104
|
+
the app installed lands on install instructions for that platform instead of a
|
|
105
|
+
dead custom-scheme link.
|
|
106
|
+
|
|
107
|
+
### Known gaps
|
|
108
|
+
|
|
109
|
+
- `status`, `clean`, `mode`, `wait`, `stats`, `suggestions` and `upgrade` still
|
|
110
|
+
ignore an unknown flag rather than exiting `2`. Unchanged from 0.60.0.
|
|
111
|
+
- `pushary upgrade` reapplies Claude settings only. Other agents need `setup`.
|
|
112
|
+
- Codex hook trust still uses a fixed version ceiling, so a newer Codex is sent
|
|
113
|
+
to the manual `/hooks` step.
|
package/README.md
CHANGED
|
@@ -58,17 +58,59 @@ Any other MCP client can use notify and ask by pointing at the Pushary MCP endpo
|
|
|
58
58
|
|
|
59
59
|
## Commands
|
|
60
60
|
|
|
61
|
+
<!-- Managed: every command below is declared in src/cli/commands.ts, and a test
|
|
62
|
+
asserts this list matches it. Do not edit one without the other. -->
|
|
63
|
+
|
|
61
64
|
```
|
|
62
|
-
setup
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
setup Configure Claude Code, Codex, Gemini CLI, Hermes, or Cursor with Pushary
|
|
66
|
+
claude Run Claude Code through Pushary, reachable from your phone even when idle
|
|
67
|
+
daemon Keep this machine reachable so your phone can START a new session
|
|
68
|
+
status One screen: which key is in force, whether the server accepts it, what can receive an approval
|
|
69
|
+
login Sign in from this terminal, no key to copy (--with-token to pipe one in)
|
|
70
|
+
logout Remove the key this machine stores, and say what it does not remove
|
|
71
|
+
connect Connect a phone without re-running setup (--app for the Pushary app)
|
|
72
|
+
doctor Verify your Pushary installation is working
|
|
73
|
+
clean Remove all Pushary configuration (--yes for non-interactive)
|
|
74
|
+
mode Switch approval mode (push_only, push_first, terminal_only)
|
|
75
|
+
wait Show or set the "wait for your phone" ladder (pushary wait 45)
|
|
76
|
+
stats Show the approval moments your agents hit while not connected
|
|
77
|
+
suggestions List rules mined from your own approvals
|
|
78
|
+
upgrade Update the globally installed hooks to the latest version
|
|
79
|
+
hook Run as a PreToolUse hook (reads stdin, writes stdout)
|
|
70
80
|
```
|
|
71
81
|
|
|
82
|
+
Run `pushary <command> --help` for one command's options.
|
|
83
|
+
|
|
84
|
+
### Non-interactive setup
|
|
85
|
+
|
|
86
|
+
`setup` asks which agents you use, so a run with no terminal on stdin needs to be
|
|
87
|
+
told instead. `--agents` or `--yes` does that; without either, setup takes the
|
|
88
|
+
defaults rather than waiting for a keypress that can never arrive.
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Everything detected on this machine, no prompts
|
|
92
|
+
npx @pushary/agent-hooks@latest setup --key-stdin --yes --skip-phone < key.txt
|
|
93
|
+
|
|
94
|
+
# Named agents only
|
|
95
|
+
npx @pushary/agent-hooks@latest setup --agents claude_code,codex --yes --skip-phone
|
|
96
|
+
|
|
97
|
+
# Store the key and configure nothing
|
|
98
|
+
npx @pushary/agent-hooks@latest setup --agents none --yes
|
|
99
|
+
|
|
100
|
+
# Show what would be written, change nothing
|
|
101
|
+
npx @pushary/agent-hooks@latest setup --agents auto --dry-run
|
|
102
|
+
|
|
103
|
+
# One machine-readable object on stdout; every human line goes to stderr
|
|
104
|
+
npx @pushary/agent-hooks@latest setup --agents auto --yes --json
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Prefer `--key-stdin` over `--key` in CI: `--key` puts the secret in argv, where
|
|
108
|
+
any other user on the box can read it out of `ps`.
|
|
109
|
+
|
|
110
|
+
Exit codes: `0` done, `2` bad usage, `3` no key resolvable, `4` the server
|
|
111
|
+
rejected the key, `5` finished with problems (an inactive plan, or an installer
|
|
112
|
+
that failed), `130` cancelled with Ctrl-C.
|
|
113
|
+
|
|
72
114
|
Examples:
|
|
73
115
|
|
|
74
116
|
```bash
|
|
@@ -106,7 +148,8 @@ If a policy cannot be fetched or a hook errors, the decision falls back to the a
|
|
|
106
148
|
- Website: [pushary.com](https://pushary.com/?from=npm)
|
|
107
149
|
- Docs: [pushary.com/docs](https://pushary.com/docs?from=npm)
|
|
108
150
|
- Sign up: [pushary.com/sign-up](https://pushary.com/sign-up?from=npm)
|
|
109
|
-
-
|
|
151
|
+
- Troubleshooting: [pushary.com/docs/agents/reference/troubleshooting](https://pushary.com/docs/agents/reference/troubleshooting?from=npm)
|
|
152
|
+
- Support and bug reports: [Discord](https://discord.gg/9v3VvUByrr) or [business@pushary.com](mailto:business@pushary.com)
|
|
110
153
|
|
|
111
154
|
## License
|
|
112
155
|
|
|
@@ -17,18 +17,18 @@ import {
|
|
|
17
17
|
reportEvent,
|
|
18
18
|
resolvePolicy,
|
|
19
19
|
waitForAnswer
|
|
20
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-VFBYRR2N.js";
|
|
21
21
|
import {
|
|
22
22
|
getMachineId
|
|
23
23
|
} from "../chunk-RN3NOEJF.js";
|
|
24
|
-
import "../chunk-
|
|
24
|
+
import "../chunk-HNTKTK5B.js";
|
|
25
25
|
import {
|
|
26
26
|
redactSecrets
|
|
27
27
|
} from "../chunk-DQAN3JQP.js";
|
|
28
28
|
import {
|
|
29
29
|
getApiKey,
|
|
30
30
|
getBaseUrl
|
|
31
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-2UMNXADU.js";
|
|
32
32
|
|
|
33
33
|
// src/wrapper/claudeBinary.ts
|
|
34
34
|
import { statSync } from "fs";
|
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
removeClaudeMcpServers,
|
|
4
|
+
removePusharySettings
|
|
5
|
+
} from "../chunk-CAJZAFVS.js";
|
|
5
6
|
import {
|
|
6
7
|
removeCodexHooks,
|
|
7
8
|
removeGeminiSettings,
|
|
8
9
|
removeInstructionBlock
|
|
9
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-S4TFBJ5O.js";
|
|
11
|
+
import {
|
|
12
|
+
removeClaudeAlias
|
|
13
|
+
} from "../chunk-BC3VCZ3E.js";
|
|
10
14
|
import {
|
|
11
15
|
execNpm
|
|
12
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-MUEW424A.js";
|
|
13
17
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
exitOnHelpFlag
|
|
19
|
+
} from "../chunk-HUJQSP4F.js";
|
|
20
|
+
import "../chunk-SML23YOT.js";
|
|
17
21
|
import "../chunk-DQAN3JQP.js";
|
|
18
22
|
|
|
19
23
|
// bin/pushary-clean.ts
|
|
20
|
-
import { existsSync, readFileSync, writeFileSync, rmSync, readdirSync } from "fs";
|
|
24
|
+
import { existsSync, readFileSync, writeFileSync, copyFileSync, rmSync, readdirSync } from "fs";
|
|
21
25
|
import { join } from "path";
|
|
22
26
|
import { homedir, tmpdir } from "os";
|
|
23
27
|
import { execSync } from "child_process";
|
|
24
28
|
import { confirm } from "@inquirer/prompts";
|
|
25
29
|
import { parse as parseTOML, stringify as stringifyTOML } from "smol-toml";
|
|
30
|
+
exitOnHelpFlag("clean");
|
|
26
31
|
var dim = (s) => `\x1B[2m${s}\x1B[0m`;
|
|
27
32
|
var bold = (s) => `\x1B[1m${s}\x1B[0m`;
|
|
28
33
|
var green = (s) => `\x1B[32m${s}\x1B[0m`;
|
|
@@ -236,9 +241,19 @@ var main = async () => {
|
|
|
236
241
|
try {
|
|
237
242
|
const content = readFileSync(shellFile, "utf-8");
|
|
238
243
|
if (content.includes("PUSHARY_API_KEY")) {
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
244
|
+
const isOurExport = (line) => /^\s*export\s+PUSHARY_API_KEY=['"]?pk_[A-Za-z0-9]+\.[A-Za-z0-9]+['"]?\s*$/.test(line);
|
|
245
|
+
const lines = content.split("\n");
|
|
246
|
+
const declined = lines.filter((l) => l.includes("PUSHARY_API_KEY") && !isOurExport(l));
|
|
247
|
+
const cleaned = lines.filter((l) => !isOurExport(l)).join("\n");
|
|
248
|
+
if (cleaned !== content) {
|
|
249
|
+
const backup = `${shellFile}.pushary-backup-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`;
|
|
250
|
+
copyFileSync(shellFile, backup);
|
|
251
|
+
writeFileSync(shellFile, cleaned, "utf-8");
|
|
252
|
+
console.log(` ${check} ${shellFile.split("/").pop()} ${dim(`(removed the export, backup at ${backup})`)}`);
|
|
253
|
+
}
|
|
254
|
+
for (const line of declined) {
|
|
255
|
+
console.log(` ${skip} ${shellFile.split("/").pop()} ${dim(`left a line referencing PUSHARY_API_KEY: ${line.trim()}`)}`);
|
|
256
|
+
}
|
|
242
257
|
}
|
|
243
258
|
} catch {
|
|
244
259
|
}
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
toCodexWire,
|
|
32
32
|
toPolicyLookup,
|
|
33
33
|
waitForAnswer
|
|
34
|
-
} from "../chunk-
|
|
34
|
+
} from "../chunk-VFBYRR2N.js";
|
|
35
35
|
import {
|
|
36
36
|
getMachineId
|
|
37
37
|
} from "../chunk-RN3NOEJF.js";
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
isGatingMoment,
|
|
40
40
|
recordKeylessMoment
|
|
41
41
|
} from "../chunk-WLGEY4UX.js";
|
|
42
|
-
import "../chunk-
|
|
42
|
+
import "../chunk-HNTKTK5B.js";
|
|
43
43
|
import {
|
|
44
44
|
DECISION_LINE_MAX,
|
|
45
45
|
effectiveWaitSeconds,
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
} from "../chunk-DQAN3JQP.js";
|
|
49
49
|
import {
|
|
50
50
|
getApiKey
|
|
51
|
-
} from "../chunk-
|
|
51
|
+
} from "../chunk-2UMNXADU.js";
|
|
52
52
|
|
|
53
53
|
// bin/pushary-codex-hook.ts
|
|
54
54
|
import { basename, join } from "path";
|
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
askUser,
|
|
4
4
|
reportEvent,
|
|
5
5
|
waitForAnswer
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-VFBYRR2N.js";
|
|
7
7
|
import {
|
|
8
8
|
getMachineId
|
|
9
9
|
} from "../chunk-RN3NOEJF.js";
|
|
10
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-HNTKTK5B.js";
|
|
11
11
|
import "../chunk-DQAN3JQP.js";
|
|
12
12
|
import {
|
|
13
13
|
getApiKey
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-2UMNXADU.js";
|
|
15
15
|
|
|
16
16
|
// bin/pushary-codex.ts
|
|
17
17
|
import { basename } from "path";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
printKeyCheck
|
|
4
|
+
} from "../chunk-R6C4USIV.js";
|
|
5
|
+
import {
|
|
6
|
+
confirmAppConnection,
|
|
7
|
+
connectDevice,
|
|
8
|
+
printConnectInstructions
|
|
9
|
+
} from "../chunk-GX64YGU3.js";
|
|
10
|
+
import "../chunk-3EGEA4KH.js";
|
|
11
|
+
import {
|
|
12
|
+
parseFlags
|
|
13
|
+
} from "../chunk-N4DA4CJB.js";
|
|
14
|
+
import {
|
|
15
|
+
readKeySource
|
|
16
|
+
} from "../chunk-B26DNXCA.js";
|
|
17
|
+
import {
|
|
18
|
+
checkApiKey
|
|
19
|
+
} from "../chunk-UKNAAVEE.js";
|
|
20
|
+
import {
|
|
21
|
+
createIo
|
|
22
|
+
} from "../chunk-TX7KBKT7.js";
|
|
23
|
+
import {
|
|
24
|
+
UsageError
|
|
25
|
+
} from "../chunk-7QLSKOSU.js";
|
|
26
|
+
import "../chunk-BC3VCZ3E.js";
|
|
27
|
+
import {
|
|
28
|
+
exitOnHelpFlag
|
|
29
|
+
} from "../chunk-HUJQSP4F.js";
|
|
30
|
+
import {
|
|
31
|
+
EXIT
|
|
32
|
+
} from "../chunk-SML23YOT.js";
|
|
33
|
+
import "../chunk-HNTKTK5B.js";
|
|
34
|
+
import "../chunk-DQAN3JQP.js";
|
|
35
|
+
import "../chunk-2UMNXADU.js";
|
|
36
|
+
|
|
37
|
+
// bin/pushary-connect.ts
|
|
38
|
+
exitOnHelpFlag("connect");
|
|
39
|
+
var parseConnectOptions = (argv) => {
|
|
40
|
+
const flags = parseFlags(argv, { bools: ["app", "browser", "help", "h"], values: [] });
|
|
41
|
+
if (flags.command !== void 0 && flags.command !== "connect") {
|
|
42
|
+
throw new UsageError(`connect takes no positional arguments (got ${flags.command})`);
|
|
43
|
+
}
|
|
44
|
+
if (flags.bools.has("app") && flags.bools.has("browser")) {
|
|
45
|
+
throw new UsageError("pass either --app or --browser, not both");
|
|
46
|
+
}
|
|
47
|
+
return { mode: flags.bools.has("app") ? "app" : "browser" };
|
|
48
|
+
};
|
|
49
|
+
var options;
|
|
50
|
+
try {
|
|
51
|
+
options = parseConnectOptions(process.argv.slice(2));
|
|
52
|
+
} catch (err) {
|
|
53
|
+
process.stderr.write(` ! ${err instanceof Error ? err.message : String(err)}
|
|
54
|
+
`);
|
|
55
|
+
process.stderr.write(" Run `pushary connect --help` for the full list.\n");
|
|
56
|
+
process.exit(EXIT.USAGE);
|
|
57
|
+
}
|
|
58
|
+
var { bold, dim, cyan, yellow } = createIo();
|
|
59
|
+
var main = async () => {
|
|
60
|
+
const source = readKeySource();
|
|
61
|
+
if (!source.key) {
|
|
62
|
+
console.log();
|
|
63
|
+
console.log(` ${yellow("!")} No API key on this machine, so there is no site to connect a phone to.`);
|
|
64
|
+
console.log(` ${dim("Run")} ${cyan("pushary setup")} ${dim("first.")}`);
|
|
65
|
+
console.log();
|
|
66
|
+
process.exit(EXIT.NOT_CONFIGURED);
|
|
67
|
+
}
|
|
68
|
+
console.log();
|
|
69
|
+
console.log(` ${bold("Pushary")} ${dim("connect a phone")}`);
|
|
70
|
+
console.log();
|
|
71
|
+
const keyCheck = await checkApiKey(source.key);
|
|
72
|
+
if (keyCheck.kind !== "ok") {
|
|
73
|
+
const report = printKeyCheck(keyCheck);
|
|
74
|
+
if (keyCheck.kind !== "unreachable") process.exit(report.exitCode);
|
|
75
|
+
console.log();
|
|
76
|
+
}
|
|
77
|
+
const result = options.mode === "app" ? await confirmAppConnection(source.key) : process.stdout.isTTY ? await connectDevice(source.key, { showCapabilities: true }) : await printConnectInstructions(source.key);
|
|
78
|
+
console.log();
|
|
79
|
+
if (result.reachesYou) {
|
|
80
|
+
console.log(` ${dim("Your phone can receive approvals. Try")} ${cyan("pushary doctor --roundtrip")} ${dim("to answer one.")}`);
|
|
81
|
+
console.log();
|
|
82
|
+
process.exit(EXIT.OK);
|
|
83
|
+
}
|
|
84
|
+
console.log(` ${dim("No device of yours can answer yet. Run")} ${cyan("pushary connect")} ${dim("again when you are ready.")}`);
|
|
85
|
+
console.log();
|
|
86
|
+
process.exit(EXIT.NO_DEVICE);
|
|
87
|
+
};
|
|
88
|
+
main().catch((err) => {
|
|
89
|
+
process.stderr.write(` ! connect failed: ${err instanceof Error ? err.message : String(err)}
|
|
90
|
+
`);
|
|
91
|
+
process.exit(EXIT.FAILED);
|
|
92
|
+
});
|
|
@@ -4,14 +4,18 @@ import {
|
|
|
4
4
|
} from "../chunk-XHKBHWLX.js";
|
|
5
5
|
import {
|
|
6
6
|
resolveGlobalBinary
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-MUEW424A.js";
|
|
8
|
+
import {
|
|
9
|
+
exitOnHelpFlag
|
|
10
|
+
} from "../chunk-HUJQSP4F.js";
|
|
11
|
+
import "../chunk-SML23YOT.js";
|
|
8
12
|
import {
|
|
9
13
|
getMachineId
|
|
10
14
|
} from "../chunk-RN3NOEJF.js";
|
|
11
15
|
import {
|
|
12
16
|
getApiKey,
|
|
13
17
|
getBaseUrl
|
|
14
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-2UMNXADU.js";
|
|
15
19
|
|
|
16
20
|
// src/spawn-daemon.ts
|
|
17
21
|
import { spawn } from "child_process";
|
|
@@ -153,6 +157,7 @@ var runSpawnDaemon = async () => {
|
|
|
153
157
|
};
|
|
154
158
|
|
|
155
159
|
// bin/pushary-daemon.ts
|
|
160
|
+
exitOnHelpFlag("daemon");
|
|
156
161
|
runSpawnDaemon().then((code) => process.exit(code)).catch((err) => {
|
|
157
162
|
process.stderr.write(
|
|
158
163
|
`[pushary] daemon error: ${err instanceof Error ? err.message : String(err)}
|