@pushary/agent-hooks 0.90.1 → 0.90.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/bin/pushary-bell.js +6 -61
  3. package/dist/bin/pushary-claude.js +5 -5
  4. package/dist/bin/pushary-clean.js +96 -13
  5. package/dist/bin/pushary-codex-bridge.js +3 -3
  6. package/dist/bin/pushary-codex-hook.js +3 -3
  7. package/dist/bin/pushary-codex.js +3 -3
  8. package/dist/bin/pushary-connect.js +2 -2
  9. package/dist/bin/pushary-daemon.js +9 -9
  10. package/dist/bin/pushary-disconnect.js +2 -2
  11. package/dist/bin/pushary-doctor.js +13 -13
  12. package/dist/bin/pushary-elicitation-hook.js +2 -2
  13. package/dist/bin/pushary-gemini-bridge.js +3 -3
  14. package/dist/bin/pushary-gemini-hook.js +3 -3
  15. package/dist/bin/pushary-hook.js +4 -4
  16. package/dist/bin/pushary-login.js +4 -4
  17. package/dist/bin/pushary-logout.js +1 -1
  18. package/dist/bin/pushary-mode.js +2 -2
  19. package/dist/bin/pushary-notification-hook.js +3 -3
  20. package/dist/bin/pushary-opencode-hook.js +3 -3
  21. package/dist/bin/pushary-permission-denied-hook.js +4 -4
  22. package/dist/bin/pushary-permission-hook.js +4 -4
  23. package/dist/bin/pushary-post-hook.js +3 -3
  24. package/dist/bin/pushary-prompt-hook.js +3 -3
  25. package/dist/bin/pushary-session-end-hook.js +3 -3
  26. package/dist/bin/pushary-session-start-hook.js +3 -3
  27. package/dist/bin/pushary-setup.js +104 -179
  28. package/dist/bin/pushary-status.js +4 -4
  29. package/dist/bin/pushary-stop-hook.js +3 -3
  30. package/dist/bin/pushary-stopfailure-hook.js +3 -3
  31. package/dist/bin/pushary-upgrade.js +8 -8
  32. package/dist/bin/pushary-wait.js +2 -2
  33. package/dist/{chunk-B6H2KAQC.js → chunk-4IEW4ZRF.js} +2 -2
  34. package/dist/chunk-ATUUQFDH.js +536 -0
  35. package/dist/{chunk-54ELC7D7.js → chunk-AWHCZOZO.js} +1 -1
  36. package/dist/{chunk-KUZWXPUS.js → chunk-BVNYTQ5I.js} +23 -0
  37. package/dist/{chunk-AJYV3VGU.js → chunk-BXTJVM7O.js} +2 -0
  38. package/dist/{chunk-FQL5E6NG.js → chunk-CRVJCKIN.js} +85 -2
  39. package/dist/chunk-DSTLA2TC.js +68 -0
  40. package/dist/{chunk-GL3FFM7A.js → chunk-ELHCIEMM.js} +1 -1
  41. package/dist/{chunk-Y6BWPERV.js → chunk-GQ5ZC2QY.js} +1 -1
  42. package/dist/chunk-GU3EJCVV.js +43 -0
  43. package/dist/{chunk-4LOPSGLP.js → chunk-TVZQMPB7.js} +1 -1
  44. package/dist/{chunk-BQBEH6TV.js → chunk-VAMBUKXH.js} +4 -4
  45. package/dist/{chunk-DZDI62LY.js → chunk-WGKC6PU2.js} +2 -2
  46. package/dist/{chunk-7TPQEWUZ.js → chunk-YTD6PJM7.js} +1 -1
  47. package/dist/{chunk-H2QZRQR2.js → chunk-YTDH3XCE.js} +1 -1
  48. package/dist/{chunk-F2ICEWZL.js → chunk-Z4XCN2HH.js} +2 -2
  49. package/dist/{chunk-DYP6SMOR.js → chunk-Z6RFZKY4.js} +1 -1
  50. package/dist/src/index.js +4 -4
  51. package/package.json +1 -1
  52. package/dist/chunk-AZPIQG4G.js +0 -274
  53. package/dist/chunk-S6LYP7QA.js +0 -127
@@ -4,7 +4,7 @@ import {
4
4
  codexConfigToml,
5
5
  cursorUserMcp,
6
6
  geminiSettings
7
- } from "../chunk-KUZWXPUS.js";
7
+ } from "../chunk-BVNYTQ5I.js";
8
8
  import {
9
9
  createIo
10
10
  } from "../chunk-5RUIFDTP.js";
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  exitOnFailedResponse
4
- } from "../chunk-DYP6SMOR.js";
5
- import "../chunk-AJYV3VGU.js";
4
+ } from "../chunk-Z6RFZKY4.js";
5
+ import "../chunk-BXTJVM7O.js";
6
6
  import {
7
7
  createIo
8
8
  } from "../chunk-5RUIFDTP.js";
@@ -4,11 +4,11 @@ import {
4
4
  } from "../chunk-6CUUA7HO.js";
5
5
  import {
6
6
  handleNotification
7
- } from "../chunk-4LOPSGLP.js";
7
+ } from "../chunk-TVZQMPB7.js";
8
8
  import "../chunk-F7OURW3C.js";
9
9
  import "../chunk-L4E2BIJ2.js";
10
- import "../chunk-54ELC7D7.js";
11
- import "../chunk-KUZWXPUS.js";
10
+ import "../chunk-AWHCZOZO.js";
11
+ import "../chunk-BVNYTQ5I.js";
12
12
  import "../chunk-BSZYIAZL.js";
13
13
  import "../chunk-SAF6HGAA.js";
14
14
  import "../chunk-7QLSKOSU.js";
@@ -19,7 +19,7 @@ import {
19
19
  policyRequestFor,
20
20
  readLastPrompt,
21
21
  repoKeyFor
22
- } from "../chunk-4LOPSGLP.js";
22
+ } from "../chunk-TVZQMPB7.js";
23
23
  import {
24
24
  DEFAULT_SESSION,
25
25
  askUser,
@@ -40,8 +40,8 @@ import {
40
40
  } from "../chunk-L4E2BIJ2.js";
41
41
  import {
42
42
  getMachineId
43
- } from "../chunk-54ELC7D7.js";
44
- import "../chunk-KUZWXPUS.js";
43
+ } from "../chunk-AWHCZOZO.js";
44
+ import "../chunk-BVNYTQ5I.js";
45
45
  import "../chunk-BSZYIAZL.js";
46
46
  import "../chunk-SAF6HGAA.js";
47
47
  import "../chunk-7QLSKOSU.js";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  handlePermissionDenied
4
- } from "../chunk-B6H2KAQC.js";
4
+ } from "../chunk-4IEW4ZRF.js";
5
5
  import "../chunk-2LAHXHBR.js";
6
6
  import "../chunk-I463AEG3.js";
7
7
  import "../chunk-VHWCVD42.js";
@@ -9,11 +9,11 @@ import {
9
9
  readHookInput
10
10
  } from "../chunk-6CUUA7HO.js";
11
11
  import "../chunk-YHG74UFF.js";
12
- import "../chunk-4LOPSGLP.js";
12
+ import "../chunk-TVZQMPB7.js";
13
13
  import "../chunk-F7OURW3C.js";
14
14
  import "../chunk-L4E2BIJ2.js";
15
- import "../chunk-54ELC7D7.js";
16
- import "../chunk-KUZWXPUS.js";
15
+ import "../chunk-AWHCZOZO.js";
16
+ import "../chunk-BVNYTQ5I.js";
17
17
  import "../chunk-BSZYIAZL.js";
18
18
  import "../chunk-SAF6HGAA.js";
19
19
  import "../chunk-7QLSKOSU.js";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  handlePermissionRequest
4
- } from "../chunk-B6H2KAQC.js";
4
+ } from "../chunk-4IEW4ZRF.js";
5
5
  import "../chunk-2LAHXHBR.js";
6
6
  import "../chunk-I463AEG3.js";
7
7
  import "../chunk-VHWCVD42.js";
@@ -9,11 +9,11 @@ import {
9
9
  readHookInput
10
10
  } from "../chunk-6CUUA7HO.js";
11
11
  import "../chunk-YHG74UFF.js";
12
- import "../chunk-4LOPSGLP.js";
12
+ import "../chunk-TVZQMPB7.js";
13
13
  import "../chunk-F7OURW3C.js";
14
14
  import "../chunk-L4E2BIJ2.js";
15
- import "../chunk-54ELC7D7.js";
16
- import "../chunk-KUZWXPUS.js";
15
+ import "../chunk-AWHCZOZO.js";
16
+ import "../chunk-BVNYTQ5I.js";
17
17
  import "../chunk-BSZYIAZL.js";
18
18
  import "../chunk-SAF6HGAA.js";
19
19
  import "../chunk-7QLSKOSU.js";
@@ -6,11 +6,11 @@ import {
6
6
  handleCompaction,
7
7
  handlePostToolUse,
8
8
  isCompactionEvent
9
- } from "../chunk-4LOPSGLP.js";
9
+ } from "../chunk-TVZQMPB7.js";
10
10
  import "../chunk-F7OURW3C.js";
11
11
  import "../chunk-L4E2BIJ2.js";
12
- import "../chunk-54ELC7D7.js";
13
- import "../chunk-KUZWXPUS.js";
12
+ import "../chunk-AWHCZOZO.js";
13
+ import "../chunk-BVNYTQ5I.js";
14
14
  import "../chunk-BSZYIAZL.js";
15
15
  import "../chunk-SAF6HGAA.js";
16
16
  import "../chunk-7QLSKOSU.js";
@@ -4,11 +4,11 @@ import {
4
4
  } from "../chunk-6CUUA7HO.js";
5
5
  import {
6
6
  handleUserPrompt
7
- } from "../chunk-4LOPSGLP.js";
7
+ } from "../chunk-TVZQMPB7.js";
8
8
  import "../chunk-F7OURW3C.js";
9
9
  import "../chunk-L4E2BIJ2.js";
10
- import "../chunk-54ELC7D7.js";
11
- import "../chunk-KUZWXPUS.js";
10
+ import "../chunk-AWHCZOZO.js";
11
+ import "../chunk-BVNYTQ5I.js";
12
12
  import "../chunk-BSZYIAZL.js";
13
13
  import "../chunk-SAF6HGAA.js";
14
14
  import "../chunk-7QLSKOSU.js";
@@ -4,11 +4,11 @@ import {
4
4
  } from "../chunk-6CUUA7HO.js";
5
5
  import {
6
6
  handleSessionEnd
7
- } from "../chunk-4LOPSGLP.js";
7
+ } from "../chunk-TVZQMPB7.js";
8
8
  import "../chunk-F7OURW3C.js";
9
9
  import "../chunk-L4E2BIJ2.js";
10
- import "../chunk-54ELC7D7.js";
11
- import "../chunk-KUZWXPUS.js";
10
+ import "../chunk-AWHCZOZO.js";
11
+ import "../chunk-BVNYTQ5I.js";
12
12
  import "../chunk-BSZYIAZL.js";
13
13
  import "../chunk-SAF6HGAA.js";
14
14
  import "../chunk-7QLSKOSU.js";
@@ -4,11 +4,11 @@ import {
4
4
  } from "../chunk-6CUUA7HO.js";
5
5
  import {
6
6
  handleSessionStart
7
- } from "../chunk-4LOPSGLP.js";
7
+ } from "../chunk-TVZQMPB7.js";
8
8
  import "../chunk-F7OURW3C.js";
9
9
  import "../chunk-L4E2BIJ2.js";
10
- import "../chunk-54ELC7D7.js";
11
- import "../chunk-KUZWXPUS.js";
10
+ import "../chunk-AWHCZOZO.js";
11
+ import "../chunk-BVNYTQ5I.js";
12
12
  import "../chunk-BSZYIAZL.js";
13
13
  import "../chunk-SAF6HGAA.js";
14
14
  import "../chunk-7QLSKOSU.js";
@@ -4,40 +4,52 @@ import {
4
4
  } from "../chunk-Z3Z4VK5F.js";
5
5
  import {
6
6
  detectClaudeVersion
7
- } from "../chunk-H2QZRQR2.js";
7
+ } from "../chunk-YTDH3XCE.js";
8
8
  import {
9
9
  describeVersionManagerPin,
10
- isBridgeLocator,
11
10
  versionManagerOf
12
- } from "../chunk-S6LYP7QA.js";
11
+ } from "../chunk-GU3EJCVV.js";
13
12
  import {
14
13
  waitForMachineReadiness
15
- } from "../chunk-7TPQEWUZ.js";
14
+ } from "../chunk-YTD6PJM7.js";
16
15
  import {
17
16
  HERMES_CONFIG_SCRIPT,
17
+ KEEP_HINT,
18
+ captureHookTakeover,
19
+ captureMcpServer,
20
+ describeAppOwnership,
21
+ describeHookOwnership,
18
22
  describeSetupSideEffects,
23
+ effectiveControlMode,
24
+ effectiveVerify,
25
+ hookOwnerOf,
19
26
  isHermesConfigReceipt,
27
+ mcpBearerKey,
28
+ parseSetupOptions,
29
+ planHooks,
20
30
  resolveHermesPython,
21
31
  runHermesPythonScript
22
- } from "../chunk-AZPIQG4G.js";
32
+ } from "../chunk-ATUUQFDH.js";
23
33
  import {
24
34
  describeDetection,
25
35
  detectAllAgents,
26
36
  isDetected,
37
+ liveBridgeProbe,
27
38
  pluginLocationSnippet,
28
39
  registerPluginLocation,
29
40
  renderAgentInstructions,
30
41
  renderProjectAgentInstructions,
42
+ resolveBridgeStub,
31
43
  shortenHome,
32
44
  vscodeSettingsTargets,
33
45
  writeInstructionBlock
34
- } from "../chunk-FQL5E6NG.js";
46
+ } from "../chunk-CRVJCKIN.js";
35
47
  import {
36
48
  claudeWired,
37
49
  codexWired,
38
50
  geminiWired,
39
51
  pusharyHookExecutable
40
- } from "../chunk-DZDI62LY.js";
52
+ } from "../chunk-WGKC6PU2.js";
41
53
  import {
42
54
  OPENCODE_HOOK_BINARY,
43
55
  addOpenCodeMcpServer,
@@ -61,8 +73,9 @@ import {
61
73
  isClaudeMcpSnapshot,
62
74
  parseVersion,
63
75
  updateClaudeMcpSnapshot
64
- } from "../chunk-GL3FFM7A.js";
76
+ } from "../chunk-ELHCIEMM.js";
65
77
  import "../chunk-2LAHXHBR.js";
78
+ import "../chunk-DSTLA2TC.js";
66
79
  import {
67
80
  guardBinary,
68
81
  guardCursorGate,
@@ -80,7 +93,7 @@ import {
80
93
  replaceDaemonService,
81
94
  stopDaemonService,
82
95
  waitForDaemonRemoteProof
83
- } from "../chunk-F2ICEWZL.js";
96
+ } from "../chunk-Z4XCN2HH.js";
84
97
  import {
85
98
  detectProviderLiveCapabilities,
86
99
  hasSpawnProvider,
@@ -98,14 +111,15 @@ import {
98
111
  } from "../chunk-L4ZCFMWW.js";
99
112
  import {
100
113
  reportEvent
101
- } from "../chunk-4LOPSGLP.js";
114
+ } from "../chunk-TVZQMPB7.js";
102
115
  import "../chunk-F7OURW3C.js";
103
116
  import "../chunk-L4E2BIJ2.js";
104
- import "../chunk-54ELC7D7.js";
117
+ import "../chunk-AWHCZOZO.js";
105
118
  import {
106
119
  addCodexHookTrust,
107
120
  addCodexHooks,
108
121
  addCodexMcpServer,
122
+ captureCodexHookTrust,
109
123
  claudeJson,
110
124
  claudeMcpReceipt,
111
125
  claudeSettings,
@@ -118,12 +132,17 @@ import {
118
132
  codexTrustSchemeAgrees,
119
133
  cursorPluginDir,
120
134
  cursorUserHooks,
135
+ cursorUserMcp,
121
136
  geminiMd,
122
137
  geminiSettings,
123
138
  hermesConfigReceipt,
139
+ hookTakeoverReceipt,
124
140
  pusharyConfigFile,
125
- vscodePluginDir
126
- } from "../chunk-KUZWXPUS.js";
141
+ pusharyDir,
142
+ readCodexMcpAuth,
143
+ vscodePluginDir,
144
+ vscodePluginMcp
145
+ } from "../chunk-BVNYTQ5I.js";
127
146
  import {
128
147
  confirmAppConnection,
129
148
  connectDevice,
@@ -136,17 +155,16 @@ import {
136
155
  import "../chunk-3EGEA4KH.js";
137
156
  import {
138
157
  checkApiKey,
139
- describeKeyCheck
140
- } from "../chunk-AJYV3VGU.js";
158
+ describeKeyCheck,
159
+ samePusharyAccount
160
+ } from "../chunk-BXTJVM7O.js";
141
161
  import {
142
162
  setHumanStream
143
163
  } from "../chunk-QCGNGEGE.js";
144
164
  import {
145
165
  useColor
146
166
  } from "../chunk-5RUIFDTP.js";
147
- import {
148
- parseFlags
149
- } from "../chunk-GMXKITVA.js";
167
+ import "../chunk-GMXKITVA.js";
150
168
  import {
151
169
  renderCommandHelp
152
170
  } from "../chunk-43GMYSS4.js";
@@ -185,6 +203,7 @@ import {
185
203
  import "../chunk-2UMNXADU.js";
186
204
  import {
187
205
  CURSOR_GATE_EVENTS,
206
+ HOOK_LOCATOR_BINARY,
188
207
  isValidApiKey
189
208
  } from "../chunk-VNMKIJZB.js";
190
209
 
@@ -534,154 +553,6 @@ var reportSetupAbortWith = async (deps, reason, exitCode, keyCheck = "unknown")
534
553
  });
535
554
  var reportSetupAbort = (reason, exitCode, keyCheck) => reportSetupAbortWith(defaultDeps, reason, exitCode, keyCheck);
536
555
 
537
- // src/setup/options.ts
538
- var AGENT_CHOICES = ["claude_code", "codex", "gemini_cli", "hermes", "cursor", "vscode", "opencode", "custom"];
539
- var CONNECT_MODES = ["app", "browser", "web", "none"];
540
- var CONNECT_ALIASES = { auto: "app", pwa: "web" };
541
- var parseConnectMode = (raw) => {
542
- const value = raw.trim().toLowerCase();
543
- if (Object.hasOwn(CONNECT_ALIASES, value)) return CONNECT_ALIASES[value];
544
- if (CONNECT_MODES.includes(value)) return value;
545
- throw new UsageError(`--connect must be one of: ${CONNECT_MODES.join(", ")} (got ${raw})`);
546
- };
547
- var VERIFY_MODES = ["roundtrip", "push", "none"];
548
- var parseVerifyMode = (raw) => {
549
- const value = raw.trim().toLowerCase();
550
- if (VERIFY_MODES.includes(value)) return value;
551
- throw new UsageError(`--verify must be one of: ${VERIFY_MODES.join(", ")} (got ${raw})`);
552
- };
553
- var CONTROL_MODES = ["auto", "on", "off"];
554
- var parseControlMode = (raw) => {
555
- const value = raw.trim().toLowerCase();
556
- if (CONTROL_MODES.includes(value)) return value;
557
- throw new UsageError(`--control must be one of: ${CONTROL_MODES.join(", ")} (got ${raw})`);
558
- };
559
- var effectiveVerify = (options, context) => {
560
- if (options.verifyExplicit) return options.verify;
561
- if (options.verify === "roundtrip") return "roundtrip";
562
- return context.paired ? "roundtrip" : options.verify;
563
- };
564
- var SETUP_FLAGS = {
565
- bools: ["key-stdin", "skip-phone", "yes", "y", "json", "dry-run", "take-over-hooks", "help", "h"],
566
- values: ["key", "connect", "agents", "verify", "control", "transcripts"]
567
- };
568
- var effectiveControlMode = (options, stored, configPresent) => options.controlExplicit ? options.control : stored ?? (configPresent ? null : options.control);
569
- var isAgentChoice = (value) => AGENT_CHOICES.includes(value);
570
- var parseAgentSelection = (raw, yes) => {
571
- if (raw === void 0) {
572
- return yes ? { kind: "auto" } : { kind: "ask" };
573
- }
574
- const value = raw.trim().toLowerCase();
575
- if (value === "auto") return { kind: "auto" };
576
- if (value === "none") return { kind: "none" };
577
- const parts = value.split(",").map((part) => part.trim()).filter((part) => part !== "");
578
- if (parts.length === 0) throw new UsageError("--agents needs a value");
579
- const unknown = parts.filter((part) => !isAgentChoice(part));
580
- if (unknown.length > 0) {
581
- throw new UsageError(
582
- `--agents does not know: ${unknown.join(", ")}. Use auto, none, or any of: ${AGENT_CHOICES.join(", ")}`
583
- );
584
- }
585
- return { kind: "explicit", agents: [...new Set(parts)] };
586
- };
587
- var parseSetupOptions = (input2) => {
588
- const flags = parseFlags(input2.argv, SETUP_FLAGS);
589
- const stray = [
590
- ...flags.command !== void 0 && flags.command !== "setup" ? [flags.command] : [],
591
- ...flags.rest
592
- ];
593
- if (stray.length > 0) {
594
- throw new UsageError(
595
- `setup takes no positional arguments (got ${stray.join(", ")}). Did you mean --agents ${stray[0]}?`
596
- );
597
- }
598
- const yes = flags.bools.has("yes") || flags.bools.has("y");
599
- const help = flags.bools.has("help") || flags.bools.has("h");
600
- const agentsFlag = flags.values.get("agents");
601
- const agents = parseAgentSelection(agentsFlag, yes);
602
- const connectRaw = flags.values.get("connect");
603
- const connectMode = connectRaw === void 0 ? "app" : parseConnectMode(connectRaw);
604
- const verifyRaw = flags.values.get("verify");
605
- const controlRaw = flags.values.get("control");
606
- const transcriptsRaw = flags.values.get("transcripts")?.trim().toLowerCase();
607
- if (transcriptsRaw !== void 0 && transcriptsRaw !== "on" && transcriptsRaw !== "off") {
608
- throw new UsageError(`--transcripts must be one of: on, off (got ${transcriptsRaw})`);
609
- }
610
- const nonInteractive = yes || agentsFlag !== void 0 || flags.bools.has("json") || !input2.stdinIsTty;
611
- const verify = verifyRaw !== void 0 ? parseVerifyMode(verifyRaw) : nonInteractive ? "push" : "roundtrip";
612
- const key = flags.values.get("key")?.trim() || null;
613
- const keyStdin = flags.bools.has("key-stdin");
614
- if (key && keyStdin) {
615
- throw new UsageError("Pass either --key or --key-stdin, not both");
616
- }
617
- if (key && !isValidApiKey(key)) {
618
- throw new UsageError("--key is not a valid API key. Expected the pk_xxx.xxx shape from pushary.com/dashboard/agent/settings");
619
- }
620
- return {
621
- connectMode,
622
- connectExplicit: connectRaw !== void 0,
623
- // `--connect none` and `--skip-phone` are the same instruction, so they
624
- // resolve to the same field rather than being checked separately at the two
625
- // call sites that would inevitably drift apart.
626
- skipPhone: flags.bools.has("skip-phone") || connectMode === "none",
627
- // Anything that means "there is nobody to answer a prompt". A non-TTY stdin
628
- // is included because that is the case that used to hang: it is better to
629
- // take the defaults and say so than to wait forever for a keypress.
630
- //
631
- // --json counts. Under it stdout carries exactly one object and every human
632
- // line is redirected to stderr, so a prompt has nowhere to render: the
633
- // question goes to stderr while the run blocks on a keypress the caller
634
- // cannot see it is waiting for, and whatever is reading stdout waits forever
635
- // for an object that never arrives. Asking for machine-readable output is
636
- // itself a statement that no human is watching.
637
- nonInteractive,
638
- json: flags.bools.has("json"),
639
- dryRun: flags.bools.has("dry-run"),
640
- help,
641
- agents,
642
- key,
643
- keyStdin,
644
- verify,
645
- verifyExplicit: verifyRaw !== void 0,
646
- control: controlRaw === void 0 ? "auto" : parseControlMode(controlRaw),
647
- controlExplicit: controlRaw !== void 0,
648
- transcripts: transcriptsRaw === void 0 ? null : transcriptsRaw === "on",
649
- takeOverHooks: flags.bools.has("take-over-hooks")
650
- };
651
- };
652
-
653
- // src/setup/hook-ownership.ts
654
- var commandsIn = (value) => {
655
- if (Array.isArray(value)) return value.flatMap(commandsIn);
656
- if (!value || typeof value !== "object") return [];
657
- return Object.entries(value).flatMap(([key, item]) => key === "command" && typeof item === "string" ? [item] : commandsIn(item));
658
- };
659
- var hookOwnerOf = (document) => {
660
- const hooks = document && typeof document === "object" ? document.hooks : void 0;
661
- const executables = commandsIn(hooks).map(pusharyHookExecutable).filter((executable) => executable !== null);
662
- if (executables.some(isBridgeLocator)) return "app";
663
- if (executables.length > 0) return "cli";
664
- return "none";
665
- };
666
- var planHooks = (context) => {
667
- if (context.owner !== "app") return "install";
668
- if (context.takeOverHooks) return "install";
669
- return context.nonInteractive ? "keep" : "ask";
670
- };
671
- var describeAppOwnership = (agentName) => `The Pushary Mac app owns ${agentName}'s hooks.`;
672
- var takeoverQuestion = (agentName) => `Replace them with the CLI's? The app stops answering for ${agentName} and the notch loses its terminal jump there.`;
673
- var KEEP_HINT = "Left as they are. Pass --take-over-hooks to have the CLI own them instead.";
674
- var OWNER_LABELS = {
675
- app: "the Pushary Mac app",
676
- cli: "the CLI"
677
- };
678
- var describeHookOwnership = (entries, names) => {
679
- const owned = entries.filter((entry) => entry.owner !== "none");
680
- if (owned.length === 0) return null;
681
- const parts = owned.map((entry) => `${names[entry.agent]} by ${OWNER_LABELS[entry.owner]}${entry.kept ? " (kept)" : ""}`);
682
- return `Hooks: ${parts.join(", ")}.`;
683
- };
684
-
685
556
  // bin/pushary-setup.ts
686
557
  var CLAUDE_SETTINGS = claudeSettings();
687
558
  var CLAUDE_JSON = claudeJson();
@@ -690,6 +561,7 @@ var HERMES_CONFIG_RECEIPT = hermesConfigReceipt();
690
561
  var CURSOR_PLUGIN_DIR = cursorPluginDir();
691
562
  var CURSOR_USER_HOOKS = cursorUserHooks();
692
563
  var VSCODE_PLUGIN_DIR = vscodePluginDir();
564
+ var VSCODE_PLUGIN_MCP = vscodePluginMcp();
693
565
  var CLAUDE_SKILL_DIR = claudeSkillDir();
694
566
  var CODEX_HOME = codexHome();
695
567
  var CODEX_SKILL_DIR = codexSkillDir();
@@ -1410,7 +1282,7 @@ var setupVsCode = async (apiKey) => {
1410
1282
  }
1411
1283
  });
1412
1284
  await spinner("Linking your API key", async () => {
1413
- const mcpPath = join3(VSCODE_PLUGIN_DIR, ".mcp.json");
1285
+ const mcpPath = VSCODE_PLUGIN_MCP;
1414
1286
  const mcp = readAgentJson(mcpPath);
1415
1287
  const servers = mcp.mcpServers ?? {};
1416
1288
  if (servers.pushary) {
@@ -1585,16 +1457,36 @@ var HOOK_FILES = {
1585
1457
  cursor: () => CURSOR_USER_HOOKS,
1586
1458
  vscode: () => join3(VSCODE_PLUGIN_DIR, "hooks", "hooks.json")
1587
1459
  };
1588
- var hookOwnerFor = (agent) => {
1460
+ var hookOwnerFor = (agent, appAvailable = true) => {
1589
1461
  const file = HOOK_FILES[agent]?.();
1590
1462
  if (!file) return "none";
1591
1463
  const document = readJsonSafe(file);
1592
- return hookOwnerOf(document.kind === "ok" ? document.value : null);
1593
- };
1594
- var confirmTakeover = async (agent) => {
1595
- console.log();
1596
- console.log(` ${yellow("!")} ${describeAppOwnership(AGENT_NAMES[agent])}`);
1597
- return confirm({ message: takeoverQuestion(AGENT_NAMES[agent]), default: false });
1464
+ return hookOwnerOf(document.kind === "ok" ? document.value : null, appAvailable);
1465
+ };
1466
+ var appMcpKeyFor = (agent) => {
1467
+ if (agent === "codex") {
1468
+ const auth = readCodexMcpAuth(readAgentToml(codexConfigToml()));
1469
+ return auth?.method === "embedded" ? auth.key : null;
1470
+ }
1471
+ const file = agent === "claude_code" ? CLAUDE_JSON : agent === "gemini_cli" ? GEMINI_SETTINGS : agent === "cursor" ? cursorUserMcp() : agent === "vscode" ? VSCODE_PLUGIN_MCP : null;
1472
+ return file ? mcpBearerKey(readAgentJson(file), "mcpServers", "headers") : null;
1473
+ };
1474
+ var captureTakeoverReceipt = (agent) => {
1475
+ const hookFile = HOOK_FILES[agent]?.();
1476
+ if (!hookFile) return;
1477
+ const document = readAgentJson(hookFile);
1478
+ const captured = captureHookTakeover(agent, document);
1479
+ if (!captured) throw new Error(`Cannot safely take over ${AGENT_NAMES[agent]}'s hooks: no Mac app wiring was found.`);
1480
+ const codexConfig = agent === "codex" ? readAgentToml(codexConfigToml()) : null;
1481
+ const mcp = agent === "claude_code" ? [readAgentJson(CLAUDE_JSON), "mcpServers"] : agent === "codex" ? [codexConfig, "mcp_servers"] : agent === "gemini_cli" ? [document, "mcpServers"] : agent === "vscode" ? [readAgentJson(VSCODE_PLUGIN_MCP), "mcpServers"] : null;
1482
+ const receipt = {
1483
+ ...captured,
1484
+ ...codexConfig ? {
1485
+ codexTrust: captureCodexHookTrust(codexConfig, hookFile, codexHookPositions(document))
1486
+ } : {},
1487
+ ...mcp ? { mcpServer: captureMcpServer(mcp[0], mcp[1]) } : {}
1488
+ };
1489
+ writeJsonAtomic(hookTakeoverReceipt(agent), receipt, 384);
1598
1490
  };
1599
1491
  var agentIsWired = (agent) => {
1600
1492
  const readJson2 = (path) => {
@@ -1629,7 +1521,7 @@ var agentIsWired = (agent) => {
1629
1521
  case "cursor":
1630
1522
  return existsSync(join3(CURSOR_PLUGIN_DIR, "mcp.json"));
1631
1523
  case "vscode":
1632
- return existsSync(join3(VSCODE_PLUGIN_DIR, ".mcp.json"));
1524
+ return existsSync(VSCODE_PLUGIN_MCP);
1633
1525
  case "opencode":
1634
1526
  return openCodeWired();
1635
1527
  default:
@@ -1820,7 +1712,7 @@ var AGENT_TARGETS = {
1820
1712
  gemini_cli: [GEMINI_SETTINGS, GEMINI_MD],
1821
1713
  hermes: ["the Hermes virtualenv (pip install pushary-hermes)"],
1822
1714
  cursor: [join3(CURSOR_PLUGIN_DIR, "mcp.json"), CURSOR_USER_HOOKS],
1823
- vscode: [join3(VSCODE_PLUGIN_DIR, ".mcp.json"), ...vscodeSettingsTargets(existsSync)],
1715
+ vscode: [VSCODE_PLUGIN_MCP, ...vscodeSettingsTargets(existsSync)],
1824
1716
  opencode: [
1825
1717
  openCodePluginFile(),
1826
1718
  join3(openCodePluginDir(), "package.json"),
@@ -2044,6 +1936,29 @@ var main = async () => {
2044
1936
  }
2045
1937
  const rc = await saveApiKey(trimmedKey, controlMode, transcriptSync);
2046
1938
  const context = { rc };
1939
+ const appBridgeAvailable = resolveBridgeStub(
1940
+ join3(pusharyDir(), "bin", HOOK_LOCATOR_BINARY),
1941
+ liveBridgeProbe()
1942
+ ).kind === "bundle";
1943
+ const accountChecks = /* @__PURE__ */ new Map();
1944
+ if (keyCheck) accountChecks.set(trimmedKey, Promise.resolve(keyCheck));
1945
+ const accountCheckFor = (key) => {
1946
+ const existing = accountChecks.get(key);
1947
+ if (existing) return existing;
1948
+ const pending = checkApiKey(key);
1949
+ accountChecks.set(key, pending);
1950
+ return pending;
1951
+ };
1952
+ const appAccountMatches = async (agent) => {
1953
+ const appKey = appMcpKeyFor(agent);
1954
+ if (!appKey) return false;
1955
+ if (appKey === trimmedKey) return true;
1956
+ const [cliAccount, appAccount] = await Promise.all([
1957
+ accountCheckFor(trimmedKey),
1958
+ accountCheckFor(appKey)
1959
+ ]);
1960
+ return samePusharyAccount(cliAccount, appAccount);
1961
+ };
2047
1962
  if (envKey && envKey !== trimmedKey) {
2048
1963
  noteManual(
2049
1964
  `This shell still exports the previous key (${keyPrefix(envKey)}), and it wins over the one just saved. Open a new terminal before starting an agent here, or re-export PUSHARY_API_KEY.`
@@ -2062,22 +1977,32 @@ var main = async () => {
2062
1977
  for (const agent of agents) {
2063
1978
  markStep(`configure:${agent}`);
2064
1979
  try {
2065
- const ownerBefore = hookOwnerFor(agent);
1980
+ const ownerBefore = hookOwnerFor(agent, appBridgeAvailable);
2066
1981
  const plan = planHooks({ owner: ownerBefore, takeOverHooks: options.takeOverHooks, nonInteractive: options.nonInteractive });
2067
- const keepAppWiring = plan === "keep" || plan === "ask" && !await confirmTakeover(agent);
1982
+ const keepAppWiring = plan === "keep";
2068
1983
  if (keepAppWiring) {
1984
+ if (!await appAccountMatches(agent)) {
1985
+ hookOwners.push({ agent, owner: "app", kept: true });
1986
+ failed.push(agent.replace("_", " "));
1987
+ console.log(`
1988
+ ${yellow("!")} ${AGENT_NAMES[agent]}: Mac app hooks kept, but their Pushary account could not be matched to this setup.`);
1989
+ console.log(` ${dim("Sign the Mac app into the same account and repair this agent, then re-run setup.")}`);
1990
+ console.log(` ${dim("Or pass --take-over-hooks if you intentionally want the CLI to own these hooks.")}`);
1991
+ continue;
1992
+ }
2069
1993
  console.log(`
2070
1994
  ${check} ${AGENT_NAMES[agent]}: ${describeAppOwnership(AGENT_NAMES[agent])} ${dim(KEEP_HINT)}`);
2071
1995
  hookOwners.push({ agent, owner: "app", kept: true });
2072
1996
  completed.push(agent);
2073
1997
  continue;
2074
1998
  }
1999
+ if (ownerBefore === "app") captureTakeoverReceipt(agent);
2075
2000
  const outcome = await AGENT_SETUP[agent](trimmedKey, context);
2076
2001
  if (outcome === "skipped") {
2077
2002
  skipped.push(agent);
2078
2003
  } else if (agentIsWired(agent)) {
2079
2004
  completed.push(agent);
2080
- hookOwners.push({ agent, owner: hookOwnerFor(agent), kept: false });
2005
+ hookOwners.push({ agent, owner: hookOwnerFor(agent, appBridgeAvailable), kept: false });
2081
2006
  } else {
2082
2007
  failed.push(agent.replace("_", " "));
2083
2008
  console.log(` ${yellow("!")} ${agent.replace("_", " ")} reported success but its config is not there.`);
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  describeLastSeen,
4
4
  listMachines
5
- } from "../chunk-7TPQEWUZ.js";
6
- import "../chunk-54ELC7D7.js";
7
- import "../chunk-KUZWXPUS.js";
5
+ } from "../chunk-YTD6PJM7.js";
6
+ import "../chunk-AWHCZOZO.js";
7
+ import "../chunk-BVNYTQ5I.js";
8
8
  import {
9
9
  describeReach,
10
10
  fetchChannels,
@@ -14,7 +14,7 @@ import "../chunk-3EGEA4KH.js";
14
14
  import {
15
15
  checkApiKey,
16
16
  describeKeyCheck
17
- } from "../chunk-AJYV3VGU.js";
17
+ } from "../chunk-BXTJVM7O.js";
18
18
  import "../chunk-QCGNGEGE.js";
19
19
  import {
20
20
  createIo
@@ -6,11 +6,11 @@ import {
6
6
  handleStop,
7
7
  handleSubagentStop,
8
8
  isSubagentStop
9
- } from "../chunk-4LOPSGLP.js";
9
+ } from "../chunk-TVZQMPB7.js";
10
10
  import "../chunk-F7OURW3C.js";
11
11
  import "../chunk-L4E2BIJ2.js";
12
- import "../chunk-54ELC7D7.js";
13
- import "../chunk-KUZWXPUS.js";
12
+ import "../chunk-AWHCZOZO.js";
13
+ import "../chunk-BVNYTQ5I.js";
14
14
  import "../chunk-BSZYIAZL.js";
15
15
  import "../chunk-SAF6HGAA.js";
16
16
  import "../chunk-7QLSKOSU.js";
@@ -4,11 +4,11 @@ import {
4
4
  } from "../chunk-6CUUA7HO.js";
5
5
  import {
6
6
  handleStopFailure
7
- } from "../chunk-4LOPSGLP.js";
7
+ } from "../chunk-TVZQMPB7.js";
8
8
  import "../chunk-F7OURW3C.js";
9
9
  import "../chunk-L4E2BIJ2.js";
10
- import "../chunk-54ELC7D7.js";
11
- import "../chunk-KUZWXPUS.js";
10
+ import "../chunk-AWHCZOZO.js";
11
+ import "../chunk-BVNYTQ5I.js";
12
12
  import "../chunk-BSZYIAZL.js";
13
13
  import "../chunk-SAF6HGAA.js";
14
14
  import "../chunk-7QLSKOSU.js";