@pushary/agent-hooks 0.89.12 → 0.90.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.
Files changed (82) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +1 -0
  3. package/data/SKILL.md +1 -1
  4. package/data/cursor-plugin/skills/pushary/SKILL.md +1 -1
  5. package/data/vscode-plugin/skills/pushary/SKILL.md +1 -1
  6. package/dist/bin/pushary-bell-hook.js +4 -4
  7. package/dist/bin/pushary-bell.js +8 -8
  8. package/dist/bin/pushary-claude.js +194 -38
  9. package/dist/bin/pushary-clean.js +15 -32
  10. package/dist/bin/pushary-codex-bridge.js +37 -12
  11. package/dist/bin/pushary-codex-hook.js +45 -12
  12. package/dist/bin/pushary-codex.js +7 -7
  13. package/dist/bin/pushary-connect.js +11 -10
  14. package/dist/bin/pushary-daemon.js +186 -62
  15. package/dist/bin/pushary-disconnect.js +8 -8
  16. package/dist/bin/pushary-doctor.js +108 -25
  17. package/dist/bin/pushary-elicitation-hook.js +4 -4
  18. package/dist/bin/pushary-gemini-bridge.js +33 -11
  19. package/dist/bin/pushary-gemini-hook.js +21 -10
  20. package/dist/bin/pushary-hook.js +13 -13
  21. package/dist/bin/pushary-login.js +18 -7
  22. package/dist/bin/pushary-logout.js +6 -6
  23. package/dist/bin/pushary-mode.js +28 -21
  24. package/dist/bin/pushary-notification-hook.js +7 -7
  25. package/dist/bin/pushary-opencode-hook.js +8 -8
  26. package/dist/bin/pushary-permission-denied-hook.js +11 -11
  27. package/dist/bin/pushary-permission-hook.js +11 -11
  28. package/dist/bin/pushary-post-hook.js +14 -8
  29. package/dist/bin/pushary-prompt-hook.js +7 -7
  30. package/dist/bin/pushary-session-end-hook.js +7 -7
  31. package/dist/bin/pushary-session-start-hook.js +7 -7
  32. package/dist/bin/pushary-setup.js +168 -45
  33. package/dist/bin/pushary-stats.js +4 -4
  34. package/dist/bin/pushary-status.js +11 -10
  35. package/dist/bin/pushary-stop-hook.js +14 -8
  36. package/dist/bin/pushary-stopfailure-hook.js +7 -7
  37. package/dist/bin/pushary-suggestions.js +2 -2
  38. package/dist/bin/pushary-transcripts.d.ts +1 -0
  39. package/dist/bin/pushary-transcripts.js +79 -0
  40. package/dist/bin/pushary-upgrade.js +15 -15
  41. package/dist/bin/pushary-wait.js +5 -5
  42. package/dist/bin/pushary.js +3 -2
  43. package/dist/{chunk-KVHP5ZME.js → chunk-2LAHXHBR.js} +1 -1
  44. package/dist/{chunk-RLQWNEPM.js → chunk-43GMYSS4.js} +15 -0
  45. package/dist/{chunk-5NDB3YOE.js → chunk-54ELC7D7.js} +1 -1
  46. package/dist/{chunk-VPLQFXCH.js → chunk-5NAZ7SFS.js} +1 -1
  47. package/dist/chunk-7FE2KABY.js +156 -0
  48. package/dist/{chunk-DHR4F2CR.js → chunk-7TPQEWUZ.js} +1 -1
  49. package/dist/{chunk-Y4WVZIEI.js → chunk-AJYV3VGU.js} +1 -1
  50. package/dist/{chunk-QFJZHVVL.js → chunk-AZPIQG4G.js} +35 -1
  51. package/dist/{chunk-OCMOTJTW.js → chunk-B7UZHEBL.js} +29 -22
  52. package/dist/{chunk-7HYJPOGG.js → chunk-BQBEH6TV.js} +5 -5
  53. package/dist/{chunk-OTPJ4FUR.js → chunk-BVBEURWJ.js} +1 -1
  54. package/dist/{chunk-7DK3ZH3N.js → chunk-CELX75MW.js} +1 -1
  55. package/dist/{chunk-6VXNA5JB.js → chunk-CNPAT3HL.js} +3 -2
  56. package/dist/{chunk-327YMKP5.js → chunk-DYP6SMOR.js} +1 -1
  57. package/dist/chunk-DZDI62LY.js +145 -0
  58. package/dist/{chunk-VF3RTVWY.js → chunk-EZIEXHYM.js} +15 -7
  59. package/dist/{chunk-PS7DQ2SU.js → chunk-F2ICEWZL.js} +101 -19
  60. package/dist/{chunk-3XSP5SML.js → chunk-FQL5E6NG.js} +2 -2
  61. package/dist/{chunk-JHJHCMAF.js → chunk-FXEVRLHC.js} +20 -2
  62. package/dist/{chunk-6V7ZDH3A.js → chunk-GL3FFM7A.js} +7 -4
  63. package/dist/{chunk-NBRM3FMD.js → chunk-H2QZRQR2.js} +1 -1
  64. package/dist/{chunk-GKPURU7P.js → chunk-I463AEG3.js} +1 -1
  65. package/dist/{chunk-XREW7RQ3.js → chunk-JW4KO5AF.js} +1 -1
  66. package/dist/{chunk-OVEGEQSB.js → chunk-KUZWXPUS.js} +3 -2
  67. package/dist/{chunk-JVZX5YRJ.js → chunk-L4E2BIJ2.js} +80 -7
  68. package/dist/{chunk-RNKPLUWC.js → chunk-OSALSIUF.js} +1 -1
  69. package/dist/{chunk-MFNQ5IMW.js → chunk-PYA4FLKI.js} +32 -21
  70. package/dist/chunk-QCGNGEGE.js +15 -0
  71. package/dist/chunk-S6LYP7QA.js +127 -0
  72. package/dist/{chunk-OADGBOP7.js → chunk-TDZFPMSZ.js} +70 -11
  73. package/dist/{chunk-JJV5Q4KG.js → chunk-UZNKVRLE.js} +1 -1
  74. package/dist/{chunk-FCUUVHTS.js → chunk-VHWCVD42.js} +1 -1
  75. package/dist/{chunk-3MCEES6Z.js → chunk-VNMKIJZB.js} +15 -2
  76. package/dist/{chunk-6GU55AQQ.js → chunk-Y6BWPERV.js} +90 -7
  77. package/dist/chunk-YKLCWWEI.js +76 -0
  78. package/dist/src/index.d.ts +3 -0
  79. package/dist/src/index.js +11 -11
  80. package/package.json +3 -2
  81. package/dist/chunk-NESKLV6R.js +0 -72
  82. package/dist/chunk-WDVQ6O4C.js +0 -84
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  reapplyAllAgents
4
- } from "../chunk-7HYJPOGG.js";
5
- import "../chunk-NBRM3FMD.js";
4
+ } from "../chunk-BQBEH6TV.js";
5
+ import "../chunk-H2QZRQR2.js";
6
6
  import {
7
7
  waitForMachineReadiness
8
- } from "../chunk-DHR4F2CR.js";
9
- import "../chunk-NESKLV6R.js";
10
- import "../chunk-6V7ZDH3A.js";
11
- import "../chunk-KVHP5ZME.js";
12
- import "../chunk-VF3RTVWY.js";
8
+ } from "../chunk-7TPQEWUZ.js";
9
+ import "../chunk-DZDI62LY.js";
10
+ import "../chunk-GL3FFM7A.js";
11
+ import "../chunk-2LAHXHBR.js";
12
+ import "../chunk-EZIEXHYM.js";
13
13
  import {
14
14
  daemonHasRemoteProof,
15
15
  daemonServiceManagerAvailable,
@@ -20,7 +20,7 @@ import {
20
20
  replaceDaemonService,
21
21
  stopDaemonService,
22
22
  waitForDaemonRemoteProof
23
- } from "../chunk-PS7DQ2SU.js";
23
+ } from "../chunk-F2ICEWZL.js";
24
24
  import {
25
25
  detectProviderLiveCapabilities,
26
26
  hasSpawnProvider,
@@ -34,32 +34,32 @@ import {
34
34
  npmErrorMessage,
35
35
  resolveGlobalBinary
36
36
  } from "../chunk-L4ZCFMWW.js";
37
- import "../chunk-5NDB3YOE.js";
37
+ import "../chunk-54ELC7D7.js";
38
38
  import {
39
39
  claudeJson,
40
40
  codexConfigToml,
41
41
  cursorPluginDir,
42
42
  geminiSettings,
43
43
  vscodePluginDir
44
- } from "../chunk-OVEGEQSB.js";
44
+ } from "../chunk-KUZWXPUS.js";
45
45
  import {
46
46
  exitOnHelpFlag
47
- } from "../chunk-OTPJ4FUR.js";
48
- import "../chunk-RLQWNEPM.js";
47
+ } from "../chunk-BVBEURWJ.js";
48
+ import "../chunk-43GMYSS4.js";
49
49
  import {
50
50
  isNewerVersion
51
51
  } from "../chunk-DINDL2CF.js";
52
52
  import {
53
53
  readControlMode
54
- } from "../chunk-RNKPLUWC.js";
54
+ } from "../chunk-OSALSIUF.js";
55
55
  import "../chunk-BC3VCZ3E.js";
56
56
  import "../chunk-KZERVKTD.js";
57
- import "../chunk-XREW7RQ3.js";
57
+ import "../chunk-JW4KO5AF.js";
58
58
  import "../chunk-4LL6LG5X.js";
59
59
  import {
60
60
  getApiKey
61
61
  } from "../chunk-2UMNXADU.js";
62
- import "../chunk-3MCEES6Z.js";
62
+ import "../chunk-VNMKIJZB.js";
63
63
 
64
64
  // bin/pushary-upgrade.ts
65
65
  import { existsSync } from "fs";
@@ -4,8 +4,8 @@ import {
4
4
  } from "../chunk-IIENZE2J.js";
5
5
  import {
6
6
  exitOnFailedResponse
7
- } from "../chunk-327YMKP5.js";
8
- import "../chunk-Y4WVZIEI.js";
7
+ } from "../chunk-DYP6SMOR.js";
8
+ import "../chunk-AJYV3VGU.js";
9
9
  import {
10
10
  createIo
11
11
  } from "../chunk-5RUIFDTP.js";
@@ -14,8 +14,8 @@ import {
14
14
  } from "../chunk-GMXKITVA.js";
15
15
  import {
16
16
  exitOnHelpFlag
17
- } from "../chunk-OTPJ4FUR.js";
18
- import "../chunk-RLQWNEPM.js";
17
+ } from "../chunk-BVBEURWJ.js";
18
+ import "../chunk-43GMYSS4.js";
19
19
  import "../chunk-DINDL2CF.js";
20
20
  import "../chunk-SAF6HGAA.js";
21
21
  import {
@@ -28,7 +28,7 @@ import {
28
28
  getApiKey,
29
29
  getBaseUrl
30
30
  } from "../chunk-2UMNXADU.js";
31
- import "../chunk-3MCEES6Z.js";
31
+ import "../chunk-VNMKIJZB.js";
32
32
 
33
33
  // bin/pushary-wait.ts
34
34
  exitOnHelpFlag("wait");
@@ -3,7 +3,7 @@ import {
3
3
  COMMANDS,
4
4
  isCommandName,
5
5
  renderHelp
6
- } from "../chunk-RLQWNEPM.js";
6
+ } from "../chunk-43GMYSS4.js";
7
7
  import {
8
8
  getPackageVersion
9
9
  } from "../chunk-DINDL2CF.js";
@@ -33,7 +33,8 @@ var LOADERS = {
33
33
  stats: () => import("./pushary-stats.js"),
34
34
  suggestions: () => import("./pushary-suggestions.js"),
35
35
  upgrade: () => import("./pushary-upgrade.js"),
36
- hook: () => import("./pushary-hook.js")
36
+ hook: () => import("./pushary-hook.js"),
37
+ transcripts: () => import("./pushary-transcripts.js")
37
38
  };
38
39
  installProxyDispatcher();
39
40
  var argv = process.argv.slice(2);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ASKED_IN_EVERY_MODE_TOOLS
3
- } from "./chunk-3MCEES6Z.js";
3
+ } from "./chunk-VNMKIJZB.js";
4
4
 
5
5
  // src/claude-tools.ts
6
6
  var PRETOOLUSE_GATED_TOOLS = [
@@ -69,6 +69,16 @@ var COMMAND_LIST = [
69
69
  name: "hook",
70
70
  module: "pushary-hook",
71
71
  summary: "Run as a PreToolUse hook (reads stdin, writes stdout)"
72
+ },
73
+ {
74
+ name: "transcripts",
75
+ module: "pushary-transcripts",
76
+ summary: "Show or re-trust the keys this machine seals transcripts to",
77
+ detail: [
78
+ "Sync stops if the phone key or the compliance recovery key changes, because a",
79
+ "change is either your reinstall or a server handing itself a copy. Compare the",
80
+ "fingerprint with the app under Settings, then accept it with --rotate."
81
+ ]
72
82
  }
73
83
  ];
74
84
  var COMMANDS = COMMAND_LIST;
@@ -79,6 +89,10 @@ var COMMAND_OPTIONS = {
79
89
  ["--dry-run", "List everything it would remove and change nothing"],
80
90
  ["--yes", "Remove everything without asking"]
81
91
  ],
92
+ transcripts: [
93
+ ["status", "Show the pinned keys and their fingerprints (default)"],
94
+ ["trust --rotate", "Accept the keys the server is offering now and resume syncing"]
95
+ ],
82
96
  mode: [
83
97
  ["<mode>", "One of: push_only, push_first, terminal_only, notify_only"],
84
98
  ["status", "Show the current override"],
@@ -135,6 +149,7 @@ var SETUP_OPTIONS = [
135
149
  ["--control auto|on|off", "Manage phone-start automatically (default), require it, or disable its background service"],
136
150
  ["--transcripts on|off", "Enable or disable encrypted transcript sync on this machine"],
137
151
  ["--skip-phone", "Skip the phone connect step"],
152
+ ["--take-over-hooks", "Replace hooks the Pushary Mac app owns with the CLI's. Without it the app's wiring is kept"],
138
153
  ["--verify roundtrip", "Send a real question and wait for you to answer it (default when a human is present)"],
139
154
  ["--verify push", "Only prove a notification was delivered. Automatic when nobody is at the terminal"],
140
155
  ["--verify none", "Skip the final check entirely"],
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pusharyDir
3
- } from "./chunk-OVEGEQSB.js";
3
+ } from "./chunk-KUZWXPUS.js";
4
4
  import {
5
5
  writeFileAtomic
6
6
  } from "./chunk-4LL6LG5X.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readConfigFileKey
3
- } from "./chunk-RNKPLUWC.js";
3
+ } from "./chunk-OSALSIUF.js";
4
4
 
5
5
  // src/bell/fleet.ts
6
6
  import { closeSync, constants, futimesSync, lstatSync, mkdirSync, openSync, readdirSync, unlinkSync } from "fs";
@@ -0,0 +1,156 @@
1
+ import {
2
+ redactSecrets
3
+ } from "./chunk-VNMKIJZB.js";
4
+
5
+ // src/crypto.ts
6
+ import nacl from "tweetnacl";
7
+ var EPH_PUB_LEN = nacl.box.publicKeyLength;
8
+ var BOX_NONCE_LEN = nacl.box.nonceLength;
9
+ var SECRETBOX_NONCE_LEN = nacl.secretbox.nonceLength;
10
+ var SESSION_KEY_LEN = nacl.secretbox.keyLength;
11
+ var toBase64 = (bytes) => Buffer.from(bytes).toString("base64");
12
+ var fromBase64 = (value) => new Uint8Array(Buffer.from(value, "base64"));
13
+ var utf8Encode = (text) => new Uint8Array(Buffer.from(text, "utf-8"));
14
+ var decodePublicKey = (value) => fromBase64(value);
15
+ var generateSessionKey = () => nacl.randomBytes(SESSION_KEY_LEN);
16
+ var wrapSessionKey = (sessionKey, accountPublicKey) => {
17
+ const ephemeral = nacl.box.keyPair();
18
+ const nonce = nacl.randomBytes(BOX_NONCE_LEN);
19
+ const box = nacl.box(sessionKey, nonce, accountPublicKey, ephemeral.secretKey);
20
+ const bundle = new Uint8Array(EPH_PUB_LEN + BOX_NONCE_LEN + box.length);
21
+ bundle.set(ephemeral.publicKey, 0);
22
+ bundle.set(nonce, EPH_PUB_LEN);
23
+ bundle.set(box, EPH_PUB_LEN + BOX_NONCE_LEN);
24
+ return toBase64(bundle);
25
+ };
26
+ var encryptRecord = (plaintext, sessionKey) => {
27
+ const nonce = nacl.randomBytes(SECRETBOX_NONCE_LEN);
28
+ const box = nacl.secretbox(utf8Encode(plaintext), nonce, sessionKey);
29
+ const bundle = new Uint8Array(SECRETBOX_NONCE_LEN + box.length);
30
+ bundle.set(nonce, 0);
31
+ bundle.set(box, SECRETBOX_NONCE_LEN);
32
+ return toBase64(bundle);
33
+ };
34
+
35
+ // src/transcript-capture.ts
36
+ import { createHmac } from "crypto";
37
+
38
+ // src/transcript-budget.ts
39
+ var CIPHERTEXT_BUDGET_CHARS = 64 * 1024;
40
+ var SECRETBOX_OVERHEAD_BYTES = 24 + 16;
41
+ var MAX_PLAINTEXT_BYTES = Math.floor(CIPHERTEXT_BUDGET_CHARS / 4) * 3 - SECRETBOX_OVERHEAD_BYTES;
42
+ var MIN_KEEP_CHARS = 200;
43
+ var note = (dropped) => `
44
+ [Pushary truncated ${dropped} bytes to fit the transcript size limit]`;
45
+ var stringSlots = (value, out = []) => {
46
+ if (Array.isArray(value)) {
47
+ value.forEach((inner, index) => {
48
+ if (typeof inner === "string") {
49
+ out.push({ get: () => value[index], set: (v) => {
50
+ value[index] = v;
51
+ } });
52
+ } else {
53
+ stringSlots(inner, out);
54
+ }
55
+ });
56
+ } else if (value && typeof value === "object") {
57
+ const object = value;
58
+ for (const key of Object.keys(object)) {
59
+ const inner = object[key];
60
+ if (typeof inner === "string") {
61
+ out.push({ get: () => object[key], set: (v) => {
62
+ object[key] = v;
63
+ } });
64
+ } else {
65
+ stringSlots(inner, out);
66
+ }
67
+ }
68
+ }
69
+ return out;
70
+ };
71
+ var jsonBytes = (value) => Buffer.byteLength(JSON.stringify(value), "utf-8");
72
+ var fitWithinPlaintextBudget = (record, budget = MAX_PLAINTEXT_BYTES) => {
73
+ if (jsonBytes(record) <= budget) return false;
74
+ const slots = stringSlots(record).map((slot) => ({
75
+ slot,
76
+ originalBytes: Buffer.byteLength(slot.get(), "utf-8")
77
+ }));
78
+ if (slots.length === 0) return false;
79
+ let truncated = false;
80
+ for (let pass = 0; pass < 64 && jsonBytes(record) > budget; pass += 1) {
81
+ let worst = slots[0];
82
+ for (const candidate of slots) {
83
+ if (candidate.slot.get().length > worst.slot.get().length) worst = candidate;
84
+ }
85
+ const current = worst.slot.get();
86
+ const keep = Math.max(MIN_KEEP_CHARS, Math.floor(current.length / 2));
87
+ const kept = current.slice(0, keep);
88
+ const replacement = kept + note(worst.originalBytes - Buffer.byteLength(kept, "utf-8"));
89
+ if (replacement.length >= current.length) break;
90
+ worst.slot.set(replacement);
91
+ truncated = true;
92
+ }
93
+ return truncated;
94
+ };
95
+
96
+ // src/transcript-capture.ts
97
+ var INTERNAL_TYPES = /* @__PURE__ */ new Set([
98
+ "file-history-snapshot",
99
+ "change",
100
+ "queue-operation",
101
+ "summary",
102
+ "last-prompt",
103
+ "mode",
104
+ "permission-mode",
105
+ "atis-latch",
106
+ "frame-link",
107
+ "cost-state",
108
+ "agent-name",
109
+ "bridge-session",
110
+ "artifact-autoreact-ledger",
111
+ "artifact-comment-monitor"
112
+ ]);
113
+ var redactDeep = (value) => {
114
+ if (typeof value === "string") return redactSecrets(value);
115
+ if (Array.isArray(value)) return value.map(redactDeep);
116
+ if (value && typeof value === "object") {
117
+ const out = {};
118
+ for (const [key, inner] of Object.entries(value)) {
119
+ out[key] = redactDeep(inner);
120
+ }
121
+ return out;
122
+ }
123
+ return value;
124
+ };
125
+ var localIdFor = (parsed, rawLine, sessionKey) => typeof parsed.uuid === "string" && parsed.uuid.length > 0 ? parsed.uuid : createHmac("sha256", sessionKey).update(rawLine).digest("hex").slice(0, 32);
126
+ var buildTranscriptRecords = (lines, sessionKey, seen = /* @__PURE__ */ new Set()) => {
127
+ const records = [];
128
+ const nextSeen = new Set(seen);
129
+ for (const line of lines) {
130
+ const trimmed = line.trim();
131
+ if (!trimmed) continue;
132
+ let parsed;
133
+ try {
134
+ parsed = JSON.parse(trimmed);
135
+ } catch {
136
+ continue;
137
+ }
138
+ const type = typeof parsed.type === "string" ? parsed.type : "";
139
+ if (INTERNAL_TYPES.has(type)) continue;
140
+ const localId = localIdFor(parsed, trimmed, sessionKey);
141
+ if (nextSeen.has(localId)) continue;
142
+ nextSeen.add(localId);
143
+ const redacted = redactDeep(parsed);
144
+ fitWithinPlaintextBudget(redacted);
145
+ const content = encryptRecord(JSON.stringify(redacted), sessionKey);
146
+ records.push({ localId, content });
147
+ }
148
+ return { records, seen: nextSeen };
149
+ };
150
+
151
+ export {
152
+ decodePublicKey,
153
+ generateSessionKey,
154
+ wrapSessionKey,
155
+ buildTranscriptRecords
156
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getMachineId
3
- } from "./chunk-5NDB3YOE.js";
3
+ } from "./chunk-54ELC7D7.js";
4
4
  import {
5
5
  getPackageVersion
6
6
  } from "./chunk-DINDL2CF.js";
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-2UMNXADU.js";
13
13
  import {
14
14
  isValidApiKey
15
- } from "./chunk-3MCEES6Z.js";
15
+ } from "./chunk-VNMKIJZB.js";
16
16
 
17
17
  // src/session.ts
18
18
  var IDENTITY_PATH = "/api/v1/server/identity";
@@ -232,9 +232,43 @@ var runHermesPythonScript = (python, script, ...args) => {
232
232
  }
233
233
  };
234
234
 
235
+ // src/cli/dry-run.ts
236
+ import { execSync } from "child_process";
237
+ import { rmSync as rmSync2, writeFileSync as writeFileSync2 } from "fs";
238
+ var createGuards = (isDryRun, note) => ({
239
+ write: (path, contents) => {
240
+ if (isDryRun()) return note("rewrite", path);
241
+ writeFileSync2(path, contents, "utf-8");
242
+ },
243
+ remove: (path, options = {}) => {
244
+ if (isDryRun()) return note("remove ", path);
245
+ rmSync2(path, { recursive: true, force: options.force ?? false });
246
+ },
247
+ exec: (command, options, describe) => {
248
+ if (isDryRun()) return note("run ", describe);
249
+ execSync(command, options);
250
+ }
251
+ });
252
+ var describeService = (effects) => {
253
+ if (effects.controlMode === "off") return "skip the phone-start background service (--control off)";
254
+ const where = effects.serviceDefinitionPath ?? "the phone-start service definition";
255
+ const condition = effects.controlMode === "on" ? "" : ", when a supported agent and a service manager are present";
256
+ return `write ${where} and register it with the OS${condition}`;
257
+ };
258
+ var describeSetupSideEffects = (effects) => [
259
+ `run npm install -g @pushary/agent-hooks@${effects.version} (the hooks run from the global copy; up to two minutes)`,
260
+ `write ${effects.configFile} (the API key, mode 600)`,
261
+ effects.rcPath ? `edit ${effects.rcPath} (export PUSHARY_API_KEY)` : "print the export line for your shell, since no rc file was found",
262
+ describeService(effects),
263
+ "ask Add Pushary instructions to this project's CLAUDE.md/AGENTS.md? (default no)",
264
+ "ask Alias claude to pushary claude? (default no)"
265
+ ];
266
+
235
267
  export {
236
268
  isHermesConfigReceipt,
237
269
  HERMES_CONFIG_SCRIPT,
238
270
  resolveHermesPython,
239
- runHermesPythonScript
271
+ runHermesPythonScript,
272
+ createGuards,
273
+ describeSetupSideEffects
240
274
  };
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  PRETOOLUSE_HANDLED_TOOLS,
3
3
  PRETOOLUSE_PHONE_ANSWERED_TOOLS
4
- } from "./chunk-KVHP5ZME.js";
4
+ } from "./chunk-2LAHXHBR.js";
5
5
  import {
6
6
  defersToNativeMode
7
- } from "./chunk-GKPURU7P.js";
7
+ } from "./chunk-I463AEG3.js";
8
8
  import {
9
9
  isGatingMoment,
10
10
  recordKeylessMoment
11
- } from "./chunk-FCUUVHTS.js";
11
+ } from "./chunk-VHWCVD42.js";
12
12
  import {
13
13
  denyReasonFrom,
14
14
  isDeferAnswer
@@ -19,8 +19,9 @@ import {
19
19
  readLastPrompt,
20
20
  readLastUserPrompt,
21
21
  repoKeyFor,
22
+ settleQuestionsForToolUse,
22
23
  throttlePass
23
- } from "./chunk-OADGBOP7.js";
24
+ } from "./chunk-TDZFPMSZ.js";
24
25
  import {
25
26
  DEFAULT_SESSION,
26
27
  askUser,
@@ -28,7 +29,7 @@ import {
28
29
  pollForAnswer,
29
30
  savePendingQuestion,
30
31
  sendNotification
31
- } from "./chunk-JHJHCMAF.js";
32
+ } from "./chunk-FXEVRLHC.js";
32
33
  import {
33
34
  UNNAMED_ACTION,
34
35
  deriveAction,
@@ -37,10 +38,10 @@ import {
37
38
  deriveToolTarget,
38
39
  describeToolCall,
39
40
  scopePathFor
40
- } from "./chunk-JVZX5YRJ.js";
41
+ } from "./chunk-L4E2BIJ2.js";
41
42
  import {
42
43
  getMachineId
43
- } from "./chunk-5NDB3YOE.js";
44
+ } from "./chunk-54ELC7D7.js";
44
45
  import {
45
46
  getApiKey,
46
47
  getBaseUrl
@@ -52,10 +53,12 @@ import {
52
53
  effectiveWaitSeconds,
53
54
  hookWaitClamped,
54
55
  hookWaitDeadline,
56
+ isPusharyOwnTool,
55
57
  parseAgentQuestionAnswers,
56
58
  parseAgentQuestions,
57
- resolveGate
58
- } from "./chunk-3MCEES6Z.js";
59
+ resolveGate,
60
+ stoppedOutput
61
+ } from "./chunk-VNMKIJZB.js";
59
62
 
60
63
  // src/decision-episode.ts
61
64
  var EPISODE_PATH = "/api/agent/decision-episode";
@@ -88,6 +91,7 @@ var allow = () => claudePreToolUseOutput("allow");
88
91
  var deny = (reason) => claudePreToolUseOutput("deny", reason);
89
92
  var allowWithInput = (updatedInput) => claudePreToolUseOutput("allow", void 0, updatedInput);
90
93
  var ask = (reason) => claudePreToolUseOutput("ask", reason);
94
+ var halted = (reason) => stoppedOutput(deny(reason), reason);
91
95
  var storedWaitDeadline = (result, requestedDeadline) => {
92
96
  const stored = result.waitEndsAt ? Date.parse(result.waitEndsAt) : Number.NaN;
93
97
  return Number.isFinite(stored) ? Math.min(stored, requestedDeadline) : requestedDeadline;
@@ -148,7 +152,7 @@ var handlePushOnly = async (apiKey, description, projectName, timeoutSeconds, ti
148
152
  return answer.value === "yes" ? allow() : deny(denyReasonFrom(answer.value, answer.note));
149
153
  }
150
154
  if (timeoutAction === "wait" || clampCut) {
151
- savePendingQuestion(sessionId || DEFAULT_SESSION, result.correlationId);
155
+ savePendingQuestion(sessionId || DEFAULT_SESSION, result.correlationId, decision.toolUseId);
152
156
  return ask(timeoutAction === "wait" ? "Still waiting on your phone. Answer here, or on your phone and it will be applied on the next step." : "This step cannot wait any longer. Answer here, or on your phone and it will be applied on the next step.");
153
157
  }
154
158
  switch (timeoutAction) {
@@ -157,7 +161,7 @@ var handlePushOnly = async (apiKey, description, projectName, timeoutSeconds, ti
157
161
  case "deny":
158
162
  return deny("No response within timeout");
159
163
  default:
160
- savePendingQuestion(sessionId || DEFAULT_SESSION, result.correlationId);
164
+ savePendingQuestion(sessionId || DEFAULT_SESSION, result.correlationId, decision.toolUseId);
161
165
  return ask("No push response, asking in terminal");
162
166
  }
163
167
  };
@@ -201,7 +205,7 @@ var handlePushFirst = async (apiKey, description, projectName, pushFirstSeconds,
201
205
  signals.humanDecision = true;
202
206
  return answer.value === "yes" ? allow() : deny(denyReasonFrom(answer.value, answer.note));
203
207
  }
204
- savePendingQuestion(sessionId || DEFAULT_SESSION, result.correlationId);
208
+ savePendingQuestion(sessionId || DEFAULT_SESSION, result.correlationId, decision.toolUseId);
205
209
  return ask("Sent as push notification. You can also approve here.");
206
210
  };
207
211
  var handleNotifyOnly = async (apiKey, description, projectName, sessionId, machineId) => {
@@ -359,7 +363,7 @@ var askAsOneCard = async (apiKey, input, parsed, projectName, deadline) => {
359
363
  const answer = returnedAnswer(result) ?? await pollForAnswer(apiKey, result.correlationId, storedWaitDeadline(result, deadline));
360
364
  const values = answer.answered && answer.value ? parseAgentQuestionAnswers(parsed, answer.value) : null;
361
365
  if (!values || isDeferAnswer(answer.value)) {
362
- savePendingQuestion(input.session_id || DEFAULT_SESSION, result.correlationId);
366
+ savePendingQuestion(input.session_id || DEFAULT_SESSION, result.correlationId, input.tool_use_id);
363
367
  return void 0;
364
368
  }
365
369
  return values;
@@ -400,14 +404,15 @@ var askQuestionByQuestion = async (apiKey, input, parsed, projectName, deadline)
400
404
  })) : null;
401
405
  const value = values?.[question.question];
402
406
  if (!value || isDeferAnswer(answer.value)) {
403
- savePendingQuestion(input.session_id || DEFAULT_SESSION, result.correlationId);
407
+ savePendingQuestion(input.session_id || DEFAULT_SESSION, result.correlationId, input.tool_use_id);
404
408
  return void 0;
405
409
  }
406
410
  answers[question.question] = value;
407
411
  }
408
412
  return answers;
409
413
  };
410
- var handleAskUserQuestion = async (apiKey, input) => {
414
+ var handleAskUserQuestion = async (apiKey, input, modeState) => {
415
+ if (modeState.askHandoff) return void 0;
411
416
  const parsed = parseQuestions(input.tool_input ?? {});
412
417
  if (!parsed) return void 0;
413
418
  const projectName = basename(input.cwd ?? process.cwd());
@@ -452,7 +457,7 @@ var handleExitPlanMode = async (apiKey, input) => {
452
457
  const answer = returnedAnswer(result) ?? await pollForAnswer(apiKey, result.correlationId, storedWaitDeadline(result, deadline));
453
458
  const value = answer.answered ? (answer.value ?? "").trim() : "";
454
459
  if (!value || isDeferAnswer(answer.value)) {
455
- savePendingQuestion(input.session_id || DEFAULT_SESSION, result.correlationId);
460
+ savePendingQuestion(input.session_id || DEFAULT_SESSION, result.correlationId, input.tool_use_id);
456
461
  return void 0;
457
462
  }
458
463
  if (value === PLAN_APPROVE) return allow();
@@ -487,7 +492,7 @@ var claudeGateInput = (modeState, config, input) => {
487
492
  };
488
493
  };
489
494
  var handlePreToolUse = async (input) => {
490
- if (input.tool_name.startsWith("mcp__pushary__")) return void 0;
495
+ if (isPusharyOwnTool(input.tool_name)) return void 0;
491
496
  let apiKey;
492
497
  try {
493
498
  apiKey = getApiKey();
@@ -498,10 +503,10 @@ var handlePreToolUse = async (input) => {
498
503
  const modeState = await fetchModeState(apiKey, input.session_id);
499
504
  const policy = await getPolicy(apiKey, modeState.policyVersion, "claude_code", true, input.session_id);
500
505
  const verdict = resolveGate(claudeGateInput(modeState, policy, input));
501
- if (verdict.kind === "kill") return deny(verdict.reason);
506
+ if (verdict.kind === "kill") return halted(verdict.reason);
502
507
  if (verdict.kind === "deny") return deny(verdict.reason);
503
508
  if (input.tool_name === "AskUserQuestion") {
504
- return handleAskUserQuestion(apiKey, input);
509
+ return handleAskUserQuestion(apiKey, input, modeState);
505
510
  }
506
511
  if (input.tool_name === "ExitPlanMode") {
507
512
  return handleExitPlanMode(apiKey, input);
@@ -528,6 +533,7 @@ var handlePreToolUse = async (input) => {
528
533
  };
529
534
  var permReqAllow = (updatedInput) => claudePermissionRequestOutput("allow", void 0, updatedInput);
530
535
  var permReqDeny = (message) => claudePermissionRequestOutput("deny", message);
536
+ var permReqHalted = (reason) => stoppedOutput(permReqDeny(reason), reason);
531
537
  var toPermissionRequestOutput = (hookOutput) => {
532
538
  if (!hookOutput) return void 0;
533
539
  const d = hookOutput.hookSpecificOutput;
@@ -540,7 +546,7 @@ var handlePermissionRequest = async (input) => {
540
546
  const reclaimDeferredExec = !PRETOOLUSE_PHONE_ANSWERED_TOOLS.includes(input.tool_name) && shouldDeferToNativeMode(input.permission_mode, input.tool_name);
541
547
  if (!reclaimDeferredExec) return void 0;
542
548
  }
543
- if (input.tool_name.startsWith("mcp__pushary__")) return void 0;
549
+ if (isPusharyOwnTool(input.tool_name)) return void 0;
544
550
  let apiKey;
545
551
  try {
546
552
  apiKey = getApiKey();
@@ -553,7 +559,7 @@ var handlePermissionRequest = async (input) => {
553
559
  const verdict = resolveGate(claudeGateInput(modeState, policy, input));
554
560
  switch (verdict.kind) {
555
561
  case "kill":
556
- return permReqDeny(verdict.reason);
562
+ return permReqHalted(verdict.reason);
557
563
  case "allow":
558
564
  return permReqAllow();
559
565
  case "deny":
@@ -577,7 +583,7 @@ var automodeRetryEnabled = () => {
577
583
  return flag === "1" || flag === "true";
578
584
  };
579
585
  var handlePermissionDenied = async (input) => {
580
- if (input.tool_name.startsWith("mcp__pushary__")) return void 0;
586
+ if (isPusharyOwnTool(input.tool_name)) return void 0;
581
587
  let apiKey;
582
588
  try {
583
589
  apiKey = getApiKey();
@@ -587,6 +593,7 @@ var handlePermissionDenied = async (input) => {
587
593
  try {
588
594
  const projectName = basename(input.cwd ?? process.cwd());
589
595
  const sessionKey = input.session_id || DEFAULT_SESSION;
596
+ await settleQuestionsForToolUse(sessionKey, input.tool_use_id);
590
597
  if (!throttlePass(`permdenied:${sessionKey}:${input.tool_name}`, PERMISSION_DENIED_WINDOW_MS)) return void 0;
591
598
  const mode = await fetchModeState(apiKey, input.session_id).catch(() => null);
592
599
  if (mode?.kill || mode?.mode === "terminal_only") return void 0;
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  detectClaudeVersion
3
- } from "./chunk-NBRM3FMD.js";
3
+ } from "./chunk-H2QZRQR2.js";
4
4
  import {
5
5
  claudeWired,
6
6
  codexWired,
7
7
  geminiWired
8
- } from "./chunk-NESKLV6R.js";
8
+ } from "./chunk-DZDI62LY.js";
9
9
  import {
10
10
  GEMINI_HOOK_BINARY,
11
11
  addClaudeMcpServer,
@@ -14,10 +14,10 @@ import {
14
14
  addPusharyHooks,
15
15
  addPusharyToolPermissions,
16
16
  hasGeminiHooks
17
- } from "./chunk-6V7ZDH3A.js";
17
+ } from "./chunk-GL3FFM7A.js";
18
18
  import {
19
19
  guardBinary
20
- } from "./chunk-VF3RTVWY.js";
20
+ } from "./chunk-EZIEXHYM.js";
21
21
  import {
22
22
  resolveGlobalBinDir,
23
23
  resolveGlobalBinary
@@ -32,7 +32,7 @@ import {
32
32
  codexHooksJson,
33
33
  hasCodexHooks,
34
34
  vscodePluginMcp
35
- } from "./chunk-OVEGEQSB.js";
35
+ } from "./chunk-KUZWXPUS.js";
36
36
  import {
37
37
  readJsonSafe
38
38
  } from "./chunk-4LL6LG5X.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  renderCommandHelp
3
- } from "./chunk-RLQWNEPM.js";
3
+ } from "./chunk-43GMYSS4.js";
4
4
  import {
5
5
  getPackageVersion
6
6
  } from "./chunk-DINDL2CF.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  HOOK_BUDGETS,
3
3
  OPENCODE_APPROVAL_EVENT
4
- } from "./chunk-3MCEES6Z.js";
4
+ } from "./chunk-VNMKIJZB.js";
5
5
 
6
6
  // src/opencode-plugin.ts
7
7
  var OPENCODE_PLUGIN_MARKER = "pushary-opencode-plugin w1";