@pushary/agent-hooks 1.9.149 → 1.9.151

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 (155) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/data/cursor-plugin/.cursor-plugin/plugin.json +1 -1
  3. package/data/cursor-plugin/CHANGELOG.md +7 -0
  4. package/data/cursor-plugin/scripts/redaction.mjs +6 -1
  5. package/data/openclaw-plugin/README.md +39 -2
  6. package/data/openclaw-plugin/dist/approval-hook.js +8 -4
  7. package/data/openclaw-plugin/dist/approval-question.js +100 -33
  8. package/data/openclaw-plugin/dist/command-preview.js +65 -0
  9. package/data/openclaw-plugin/dist/file-change-preview.js +109 -0
  10. package/data/openclaw-plugin/dist/gate-result.js +11 -4
  11. package/data/openclaw-plugin/dist/parameter-redaction.js +28 -0
  12. package/data/openclaw-plugin/dist/protected-writes.js +18 -4
  13. package/data/openclaw-plugin/dist/redaction.js +6 -1
  14. package/data/openclaw-plugin/dist/settings.js +7 -1
  15. package/data/openclaw-plugin/dist/visible-text.js +5 -0
  16. package/data/openclaw-plugin/openclaw.plugin.json +1 -1
  17. package/data/openclaw-plugin/package.json +1 -1
  18. package/data/vscode-plugin/.claude-plugin/plugin.json +1 -1
  19. package/data/vscode-plugin/CHANGELOG.md +9 -0
  20. package/data/vscode-plugin/scripts/redaction.mjs +6 -1
  21. package/dist/{api-H7H75ARS.js → api-GHPLREAU.js} +11 -11
  22. package/dist/bin/pushary-audit.js +3 -3
  23. package/dist/bin/pushary-bell-hook.js +28 -28
  24. package/dist/bin/pushary-bell.js +10 -10
  25. package/dist/bin/pushary-claude.js +27 -27
  26. package/dist/bin/pushary-clean.js +36 -36
  27. package/dist/bin/pushary-codex-bridge.js +23 -23
  28. package/dist/bin/pushary-codex-hook.js +35 -35
  29. package/dist/bin/pushary-codex-session.js +8 -8
  30. package/dist/bin/pushary-codex.js +16 -16
  31. package/dist/bin/pushary-connect.js +32 -32
  32. package/dist/bin/pushary-cowork.js +5 -5
  33. package/dist/bin/pushary-daemon.js +44 -44
  34. package/dist/bin/pushary-disconnect.js +28 -28
  35. package/dist/bin/pushary-display-hook.js +33 -21
  36. package/dist/bin/pushary-doctor.js +44 -44
  37. package/dist/bin/pushary-elicitation-hook.js +28 -28
  38. package/dist/bin/pushary-gemini-bridge.js +17 -17
  39. package/dist/bin/pushary-gemini-hook.js +32 -32
  40. package/dist/bin/pushary-hook.js +35 -35
  41. package/dist/bin/pushary-login.js +21 -21
  42. package/dist/bin/pushary-logout.js +27 -27
  43. package/dist/bin/pushary-mcp.js +12 -12
  44. package/dist/bin/pushary-mode.js +15 -15
  45. package/dist/bin/pushary-notification-hook.js +27 -27
  46. package/dist/bin/pushary-opencode-hook.js +31 -31
  47. package/dist/bin/pushary-permission-denied-hook.js +35 -35
  48. package/dist/bin/pushary-permission-hook.js +35 -35
  49. package/dist/bin/pushary-post-hook.js +28 -28
  50. package/dist/bin/pushary-prompt-hook.js +27 -27
  51. package/dist/bin/pushary-session-end-hook.js +27 -27
  52. package/dist/bin/pushary-session-start-hook.js +37 -37
  53. package/dist/bin/pushary-setup.js +54 -53
  54. package/dist/bin/pushary-stats.js +5 -5
  55. package/dist/bin/pushary-status.js +33 -33
  56. package/dist/bin/pushary-stop-hook.js +27 -27
  57. package/dist/bin/pushary-stopfailure-hook.js +27 -27
  58. package/dist/bin/pushary-suggestions.js +15 -15
  59. package/dist/bin/pushary-transcript-register.js +17 -17
  60. package/dist/bin/pushary-transcripts.js +25 -25
  61. package/dist/bin/pushary-upgrade.js +42 -42
  62. package/dist/bin/pushary-wait.js +15 -15
  63. package/dist/bin/pushary.js +7 -7
  64. package/dist/{chunk-D3QT4S7U.js → chunk-3MXI37MS.js} +4 -4
  65. package/dist/{chunk-FQLS37AX.js → chunk-3TUSMGHE.js} +1 -1
  66. package/dist/{chunk-5IG3VPHT.js → chunk-3XIHKIDX.js} +4 -4
  67. package/dist/{chunk-4L2IYNLC.js → chunk-46IYOPZH.js} +1 -1
  68. package/dist/{chunk-NLED3JGR.js → chunk-4UDGVO6A.js} +1 -1
  69. package/dist/{chunk-F6ESGEWU.js → chunk-4ZH2PXDA.js} +1 -1
  70. package/dist/{chunk-3AAQJ75F.js → chunk-53Y4QQNF.js} +5 -5
  71. package/dist/{chunk-RYDDLS62.js → chunk-5D57GAKF.js} +3 -3
  72. package/dist/{chunk-RMBY7JGO.js → chunk-5TMW2X5I.js} +1 -1
  73. package/dist/{chunk-X4OEGFOG.js → chunk-6RMBTFDF.js} +3 -3
  74. package/dist/{chunk-T3CMGGNW.js → chunk-7357Q746.js} +1 -1
  75. package/dist/{chunk-UJUGFLVF.js → chunk-7FPKT5QJ.js} +5 -5
  76. package/dist/{chunk-KXNAB76Z.js → chunk-7L6IP3JA.js} +2 -2
  77. package/dist/{chunk-3OPXQK4D.js → chunk-7XFEV7ML.js} +5 -5
  78. package/dist/{chunk-3WD3BEPB.js → chunk-A3EV4C34.js} +2 -2
  79. package/dist/{chunk-6HO36P3A.js → chunk-ACC4YXJS.js} +1 -1
  80. package/dist/{chunk-PH3MVQCQ.js → chunk-AIKQFV6C.js} +4 -4
  81. package/dist/{chunk-6YX3VB5P.js → chunk-AWC7MXLX.js} +6 -6
  82. package/dist/{chunk-WQJ5NJ35.js → chunk-AYFOZBTD.js} +1 -1
  83. package/dist/{chunk-ZIPPDZ5B.js → chunk-BAH4LZL3.js} +5 -5
  84. package/dist/{chunk-JUEQUYAT.js → chunk-BANZ4GGS.js} +2 -2
  85. package/dist/{chunk-DHCJDYBT.js → chunk-BPSQLKTG.js} +6 -6
  86. package/dist/{chunk-RWTH5RYA.js → chunk-BRXPFM3U.js} +2 -2
  87. package/dist/{chunk-WQEJCDMR.js → chunk-C2JMTH45.js} +2 -2
  88. package/dist/{chunk-R2JRRCZK.js → chunk-CVQTLCVS.js} +1 -1
  89. package/dist/{chunk-M7HJZ7HO.js → chunk-DHP6SWVH.js} +3 -3
  90. package/dist/{chunk-KWJJYZ3T.js → chunk-DNK4E5CE.js} +4 -4
  91. package/dist/{chunk-QTQRQZIU.js → chunk-DQKT5KK5.js} +4 -4
  92. package/dist/{chunk-YWSIN7IH.js → chunk-DYUK6HYH.js} +1 -1
  93. package/dist/{chunk-ABTQG6XU.js → chunk-E5YEKJOM.js} +1 -1
  94. package/dist/{chunk-LC53HRZ6.js → chunk-E75OHUWM.js} +1 -1
  95. package/dist/{chunk-Q7GZKNMH.js → chunk-FHPLLUAZ.js} +1 -1
  96. package/dist/{chunk-JSZ6LKX5.js → chunk-FSEOIGZX.js} +13 -12
  97. package/dist/{chunk-HEOBF5H6.js → chunk-H4MHGLEB.js} +3 -3
  98. package/dist/{chunk-ZCB5SCYM.js → chunk-HQ3RFANL.js} +2 -2
  99. package/dist/{chunk-AQ7L2E2U.js → chunk-HY4GEW3T.js} +28 -21
  100. package/dist/{chunk-3T7RA7WJ.js → chunk-I3CN7BGN.js} +2 -2
  101. package/dist/{chunk-ENRL4WFD.js → chunk-I6DLNMUM.js} +4 -4
  102. package/dist/{chunk-NHZV2H63.js → chunk-ILEO4YWM.js} +1 -1
  103. package/dist/{chunk-A3URJPYH.js → chunk-IPRQFNPG.js} +1 -1
  104. package/dist/{chunk-UAHBSOO4.js → chunk-J6LZ4G5G.js} +2 -2
  105. package/dist/{chunk-ZOATPL53.js → chunk-JGYQ72A7.js} +4 -4
  106. package/dist/{chunk-QSZYHL7Z.js → chunk-JJKPQSEE.js} +2 -2
  107. package/dist/{chunk-O5ARO3JM.js → chunk-K3ORQ3KY.js} +13 -4
  108. package/dist/{chunk-S3MEI2D2.js → chunk-KAZ37TWD.js} +5 -5
  109. package/dist/{chunk-2CVRVHUQ.js → chunk-LRK2F63A.js} +8 -8
  110. package/dist/{chunk-X4OQ5UMH.js → chunk-NP6QILOY.js} +5 -5
  111. package/dist/{chunk-6RYJ3XCD.js → chunk-NPNBR4FS.js} +5 -5
  112. package/dist/{chunk-T4PX3DRF.js → chunk-NQUE54GA.js} +1 -1
  113. package/dist/{chunk-CMTDMZPV.js → chunk-NRMMXX62.js} +2 -2
  114. package/dist/{chunk-XSBW6TUH.js → chunk-OBIUHAXG.js} +2 -2
  115. package/dist/{chunk-35IODIBL.js → chunk-ODYF7VZZ.js} +1 -1
  116. package/dist/{chunk-YTD7RV6F.js → chunk-OZD5FIFS.js} +3 -3
  117. package/dist/{chunk-XZGQZDFP.js → chunk-P3E26UO5.js} +6 -6
  118. package/dist/{chunk-CABBLJD5.js → chunk-P3RRAH6J.js} +3 -3
  119. package/dist/{chunk-43NHQUCY.js → chunk-P6GCPJDQ.js} +3 -3
  120. package/dist/{chunk-H6FFNTSR.js → chunk-PS3O6LS2.js} +6 -6
  121. package/dist/{chunk-BP5HLKR6.js → chunk-PYH3KFLI.js} +12 -12
  122. package/dist/{chunk-MT4GBXLM.js → chunk-R2VVMSGM.js} +5 -5
  123. package/dist/{chunk-CIRTRWHM.js → chunk-RJAQ2447.js} +18 -7
  124. package/dist/{chunk-NRPQUU3D.js → chunk-S263JK6K.js} +2 -2
  125. package/dist/{chunk-KP6ERYOA.js → chunk-TQXKJX7X.js} +8 -8
  126. package/dist/{chunk-ZX2O66NS.js → chunk-TRDJICC7.js} +3 -3
  127. package/dist/{chunk-26TXJ35O.js → chunk-USN3OOHD.js} +19 -18
  128. package/dist/{chunk-CBIS7IYQ.js → chunk-WQ66RQRF.js} +5 -5
  129. package/dist/{chunk-CDQOARIF.js → chunk-WQVRDVMJ.js} +3 -3
  130. package/dist/{chunk-CU5SYUMK.js → chunk-WY4CM6TO.js} +3 -3
  131. package/dist/{chunk-CAHULQIO.js → chunk-XJLCZ24Y.js} +1 -1
  132. package/dist/{chunk-5HAA7C4X.js → chunk-XU45NUAV.js} +10 -10
  133. package/dist/{chunk-TXXAQRX4.js → chunk-XWMVKK54.js} +1 -1
  134. package/dist/{chunk-MUTMXSQZ.js → chunk-YUYBMCKF.js} +3 -3
  135. package/dist/{chunk-2VPRLAKF.js → chunk-YYEYPA3S.js} +4 -4
  136. package/dist/{chunk-VPADWVYD.js → chunk-ZBZ7CRGD.js} +1 -1
  137. package/dist/{chunk-MUSINFEU.js → chunk-ZLHPTXWU.js} +5 -5
  138. package/dist/{chunk-PUTX5BBE.js → chunk-ZMEI3EG4.js} +3 -3
  139. package/dist/{chunk-PVBDITRS.js → chunk-ZSX4XN6C.js} +5 -5
  140. package/dist/{chunk-DLPI45DF.js → chunk-ZUN37EG2.js} +6 -6
  141. package/dist/{codex-app-cards-switch-BCM547E6.js → codex-app-cards-switch-U77ZM22P.js} +11 -11
  142. package/dist/{codex-card-routing-222EKZJR.js → codex-card-routing-3L4XXUCK.js} +2 -2
  143. package/dist/{codex-desktop-launch-6AFOLMZ7.js → codex-desktop-launch-KRLBST55.js} +1 -1
  144. package/dist/{codex-session-launch-73EQE6IL.js → codex-session-launch-6LMMSNLA.js} +20 -20
  145. package/dist/{config-GWNPGS47.js → config-5YEZFF26.js} +3 -3
  146. package/dist/{global-upgrade-VRF6OSSU.js → global-upgrade-EWBY6BD5.js} +9 -9
  147. package/dist/{identity-PQIM7R2N.js → identity-D3SYIS5Z.js} +4 -4
  148. package/dist/{live-capabilities-G3LMKZUB.js → live-capabilities-QUNHPUFR.js} +4 -4
  149. package/dist/{paths-TFGIP5PU.js → paths-VI5KNBOY.js} +3 -3
  150. package/dist/{reapply-3IRAI6JF.js → reapply-AFG7K4KS.js} +30 -30
  151. package/dist/src/index.js +34 -34
  152. package/dist/{upgrade-lock-2G7ANYYO.js → upgrade-lock-COPTGES4.js} +4 -4
  153. package/dist/{usage-K3EGYCSU.js → usage-4367CHW4.js} +3 -3
  154. package/package.json +1 -1
  155. package/data/cursor-plugin/scripts/pushary-gate.test.mjs +0 -150
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.9.151
4
+
5
+ - This CLI carries the OpenClaw plugin 0.1.3. An `exec` approval now shows the environment the call sets and every other parameter, such as `host`, `node`, `security` and `ask`, before the command, and the question names the environment variables. Before, it showed only the command, so a `git status` with `GIT_CONFIG_*` variables could run another command after one yes. Values named like a credential are redacted.
6
+ - The plugin asks before a `write`, `edit` or `apply_patch` into the workspace `.openclaw` folder, for every spelling of the path. OpenClaw loads plugins from `<workspace>/.openclaw/extensions` before the installed ones, so an agent could otherwise put its own plugin with the id `pushary` there and switch off the gate at the next gateway start.
7
+ - The plugin asks before every `sessions_spawn` with `runtime: "acp"`, whose harness runs its own tools where the plugin cannot see them, and before every `nodes` action except its reads, including `run` on a paired machine and `approve` for a new one.
8
+ - The plugin 0.1.2 changes reach setup too. A gated call longer than 4,000 characters once secrets are redacted is blocked instead of being asked about in part. A file change shows the path and the lines it removes and adds. A `.env` file's values are never sent. Hidden characters are shown as codes.
9
+ - `pushary upgrade` tries the OpenClaw plugin reinstall again when OpenClaw refused it the last time. Before, it recorded the new copy as installed before OpenClaw accepted it, so a refused reinstall kept the older plugin until a later CLI carried another one.
10
+ - The editor plugins this CLI carries no longer include their test files.
11
+
12
+ ## 1.9.150
13
+
14
+ - Claude Code: the `PermissionRequest` hook allows Pushary's own tools, under `mcp__pushary__`, the claude.ai Pushary connector (`mcp__claude_ai_Pushary__`) and the Pushary plugin (`mcp__plugin_pushary_pushary__`), without a key and without asking pushary.com. Before, it left `mcp__pushary__` to Claude Code's own prompt and judged the other two like any tool. Claude Code adds your claude.ai connectors to every session, so with this CLI's hooks installed and the connector enabled, its prompt for the connector's `ask_user` could push an approval for Pushary's own question to your phone, and a standing `*` deny refused it. A plugin user, who has no allow rule from setup, would have had the prompt for the agent's own question wait in the terminal while they were away. The `PermissionDenied` hook leaves all three alone. `PreToolUse` is unchanged.
15
+ - Setup and `pushary upgrade` add `mcp__claude_ai_Pushary__*` and `mcp__plugin_pushary_pushary__*` to Claude Code's allowed tools beside `mcp__pushary__*`, so Claude Code does not ask before it calls Pushary under those names either. `pushary clean` and disconnect remove them, and keep a narrower rule of your own such as `mcp__claude_ai_Pushary__ask_user`. Other agents get only `mcp__pushary__*`, as before.
16
+ - Claude Code: an approval route that names one of Pushary's own tools on the claude.ai connector or the plugin exactly, such as `mcp__plugin_pushary_pushary__send_notification`, no longer holds that call in auto mode. Before, `PreToolUse` held it for someone else's answer, and when nobody answered it went back to the terminal prompt. A route that names any other MCP tool holds it as before.
17
+ - Claude Code: the `PreToolUse` entry setup and `pushary upgrade` write for `WebFetch`, `Task` and `Agent` has a 30 second timeout instead of 600. That entry applies only the kill switch and standing denies and never waits for an answer, so a hook that hangs can no longer hold those calls for up to 10 minutes. 30 seconds still covers the Claude Code plugin's cold `npx` start, about 8 seconds, plus the check itself. The `mcp__.*` entry keeps 600 seconds, because an approval route can hold an MCP call. The Mac app's spec and the Claude Code plugin carry the same timeout.
18
+
3
19
  ## 1.9.149
4
20
 
5
21
  - Codex and Gemini sessions started from your phone now check the keys they encrypt transcripts for against the keys this computer already trusts, as every other transcript upload does. Before, they encrypted for whatever keys the server returned. Now, if those keys change, these sessions upload nothing, print the same "Transcript sync stopped" message with the `pushary transcripts trust` step, and resume once the keys match again.
@@ -2,7 +2,7 @@
2
2
  "name": "pushary",
3
3
  "displayName": "Pushary — Control Panel for AI Agents",
4
4
  "description": "Push notifications, human-in-the-loop questions, and permission gating for your AI coding agent. Get a push when a task finishes, answer the agent from your phone, and approve risky commands before they run.",
5
- "version": "0.2.11",
5
+ "version": "0.2.12",
6
6
  "minClientVersions": {
7
7
  "grokbot": "never",
8
8
  "sand": "never"
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.12
4
+
5
+ - The bundled Pushary skill is 0.13.4, from 0.13.2. When you ask the agent to call, phone or ring you if it gets stuck, it asks with `ask_user`. Pushary phones only when the reply includes `phoneCall`, and the agent does not promise a call otherwise. It tells you when the call rings in your own time (`ringsAtLocal`), not the UTC `ringsAt`. While the question is pending it keeps waiting with the same `correlationId`, so a spoken answer arrives like any other.
6
+ - A computer whose key works but has no phone connected pairs one with `npx pushary@latest pair`, which keeps this computer's key. The agent runs it in the background and shows you the link, the QR code and the fingerprint while it waits up to 15 minutes for your phone. The skill used to send it to setup with `--connect app`, which makes a new key.
7
+ - The skill's description is shorter and names "call me if you get stuck" among its triggers.
8
+ - The gate's redaction also hides the credential after `Authorization: Basic`, `Token`, `Negotiate` or `NTLM`, not only the scheme word, so a command that carries one shows `authorization: [redacted]`.
9
+
3
10
  ## 0.2.11
4
11
 
5
12
  - The gate runs on Windows and from a plugin folder whose path has a space or a symlink. Before, it printed nothing there, so Cursor blocked every shell command, MCP call and file edit the gate covers.
@@ -25,7 +25,7 @@ const CUT_OFF_SECRET_SHAPES = {
25
25
  authorizationValue: String.raw `\S+`,
26
26
  credentialAssignment: credentialAssignmentRule(CREDENTIAL_KEY, String.raw `(?:\\[\s\S]|[^"\\])*(?:"|\\?$)`, "[^']*(?:'|$)", String.raw `\S+`),
27
27
  };
28
- const secretRedactionRules = (shapes) => [
28
+ const credentialTokenRules = (shapes) => [
29
29
  { pattern: /\bpk_[A-Za-z0-9_]+\.[A-Za-z0-9_]+/g, replacement: '[redacted]' },
30
30
  { pattern: new RegExp(String.raw `-----BEGIN[A-Z0-9 ]*PRIVATE KEY-----${shapes.privateKeyBody}-----END[A-Z0-9 ]*PRIVATE KEY-----`, 'g'), replacement: '[redacted key]' },
31
31
  { pattern: /\bsk-[A-Za-z0-9_-]{16,}\b/g, replacement: '[redacted]' },
@@ -41,14 +41,19 @@ const secretRedactionRules = (shapes) => [
41
41
  { pattern: /\bxai-[A-Za-z0-9]{16,}\b/g, replacement: '[redacted]' },
42
42
  { pattern: /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, replacement: '[redacted]' },
43
43
  { pattern: new RegExp(String.raw `\b([a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:)${shapes.urlPassword}@`, 'gi'), replacement: '$1[redacted]@' },
44
+ ];
45
+ const secretRedactionRules = (shapes) => [
46
+ ...credentialTokenRules(shapes),
44
47
  { pattern: new RegExp(String.raw `\bbearer${shapes.separator}+[A-Za-z0-9._~+/=-]+`, 'gi'), replacement: 'bearer [redacted]' },
45
48
  { pattern: new RegExp(String.raw `\bauthorization:${shapes.separator}*(?:${AUTHORIZATION_SCHEME}${shapes.separator}+)?${shapes.authorizationValue}`, 'gi'), replacement: 'authorization: [redacted]' },
46
49
  shapes.credentialAssignment,
47
50
  ];
48
51
  export const SECRET_REDACTION_RULES = secretRedactionRules(DISPLAYED_SECRET_SHAPES);
52
+ const CREDENTIAL_TOKEN_RULES = credentialTokenRules(DISPLAYED_SECRET_SHAPES);
49
53
  const CUT_OFF_TEXT_REDACTION_RULES = secretRedactionRules(CUT_OFF_SECRET_SHAPES);
50
54
  const HIGH_ENTROPY_RULE = { pattern: /[A-Za-z0-9+/]{40,}={0,2}/g, replacement: '[redacted]' };
51
55
  const applyRedactionRules = (rules, text) => rules.reduce((acc, rule) => acc.replace(rule.pattern, rule.replacement), text);
52
56
  export const redactSecrets = (text) => applyRedactionRules(SECRET_REDACTION_RULES, text);
57
+ export const containsCredentialToken = (text) => applyRedactionRules(CREDENTIAL_TOKEN_RULES, text) !== text;
53
58
  export const redactSecretsFromContent = (text) => applyRedactionRules(CUT_OFF_TEXT_REDACTION_RULES, text);
54
59
  export const redactSecretsDeep = (text) => redactSecrets(text).replace(HIGH_ENTROPY_RULE.pattern, HIGH_ENTROPY_RULE.replacement);
@@ -6,6 +6,8 @@ It is built for an OpenClaw that runs for you alone, often always on, on a small
6
6
 
7
7
  ## Install
8
8
 
9
+ ### With the Pushary CLI (recommended)
10
+
9
11
  Run the Pushary CLI on the machine that runs OpenClaw, as the user the gateway runs as:
10
12
 
11
13
  ```bash
@@ -33,6 +35,17 @@ If the gateway runs as another user, or as a service without that home folder, p
33
35
  PUSHARY_API_KEY=pk_your_key
34
36
  ```
35
37
 
38
+ ### From ClawHub or npm
39
+
40
+ ```bash
41
+ openclaw plugins install @pushary/openclaw # ClawHub
42
+ openclaw plugins install npm:@pushary/openclaw # npm
43
+ ```
44
+
45
+ Then give it a key. Create one at [pushary.com/dashboard/agent/settings](https://pushary.com/dashboard/agent/settings), add `PUSHARY_API_KEY=pk_your_key` to `~/.openclaw/.env`, connect your phone on the same page, and restart the gateway. Until it has a key, every gated call is blocked and the reason says how to add one. `openclaw plugins update pushary` follows newer releases.
46
+
47
+ Running `pushary setup` later installs the CLI's own copy over a ClawHub or npm install. Both use the plugin id `pushary`, so only one is ever loaded.
48
+
36
49
  ## What it gates
37
50
 
38
51
  - Every `exec` call.
@@ -41,8 +54,10 @@ PUSHARY_API_KEY=pk_your_key
41
54
 
42
55
  - Every `automations` (also called `cron`) action except `status`, `list`, `get`, `runs` and `next_check`. A scheduled job can run a command outside `before_tool_call`, so adding, changing, running or waking one asks.
43
56
  - Every `terminal` action except `read` and `list`. `terminal input` types into a shared operator terminal.
44
- - A `sessions_spawn` with a `cwd` outside the agent's workspace or in its `hooks` folder, or with a `projectId`, `projectGitUrl` or `worktree`. The question names the folder.
45
- - Every `write`, `edit` or `apply_patch` into OpenClaw's own files: anything inside an OpenClaw state directory, `~/.config/openclaw` (where Linux keeps `gateway.env`), `~/.pushary`, the `.env` in the gateway's working folder, the config file set by `OPENCLAW_CONFIG_PATH`, and the launchd and systemd files OpenClaw installs for its gateway. The one exception is the agent's own workspace when it lives inside the state directory, which is OpenClaw's default (`~/.openclaw/workspace`). The workspace `hooks` folder always asks, wherever the workspace is, because OpenClaw can load hooks from it as code. The plugin resolves `~`, `@` references, `file://` paths, relative paths against the agent's workspace, and symlinks before it decides, and a path it cannot resolve asks. Writes anywhere else run without asking.
57
+ - Every `nodes` action except the reads: `status`, `describe`, `pending`, `notify`, `camera_list`, `notifications_list` and the `device_*` reads. `nodes run` runs a command on a paired machine, `approve` pairs a new one, and the camera, screen and location actions take data from it.
58
+ - Every `sessions_spawn` with `runtime: "acp"`. An ACP session runs Codex, Claude Code or another harness, whose own tool calls never reach this plugin, so starting one asks.
59
+ - A `sessions_spawn` with a `cwd` outside the agent's workspace or in its `hooks` or `.openclaw` folder, or with a `projectId`, `projectGitUrl` or `worktree`. The question names the folder.
60
+ - Every `write`, `edit` or `apply_patch` into OpenClaw's own files: anything inside an OpenClaw state directory, `~/.config/openclaw` (where Linux keeps `gateway.env`), `~/.pushary`, the `.env` in the gateway's working folder, the config file set by `OPENCLAW_CONFIG_PATH`, and the launchd and systemd files OpenClaw installs for its gateway. The one exception is the agent's own workspace when it lives inside the state directory, which is OpenClaw's default (`~/.openclaw/workspace`). The workspace `hooks` and `.openclaw` folders always ask, wherever the workspace is, because OpenClaw loads code from them: hooks from `hooks`, and plugins from `.openclaw/extensions`, which it finds before the installed ones. The plugin resolves `~`, `@` references, `file://` paths, relative paths against the agent's workspace, and symlinks before it decides, and a path it cannot resolve asks. Writes anywhere else run without asking.
46
61
 
47
62
  To gate more tools, list their OpenClaw tool ids. The list adds to the defaults above; it never replaces them:
48
63
 
@@ -72,10 +87,31 @@ Ids are read the way OpenClaw names its tools: `bash` means `exec`, `cron` means
72
87
  | The agent was stopped from Pushary | Blocked |
73
88
  | No phone, browser or Slack is connected | Blocked, with a link to connect one |
74
89
  | Pushary cannot be reached, rejects the key or sends a reply the plugin cannot read | Blocked |
90
+ | The call is longer than 4,000 characters once secrets are redacted | Blocked without asking, because Pushary could not show all of it |
75
91
  | Your delivery mode keeps approvals off the phone, or a When away push window passes with no answer | Withdrawn in Pushary and handed to OpenClaw's own approval prompt, which blocks the call when nobody can answer there. On an OpenClaw older than 2026.11.3 the call is blocked instead |
76
92
 
77
93
  A missing answer never becomes an approval. A plugin error or timeout blocks the call: OpenClaw fails closed when a `before_tool_call` hook throws or runs out of time, and the plugin turns its own errors into a block rather than relying on that.
78
94
 
95
+ ## What is sent to Pushary
96
+
97
+ For each gated call, the plugin sends one `ask_user` request to `https://pushary.com/api/mcp/mcp`, with your key in the `Authorization` header. It holds:
98
+
99
+ - **The question.** For a command, its first 160 characters, with a note when the command is longer. For a file change, the path. This is what the notification shows; open the request to read the whole call before you answer.
100
+ - **The full call.** For `exec`, the whole command, and before it the environment it sets and every other parameter, such as `host`, `node`, `security` and `ask`. The question names the environment variables. For `write`, `edit` and `apply_patch`, the path, the number of lines or changes, and the lines removed and added. For every other tool, its parameters as JSON.
101
+ - **Where it comes from.** The agent name (`OpenClaw`, or `OpenClaw - <agent id>`), the tool name, the working directory and whether it asked for elevated mode, the OpenClaw session id or key (hashed when it is longer than 128 characters), a machine id (the one `pushary setup` saved in `~/.pushary/machine-id`, or else a hash of the host name), a random request id, and when the plugin stops waiting.
102
+
103
+ Before anything is sent, the plugin removes what it can recognise as a secret:
104
+
105
+ - Key and token formats it knows: Pushary keys, `sk-` keys (OpenAI, Anthropic), Stripe, GitHub, GitLab, Slack, Google, AWS access key ids, npm, xAI and JWTs, plus private key blocks and long base64-like strings of 40 or more characters.
106
+ - Passwords in URLs, `Bearer` and `Authorization` values, and the value of anything named like a password, token, secret, API key, access key, client secret or private key. In JSON this holds at any depth, whatever the value.
107
+ - Every value in a `.env` file (`.env`, `.env.*` or a name ending in `.env`, such as `gateway.env`). Only the variable names are sent.
108
+
109
+ Redaction works from these patterns. A secret in a command that matches none of them, such as a password with spaces passed to a flag of its own, is sent as written. The plugin leaves the rest of a command as it is so you can see what will run.
110
+
111
+ Characters you could not see, such as zero-width spaces, text direction overrides and terminal escape codes, are sent as visible codes like `\u{202E}`.
112
+
113
+ While it waits, the plugin sends only the question id, to check for your answer or to withdraw the question. It sends no analytics and talks to no other host.
114
+
79
115
  ## How long it waits
80
116
 
81
117
  The plugin asks OpenClaw for a five minute `before_tool_call` budget and stops waiting ten seconds before it, so it has time to withdraw the question. If you set `plugins.entries.pushary.hooks.timeouts.before_tool_call` or `hooks.timeoutMs`, the plugin reads that value and ends its wait before it instead.
@@ -99,6 +135,7 @@ Clean uninstalls the plugin and puts back the `plugins.entries.pushary` settings
99
135
 
100
136
  - The gate covers the tools listed above and any you add. It does not see other tools: for example the file-transfer plugin's `file_write` is not gated unless you add it to `gatedTools`.
101
137
  - ACP sessions set to approve everything, and CLI backends, run tools inside the external harness. Those tool calls never reach `before_tool_call`, so the plugin cannot gate them.
138
+ - A command that runs a script file shows the command, not what the script contains. A call longer than 4,000 characters is blocked, so an agent may split it this way: read the script before you approve it.
102
139
  - This is an approval layer, not a sandbox. Pair it with OpenClaw's own sandboxing and `tools.fs.workspaceOnly`.
103
140
  - The plugin talks only to `https://pushary.com` and `https://www.pushary.com`, the hosts the CLI uses. Any other `PUSHARY_BASE_URL` blocks every gated call, so a changed setting cannot point it at a server that always says yes.
104
141
  - The plugin is not told which folder a tool runs in. It resolves a relative path against the agent's workspace, any folder inside it, and the gateway's working folder, and a spawned session in any other folder asks first. A run started some other way in a folder inside OpenClaw's state is not covered.
@@ -1,7 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
- import { approvalQuestionFor } from './approval-question.js';
2
+ import { approvalPreviewFor } from './approval-question.js';
3
3
  import { runApprovalGate } from './gate.js';
4
- import { notConnectedResultFor, openClawResultFor } from './gate-result.js';
4
+ import { notConnectedResultFor, openClawResultFor, tooLongToReviewResultFor } from './gate-result.js';
5
5
  import { holdMsWithin, hookBudgetFrom, REQUESTED_HOOK_TIMEOUT_MS } from './hook-budget.js';
6
6
  import { BEFORE_TOOL_CALL_HOOK, } from './host-api.js';
7
7
  import { handsBackToTheHost, hostSupportFrom, MIN_HOST_VERSION } from './host-version.js';
@@ -20,10 +20,14 @@ export const createApprovalGateHandler = (options, environment) => async (event,
20
20
  if (!needsApproval(options.settings, event) && !reachesOpenClawState)
21
21
  return undefined;
22
22
  const agentName = askingAgentName(context.agentId);
23
- const question = approvalQuestionFor(event, agentName);
23
+ const preview = approvalPreviewFor(event, agentName);
24
24
  const reading = environment.readConnection();
25
+ const toolName = preview.kind === 'reviewable' ? preview.question.toolName : preview.toolName;
25
26
  if (reading.kind !== 'ready')
26
- return notConnectedResultFor(reading.kind, question.toolName);
27
+ return notConnectedResultFor(reading.kind, toolName);
28
+ if (preview.kind === 'too_long')
29
+ return tooLongToReviewResultFor(toolName, preview.length);
30
+ const { question } = preview;
27
31
  const sessionId = sessionIdOf(context);
28
32
  const outcome = await runApprovalGate({
29
33
  question,
@@ -1,6 +1,10 @@
1
+ import { commandPreviewOf } from './command-preview.js';
2
+ import { fileChangePreviewOf } from './file-change-preview.js';
3
+ import { serializedWithCredentialsRedacted } from './parameter-redaction.js';
1
4
  import { redactSecrets, redactSecretsDeep } from './redaction.js';
2
- import { SESSIONS_SPAWN_TOOL, SPAWN_FOLDER_PARAMETER } from './protected-writes.js';
3
- import { AGENT_LABEL } from './settings.js';
5
+ import { SESSIONS_SPAWN_TOOL, SPAWN_FOLDER_PARAMETER, startsAnAcpSession } from './protected-writes.js';
6
+ import { AGENT_LABEL, hostToolId } from './settings.js';
7
+ import { withHiddenCharactersShown } from './visible-text.js';
4
8
  export const QUESTION_SUMMARY_MAX = 160;
5
9
  export const CONTEXT_MAX = 500;
6
10
  export const ACTION_MAX = 500;
@@ -9,58 +13,121 @@ export const TOOL_TARGET_MAX = 80;
9
13
  export const TOOL_NAME_MAX = 100;
10
14
  export const APPROVAL_TITLE_MAX = 80;
11
15
  export const APPROVAL_DESCRIPTION_MAX = 512;
12
- const COMMAND_PARAMETERS = ['command', 'code'];
13
16
  const WORKDIR_PARAMETER = 'workdir';
17
+ const ELEVATED_PARAMETER = 'elevated';
18
+ const SPAWN_AGENT_PARAMETER = 'agentId';
19
+ const PARAMETERS_THE_CONTEXT_SHOWS = [WORKDIR_PARAMETER, ELEVATED_PARAMETER];
14
20
  const TARGET_WORDS = 2;
15
21
  const ELLIPSIS = '…';
16
22
  const collapsed = (text) => text.split(/\s+/).filter(Boolean).join(' ');
17
23
  export const truncated = (text, max) => text.length <= max ? text : `${text.slice(0, max - ELLIPSIS.length)}${ELLIPSIS}`;
24
+ export const characterCount = (length) => length.toLocaleString('en-US');
18
25
  const stringParameter = (params, name) => {
19
26
  const value = params[name];
20
27
  return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
21
28
  };
22
- const commandOf = (event) => COMMAND_PARAMETERS.map(name => stringParameter(event.params, name)).find(value => value !== undefined);
23
- const serializedParams = (params) => {
24
- try {
25
- return JSON.stringify(params) ?? '';
26
- }
27
- catch {
28
- return '';
29
+ const describedCall = (event) => {
30
+ const preview = commandPreviewOf(event.params, PARAMETERS_THE_CONTEXT_SHOWS);
31
+ if (preview !== null)
32
+ return { kind: 'command', preview };
33
+ const change = fileChangePreviewOf(hostToolId(event.toolName), event.params);
34
+ if (change !== null)
35
+ return { kind: 'file_change', change };
36
+ const visible = withHiddenCharactersShown(serializedWithCredentialsRedacted(event.params));
37
+ return { kind: 'parameters', line: redactSecrets(visible), body: redactSecretsDeep(visible) };
38
+ };
39
+ const READ_IT_ALL = 'Read all of it before you answer.';
40
+ const shortenedNote = (what, length) => ` Shortened here: the ${what} is ${characterCount(length)} characters. ${READ_IT_ALL}`;
41
+ const summaryOf = (line) => {
42
+ const whole = collapsed(line);
43
+ return { text: truncated(whole, QUESTION_SUMMARY_MAX), shortened: whole.length > QUESTION_SUMMARY_MAX };
44
+ };
45
+ const hasMoreThanTheCommand = (preview) => preview.environmentNames.length > 0 || preview.otherParameters !== null;
46
+ const commandQuestion = (preview) => {
47
+ const summary = summaryOf(preview.command);
48
+ const extras = hasMoreThanTheCommand(preview);
49
+ const environment = preview.environmentNames.length > 0 ? ` with ${truncated(preview.environmentNames.join(', '), QUESTION_SUMMARY_MAX)} set` : '';
50
+ const note = summary.shortened
51
+ ? shortenedNote(extras ? 'full call' : 'command', preview.body.length)
52
+ : extras ? ' Read the full call before you answer.' : '';
53
+ return `Allow ${AGENT_LABEL} to run \`${summary.text}\`${environment}?${note}`;
54
+ };
55
+ const quotedList = (paths) => truncated(paths.map(path => `\`${collapsed(path)}\``).join(', '), QUESTION_SUMMARY_MAX);
56
+ const fileChangeQuestion = (change) => {
57
+ const targets = quotedList(change.paths);
58
+ const asked = change.operation === 'patch' ? `apply a patch to ${targets}` : `${change.operation} ${targets}`;
59
+ return `Allow ${AGENT_LABEL} to ${asked}? Read the change before you answer.`;
60
+ };
61
+ const quotedForQuestion = (text) => `\`${truncated(collapsed(redactSecrets(withHiddenCharactersShown(text))), QUESTION_SUMMARY_MAX)}\``;
62
+ const spawnQuestion = (event, note) => {
63
+ if (event.toolName !== SESSIONS_SPAWN_TOOL)
64
+ return null;
65
+ const folder = stringParameter(event.params, SPAWN_FOLDER_PARAMETER);
66
+ const where = folder === undefined ? '' : ` in ${quotedForQuestion(folder)}`;
67
+ if (startsAnAcpSession(event.params)) {
68
+ const agent = stringParameter(event.params, SPAWN_AGENT_PARAMETER);
69
+ const harness = agent === undefined ? '' : ` with ${quotedForQuestion(agent)}`;
70
+ return `Allow ${AGENT_LABEL} to start an outside agent session (ACP)${harness}${where}? Pushary does not see the tool calls that session makes.${note}`;
29
71
  }
72
+ return folder === undefined ? null : `Allow ${AGENT_LABEL} to start a session${where}?${note}`;
73
+ };
74
+ const parametersQuestion = (toolName, description, event) => {
75
+ const summary = summaryOf(description.line);
76
+ const note = summary.shortened ? shortenedNote('request', description.body.length) : '';
77
+ return spawnQuestion(event, note) ?? `Allow ${AGENT_LABEL} to use ${toolName}${summary.text ? `: \`${summary.text}\`` : ''}?${note}`;
30
78
  };
31
- const questionFor = (toolName, summary, command, folder) => {
32
- if (command !== undefined)
33
- return `Allow ${AGENT_LABEL} to run \`${summary}\`?`;
34
- if (folder !== undefined)
35
- return `Allow ${AGENT_LABEL} to start a session in \`${truncated(collapsed(folder), QUESTION_SUMMARY_MAX)}\`?`;
36
- return `Allow ${AGENT_LABEL} to use ${toolName}${summary ? `: \`${summary}\`` : ''}?`;
79
+ const questionFor = (toolName, description, event) => {
80
+ if (description.kind === 'command')
81
+ return commandQuestion(description.preview);
82
+ if (description.kind === 'file_change')
83
+ return fileChangeQuestion(description.change);
84
+ return parametersQuestion(toolName, description, event);
37
85
  };
38
- const contextLines = (event, agentName) => {
86
+ const contextLines = (event, agentName, description) => {
39
87
  const workdir = stringParameter(event.params, WORKDIR_PARAMETER) ?? stringParameter(event.params, SPAWN_FOLDER_PARAMETER);
88
+ const otherParameters = description.kind === 'command' ? description.preview.otherParameters : null;
40
89
  return [
41
90
  `${agentName} wants to use its ${event.toolName} tool.`,
42
91
  ...(workdir ? [`Working directory: ${workdir}`] : []),
43
- ...(event.params.elevated === true ? ['It asked for elevated mode, outside the sandbox.'] : []),
92
+ ...(event.params[ELEVATED_PARAMETER] === true ? ['It asked for elevated mode, outside the sandbox.'] : []),
93
+ ...(otherParameters === null ? [] : [`Other parameters: ${otherParameters}`]),
44
94
  ];
45
95
  };
46
- const targetOf = (command) => {
47
- if (command === undefined)
96
+ const targetOf = (description) => {
97
+ if (description.kind !== 'command')
48
98
  return undefined;
49
- const head = collapsed(command).split(' ').slice(0, TARGET_WORDS).join(' ');
99
+ const head = collapsed(description.preview.command).split(' ').slice(0, TARGET_WORDS).join(' ');
50
100
  return head ? truncated(head, TOOL_TARGET_MAX) : undefined;
51
101
  };
52
- export const approvalQuestionFor = (event, agentName) => {
53
- const toolName = truncated(event.toolName.trim(), TOOL_NAME_MAX);
54
- const command = commandOf(event);
55
- const raw = command ?? serializedParams(event.params);
56
- const body = redactSecrets(raw);
57
- const summary = truncated(collapsed(body), QUESTION_SUMMARY_MAX);
102
+ const actionLineOf = (description) => {
103
+ if (description.kind === 'command')
104
+ return description.preview.line;
105
+ if (description.kind === 'file_change')
106
+ return `${description.change.operation} ${description.change.paths.join(', ')}`;
107
+ return description.line;
108
+ };
109
+ const actionBodyOf = (description) => {
110
+ if (description.kind === 'command')
111
+ return description.preview.body;
112
+ if (description.kind === 'file_change')
113
+ return description.change.body;
114
+ return description.body;
115
+ };
116
+ export const approvalPreviewFor = (event, agentName) => {
117
+ const toolName = truncated(withHiddenCharactersShown(event.toolName.trim()), TOOL_NAME_MAX);
118
+ const description = describedCall(event);
119
+ const actionBody = actionBodyOf(description);
120
+ if (actionBody.length > ACTION_BODY_MAX)
121
+ return { kind: 'too_long', toolName, length: actionBody.length };
58
122
  return {
59
- question: questionFor(toolName, summary, command, event.toolName === SESSIONS_SPAWN_TOOL ? stringParameter(event.params, SPAWN_FOLDER_PARAMETER) : undefined),
60
- context: truncated(redactSecrets(contextLines(event, agentName).join(' ')), CONTEXT_MAX),
61
- toolName,
62
- toolTarget: targetOf(command === undefined ? undefined : body),
63
- action: truncated(collapsed(body), ACTION_MAX),
64
- actionBody: truncated(redactSecretsDeep(raw), ACTION_BODY_MAX),
123
+ kind: 'reviewable',
124
+ question: {
125
+ question: questionFor(toolName, description, event),
126
+ context: truncated(redactSecrets(withHiddenCharactersShown(contextLines(event, agentName, description).join(' '))), CONTEXT_MAX),
127
+ toolName,
128
+ toolTarget: targetOf(description),
129
+ action: truncated(collapsed(actionLineOf(description)), ACTION_MAX),
130
+ actionBody,
131
+ },
65
132
  };
66
133
  };
@@ -0,0 +1,65 @@
1
+ import { isCredentialName, isRecord, REDACTED_VALUE, serializedWithCredentialsRedacted } from './parameter-redaction.js';
2
+ import { redactSecrets, redactSecretsDeep } from './redaction.js';
3
+ import { withHiddenCharactersShown } from './visible-text.js';
4
+ const COMMAND_PARAMETERS = ['command', 'code'];
5
+ const ENV_PARAMETER = 'env';
6
+ const ASSIGNMENT_SEPARATOR = '=';
7
+ const commandParameterOf = (params) => {
8
+ for (const name of COMMAND_PARAMETERS) {
9
+ const value = params[name];
10
+ if (typeof value === 'string' && value.trim().length > 0)
11
+ return { name, command: value };
12
+ }
13
+ return null;
14
+ };
15
+ const environmentValueText = (value) => typeof value === 'string' ? value : serializedWithCredentialsRedacted(value);
16
+ const environmentEntryOf = (name, value) => ({
17
+ name,
18
+ assignment: `${name}${ASSIGNMENT_SEPARATOR}${isCredentialName(name) ? REDACTED_VALUE : environmentValueText(value)}`,
19
+ });
20
+ const environmentEntryOfAssignment = (assignment) => {
21
+ const separator = assignment.indexOf(ASSIGNMENT_SEPARATOR);
22
+ return separator === -1
23
+ ? { name: assignment, assignment }
24
+ : environmentEntryOf(assignment.slice(0, separator), assignment.slice(separator + ASSIGNMENT_SEPARATOR.length));
25
+ };
26
+ const isListOfText = (value) => Array.isArray(value) && value.every(item => typeof item === 'string');
27
+ const environmentOf = (value) => {
28
+ if (isRecord(value))
29
+ return Object.entries(value).map(([name, entry]) => environmentEntryOf(name, entry));
30
+ if (isListOfText(value))
31
+ return value.map(environmentEntryOfAssignment);
32
+ return null;
33
+ };
34
+ const otherParametersOf = (params, skipped) => {
35
+ const others = Object.entries(params).filter(([name]) => !skipped.has(name));
36
+ return others.length === 0 ? null : serializedWithCredentialsRedacted(Object.fromEntries(others));
37
+ };
38
+ const sectionsOf = (environment, otherParameters, command) => {
39
+ if (environment.length === 0 && otherParameters === null)
40
+ return command;
41
+ return [
42
+ ...(environment.length > 0 ? ['Environment:', ...environment.map(entry => entry.assignment), ''] : []),
43
+ ...(otherParameters === null ? [] : [`Other parameters: ${otherParameters}`, '']),
44
+ 'Command:',
45
+ command,
46
+ ].join('\n');
47
+ };
48
+ const oneLineOf = (environment, otherParameters, command) => [...environment.map(entry => entry.assignment), command, ...(otherParameters === null ? [] : [`(${otherParameters})`])].join(' ');
49
+ const displayed = (text) => redactSecrets(withHiddenCharactersShown(text));
50
+ export const commandPreviewOf = (params, shownElsewhere) => {
51
+ const found = commandParameterOf(params);
52
+ if (found === null)
53
+ return null;
54
+ const environment = environmentOf(params[ENV_PARAMETER]);
55
+ const skipped = new Set([found.name, ...shownElsewhere, ...(environment === null ? [] : [ENV_PARAMETER])]);
56
+ const entries = environment ?? [];
57
+ const otherParameters = otherParametersOf(params, skipped);
58
+ return {
59
+ command: displayed(found.command),
60
+ line: displayed(oneLineOf(entries, otherParameters, found.command)),
61
+ body: redactSecretsDeep(withHiddenCharactersShown(sectionsOf(entries, otherParameters, found.command))),
62
+ environmentNames: entries.map(entry => displayed(entry.name)),
63
+ otherParameters: otherParameters === null ? null : displayed(otherParameters),
64
+ };
65
+ };
@@ -0,0 +1,109 @@
1
+ import { basename } from 'node:path';
2
+ import { APPLY_PATCH_TOOL, EDIT_TOOL, patchTargetsOf, WRITE_TOOL } from './protected-writes.js';
3
+ import { redactSecrets, redactSecretsDeep } from './redaction.js';
4
+ import { withHiddenCharactersShown } from './visible-text.js';
5
+ const PATH_PARAMETER = 'path';
6
+ const CONTENT_PARAMETER = 'content';
7
+ const EDITS_PARAMETER = 'edits';
8
+ const PATCH_PARAMETER = 'input';
9
+ const OLD_TEXT_PARAMETER = 'oldText';
10
+ const NEW_TEXT_PARAMETER = 'newText';
11
+ const ENV_FILE_NAME = '.env';
12
+ const ENV_ASSIGNMENT = /^([+\- ]?[ \t]*(?:export[ \t]+)?[A-Za-z_][A-Za-z0-9_.-]*[ \t]*=[ \t]*)\S.*$/gm;
13
+ const HIDDEN_VALUE = '[value not sent]';
14
+ const REMOVED_LINE_PREFIX = '- ';
15
+ const ADDED_LINE_PREFIX = '+ ';
16
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
17
+ const textParameter = (params, name) => {
18
+ const value = params[name];
19
+ return typeof value === 'string' ? value : undefined;
20
+ };
21
+ const pathParameter = (params) => {
22
+ const path = textParameter(params, PATH_PARAMETER)?.trim();
23
+ return path ? path : undefined;
24
+ };
25
+ export const isEnvFile = (path) => {
26
+ const name = basename(path.trim()).toLowerCase();
27
+ return name.endsWith(ENV_FILE_NAME) || name.startsWith(`${ENV_FILE_NAME}.`);
28
+ };
29
+ const withEnvValuesHidden = (text) => text.replace(ENV_ASSIGNMENT, `$1${HIDDEN_VALUE}`);
30
+ const sendableText = (text, hidesEnvValues) => {
31
+ const visible = withHiddenCharactersShown(text);
32
+ return redactSecretsDeep(hidesEnvValues ? withEnvValuesHidden(visible) : visible);
33
+ };
34
+ const sendablePath = (path) => redactSecrets(withHiddenCharactersShown(path));
35
+ const lineCountOf = (text) => {
36
+ if (text.length === 0)
37
+ return 0;
38
+ const lines = text.split('\n').length;
39
+ return text.endsWith('\n') ? lines - 1 : lines;
40
+ };
41
+ const plural = (count, word) => `${count} ${word}${count === 1 ? '' : 's'}`;
42
+ const prefixedLines = (text, prefix) => text.split('\n').map(line => `${prefix}${line}`).join('\n');
43
+ const textEditOf = (value) => {
44
+ if (!isRecord(value))
45
+ return null;
46
+ const oldText = textParameter(value, OLD_TEXT_PARAMETER);
47
+ const newText = textParameter(value, NEW_TEXT_PARAMETER);
48
+ return oldText === undefined || newText === undefined ? null : { oldText, newText };
49
+ };
50
+ const textEditsOf = (params) => {
51
+ const listed = params[EDITS_PARAMETER];
52
+ const candidates = Array.isArray(listed) ? listed : [params];
53
+ const edits = [];
54
+ for (const candidate of candidates) {
55
+ const edit = textEditOf(candidate);
56
+ if (edit === null)
57
+ return null;
58
+ edits.push(edit);
59
+ }
60
+ return edits.length > 0 ? edits : null;
61
+ };
62
+ const writePreviewOf = (params) => {
63
+ const path = pathParameter(params);
64
+ const content = textParameter(params, CONTENT_PARAMETER);
65
+ if (path === undefined || content === undefined)
66
+ return null;
67
+ const shownPath = sendablePath(path);
68
+ return {
69
+ operation: 'write',
70
+ paths: [shownPath],
71
+ body: `Write ${shownPath}, ${plural(lineCountOf(content), 'line')}:\n\n${sendableText(content, isEnvFile(path))}`,
72
+ };
73
+ };
74
+ const shownEdit = (edit, hidesEnvValues) => [prefixedLines(sendableText(edit.oldText, hidesEnvValues), REMOVED_LINE_PREFIX), prefixedLines(sendableText(edit.newText, hidesEnvValues), ADDED_LINE_PREFIX)].join('\n');
75
+ const editPreviewOf = (params) => {
76
+ const path = pathParameter(params);
77
+ const edits = textEditsOf(params);
78
+ if (path === undefined || edits === null)
79
+ return null;
80
+ const shownPath = sendablePath(path);
81
+ const hidesEnvValues = isEnvFile(path);
82
+ return {
83
+ operation: 'edit',
84
+ paths: [shownPath],
85
+ body: `Edit ${shownPath}, ${plural(edits.length, 'change')}:\n\n${edits.map(edit => shownEdit(edit, hidesEnvValues)).join('\n\n')}`,
86
+ };
87
+ };
88
+ const patchPreviewOf = (params) => {
89
+ const patch = textParameter(params, PATCH_PARAMETER);
90
+ if (patch === undefined)
91
+ return null;
92
+ const targets = patchTargetsOf(patch);
93
+ if (targets.length === 0)
94
+ return null;
95
+ return {
96
+ operation: 'patch',
97
+ paths: targets.map(sendablePath),
98
+ body: sendableText(patch, targets.some(isEnvFile)),
99
+ };
100
+ };
101
+ export const fileChangePreviewOf = (toolId, params) => {
102
+ if (toolId === WRITE_TOOL)
103
+ return writePreviewOf(params);
104
+ if (toolId === EDIT_TOOL)
105
+ return editPreviewOf(params);
106
+ if (toolId === APPLY_PATCH_TOOL)
107
+ return patchPreviewOf(params);
108
+ return null;
109
+ };
@@ -1,7 +1,7 @@
1
- import { APPROVAL_DESCRIPTION_MAX, APPROVAL_TITLE_MAX, truncated } from './approval-question.js';
1
+ import { ACTION_BODY_MAX, APPROVAL_DESCRIPTION_MAX, APPROVAL_TITLE_MAX, characterCount, truncated } from './approval-question.js';
2
2
  import { API_KEY_VARIABLE, BASE_URL_VARIABLE } from './connection.js';
3
3
  import { MIN_HOST_VERSION } from './host-version.js';
4
- export const SETUP_COMMAND = 'npx pushary@latest setup';
4
+ export const SETUP_COMMAND = 'npx pushary@latest setup --agents openclaw';
5
5
  export const DEVICES_URL = 'https://pushary.com/dashboard/agent/settings';
6
6
  export const HAND_BACK_DECISIONS = ['allow-once', 'deny'];
7
7
  const SECONDS_PER_MINUTE = 60;
@@ -23,10 +23,16 @@ const unavailableReason = (toolName, outcome) => {
23
23
  }
24
24
  return `Pushary could not be reached, so nobody could approve this ${toolName} call and it was blocked. Nothing ran. Try again in a moment.`;
25
25
  };
26
+ const shortenedDescription = (text) => {
27
+ if (text.length <= APPROVAL_DESCRIPTION_MAX)
28
+ return text;
29
+ const notice = ` (shortened from ${characterCount(text.length)} characters: read the whole call in OpenClaw before you allow it)`;
30
+ return `${truncated(text, APPROVAL_DESCRIPTION_MAX - notice.length)}${notice}`;
31
+ };
26
32
  const handedBack = (question) => ({
27
33
  requireApproval: {
28
34
  title: truncated(question.question, APPROVAL_TITLE_MAX),
29
- description: truncated(`${question.context} ${question.action}`, APPROVAL_DESCRIPTION_MAX),
35
+ description: shortenedDescription(`${question.context} ${question.action}`),
30
36
  severity: 'warning',
31
37
  allowedDecisions: [...HAND_BACK_DECISIONS],
32
38
  },
@@ -53,6 +59,7 @@ export const openClawResultFor = (outcome, question, handBackSurface) => {
53
59
  return blocked(unavailableReason(tool, outcome));
54
60
  }
55
61
  };
62
+ export const tooLongToReviewResultFor = (toolName, length) => blocked(`This ${toolName} call is too long to show in full: ${characterCount(length)} characters, and Pushary shows at most ${characterCount(ACTION_BODY_MAX)}. It was blocked, not sent for an approval nobody could read. Nothing ran. Split it into smaller steps.`);
56
63
  export const notConnectedResultFor = (problem, toolName) => problem === 'missing_api_key'
57
- ? blocked(`Pushary is not set up for OpenClaw on this machine: ${API_KEY_VARIABLE} is missing, so this ${toolName} call was blocked. Run ${SETUP_COMMAND}, or add ${API_KEY_VARIABLE} to ~/.openclaw/.env, then restart the OpenClaw gateway.`)
64
+ ? blocked(`Pushary is not set up for OpenClaw on this machine: ${API_KEY_VARIABLE} is missing, so this ${toolName} call was blocked. Run ${SETUP_COMMAND}, or create an API key at ${DEVICES_URL} and add ${API_KEY_VARIABLE}=<key> to ~/.openclaw/.env, then restart the OpenClaw gateway.`)
58
65
  : blocked(`${BASE_URL_VARIABLE} is not https://pushary.com or https://www.pushary.com, so this ${toolName} call was blocked. Remove it, then restart the OpenClaw gateway.`);
@@ -0,0 +1,28 @@
1
+ import { redactSecrets } from './redaction.js';
2
+ export const REDACTED_VALUE = '[redacted]';
3
+ const REDACTION_PROBE = 'x';
4
+ export const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
5
+ export const isCredentialName = (key) => redactSecrets(`${key}=${REDACTION_PROBE}`) !== `${key}=${REDACTION_PROBE}`;
6
+ const withCredentialValuesRedacted = (value, ancestors) => {
7
+ if (typeof value !== 'object' || value === null)
8
+ return value;
9
+ if (ancestors.has(value))
10
+ throw new TypeError('circular parameters');
11
+ const inside = new Set([...ancestors, value]);
12
+ if (Array.isArray(value))
13
+ return value.map(item => withCredentialValuesRedacted(item, inside));
14
+ if (!isRecord(value))
15
+ return value;
16
+ return Object.fromEntries(Object.entries(value).map(([key, entry]) => [
17
+ key,
18
+ isCredentialName(key) ? REDACTED_VALUE : withCredentialValuesRedacted(entry, inside),
19
+ ]));
20
+ };
21
+ export const serializedWithCredentialsRedacted = (value) => {
22
+ try {
23
+ return JSON.stringify(withCredentialValuesRedacted(value, new Set())) ?? '';
24
+ }
25
+ catch {
26
+ return '';
27
+ }
28
+ };