@pushary/agent-hooks 1.9.150 → 1.9.152
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/data/openclaw-plugin/README.md +39 -2
- package/data/openclaw-plugin/dist/approval-hook.js +8 -4
- package/data/openclaw-plugin/dist/approval-question.js +100 -33
- package/data/openclaw-plugin/dist/command-preview.js +65 -0
- package/data/openclaw-plugin/dist/file-change-preview.js +109 -0
- package/data/openclaw-plugin/dist/gate-result.js +11 -4
- package/data/openclaw-plugin/dist/parameter-redaction.js +28 -0
- package/data/openclaw-plugin/dist/protected-writes.js +18 -4
- package/data/openclaw-plugin/dist/settings.js +7 -1
- package/data/openclaw-plugin/dist/visible-text.js +5 -0
- package/data/openclaw-plugin/openclaw.plugin.json +1 -1
- package/data/openclaw-plugin/package.json +1 -1
- package/dist/{api-GHPLREAU.js → api-IQMAAMIS.js} +11 -11
- package/dist/bin/pushary-audit.js +3 -3
- package/dist/bin/pushary-bell-hook.js +28 -28
- package/dist/bin/pushary-bell.js +10 -10
- package/dist/bin/pushary-claude.js +29 -28
- package/dist/bin/pushary-clean.js +36 -36
- package/dist/bin/pushary-codex-bridge.js +23 -23
- package/dist/bin/pushary-codex-hook.js +39 -39
- package/dist/bin/pushary-codex-session.js +8 -8
- package/dist/bin/pushary-codex.js +16 -16
- package/dist/bin/pushary-connect.js +32 -32
- package/dist/bin/pushary-cowork.js +5 -5
- package/dist/bin/pushary-daemon.js +44 -44
- package/dist/bin/pushary-disconnect.js +28 -28
- package/dist/bin/pushary-display-hook.js +10 -5
- package/dist/bin/pushary-doctor.js +44 -44
- package/dist/bin/pushary-elicitation-hook.js +28 -28
- package/dist/bin/pushary-gemini-bridge.js +17 -17
- package/dist/bin/pushary-gemini-hook.js +32 -32
- package/dist/bin/pushary-hook.js +35 -35
- package/dist/bin/pushary-login.js +21 -21
- package/dist/bin/pushary-logout.js +27 -27
- package/dist/bin/pushary-mcp.js +12 -12
- package/dist/bin/pushary-mode.js +15 -15
- package/dist/bin/pushary-notification-hook.js +27 -27
- package/dist/bin/pushary-opencode-hook.js +31 -31
- package/dist/bin/pushary-permission-denied-hook.js +35 -35
- package/dist/bin/pushary-permission-hook.js +35 -35
- package/dist/bin/pushary-post-hook.js +28 -28
- package/dist/bin/pushary-prompt-hook.js +27 -27
- package/dist/bin/pushary-session-end-hook.js +27 -27
- package/dist/bin/pushary-session-start-hook.js +37 -37
- package/dist/bin/pushary-setup.js +52 -52
- package/dist/bin/pushary-stats.js +5 -5
- package/dist/bin/pushary-status.js +33 -33
- package/dist/bin/pushary-stop-hook.js +27 -27
- package/dist/bin/pushary-stopfailure-hook.js +27 -27
- package/dist/bin/pushary-suggestions.js +15 -15
- package/dist/bin/pushary-transcript-register.js +17 -17
- package/dist/bin/pushary-transcripts.js +25 -25
- package/dist/bin/pushary-upgrade.js +42 -42
- package/dist/bin/pushary-wait.js +15 -15
- package/dist/bin/pushary.js +7 -7
- package/dist/{chunk-C2JMTH45.js → chunk-2NEN7KVF.js} +2 -2
- package/dist/{chunk-7XFEV7ML.js → chunk-2PCWFDLS.js} +5 -5
- package/dist/{chunk-ACC4YXJS.js → chunk-2PWQQ5S4.js} +1 -1
- package/dist/{chunk-5D57GAKF.js → chunk-3N5RC7KI.js} +3 -3
- package/dist/{chunk-E75OHUWM.js → chunk-43TBZRPG.js} +1 -1
- package/dist/{chunk-A3EV4C34.js → chunk-43XJ7U63.js} +2 -2
- package/dist/{chunk-KACTUGKV.js → chunk-4BUSJQJH.js} +5 -5
- package/dist/{chunk-4ZH2PXDA.js → chunk-4LVISHV6.js} +1 -1
- package/dist/{chunk-XU45NUAV.js → chunk-4NZORVWS.js} +10 -10
- package/dist/{chunk-DHP6SWVH.js → chunk-4P4G4AGP.js} +3 -3
- package/dist/{chunk-DYUK6HYH.js → chunk-4RFLYU65.js} +1 -1
- package/dist/{chunk-TRDJICC7.js → chunk-672GQ3QP.js} +3 -3
- package/dist/{chunk-CVQTLCVS.js → chunk-6B5OLJFA.js} +1 -1
- package/dist/{chunk-OZD5FIFS.js → chunk-6FIQQLB4.js} +3 -3
- package/dist/{chunk-AWC7MXLX.js → chunk-6U4HTJDH.js} +6 -6
- package/dist/{chunk-XJLCZ24Y.js → chunk-7T75RUZJ.js} +1 -1
- package/dist/{chunk-I3CN7BGN.js → chunk-7THR5LFY.js} +2 -2
- package/dist/{chunk-KAZ37TWD.js → chunk-ADZQYXHK.js} +5 -5
- package/dist/{chunk-NRMMXX62.js → chunk-AHAVUAFN.js} +2 -2
- package/dist/{chunk-46IYOPZH.js → chunk-AVB5ZJRA.js} +1 -1
- package/dist/{chunk-K3ORQ3KY.js → chunk-BEGXHUFW.js} +13 -7
- package/dist/{chunk-NP6QILOY.js → chunk-BKXMMYEJ.js} +5 -5
- package/dist/{chunk-6RMBTFDF.js → chunk-BVI7NBGK.js} +3 -3
- package/dist/{chunk-7L6IP3JA.js → chunk-DJCTVJR4.js} +2 -2
- package/dist/{chunk-PS3O6LS2.js → chunk-E2ZX6DAP.js} +6 -6
- package/dist/{chunk-JGYQ72A7.js → chunk-ED6YWQEU.js} +4 -4
- package/dist/{chunk-3XIHKIDX.js → chunk-ESHJ67UO.js} +4 -4
- package/dist/{chunk-BPSQLKTG.js → chunk-F5KUZBN7.js} +6 -6
- package/dist/{chunk-USN3OOHD.js → chunk-FT4V3IJ2.js} +16 -16
- package/dist/{chunk-BANZ4GGS.js → chunk-G7UI7IQN.js} +2 -2
- package/dist/{chunk-NQUE54GA.js → chunk-GBVNCGF5.js} +1 -1
- package/dist/{chunk-7357Q746.js → chunk-GRKS5KRJ.js} +1 -1
- package/dist/{chunk-OBIUHAXG.js → chunk-H3PD7NM6.js} +2 -2
- package/dist/{chunk-FHPLLUAZ.js → chunk-H3W3GRV6.js} +1 -1
- package/dist/{chunk-WQVRDVMJ.js → chunk-HDG5E3KL.js} +3 -3
- package/dist/{chunk-H4MHGLEB.js → chunk-HYKV5VFO.js} +3 -3
- package/dist/{chunk-NPNBR4FS.js → chunk-HZUVLAWB.js} +5 -5
- package/dist/{chunk-53URUFUJ.js → chunk-IQ6ZOIJW.js} +11 -11
- package/dist/{chunk-E5YEKJOM.js → chunk-ISF5ESY4.js} +1 -1
- package/dist/{chunk-P3E26UO5.js → chunk-ITQPLAJU.js} +6 -6
- package/dist/{chunk-BAH4LZL3.js → chunk-IZIUWALV.js} +5 -5
- package/dist/{chunk-7FPKT5QJ.js → chunk-J7ZT4QIS.js} +5 -5
- package/dist/{chunk-ZUN37EG2.js → chunk-JHYXXSXE.js} +6 -6
- package/dist/{chunk-AYFOZBTD.js → chunk-JKP27CWR.js} +1 -1
- package/dist/{chunk-3MXI37MS.js → chunk-K3RITWPY.js} +4 -4
- package/dist/{chunk-AIKQFV6C.js → chunk-K73XYVAI.js} +4 -4
- package/dist/{chunk-WY4CM6TO.js → chunk-KSQOSFWU.js} +3 -3
- package/dist/{chunk-ZBZ7CRGD.js → chunk-LFMW5JU5.js} +1 -1
- package/dist/{chunk-J6LZ4G5G.js → chunk-MIVJN6UX.js} +2 -2
- package/dist/{chunk-PYH3KFLI.js → chunk-NLEUWI4M.js} +12 -12
- package/dist/{chunk-YYEYPA3S.js → chunk-NPRN6U2N.js} +4 -4
- package/dist/{chunk-ZMEI3EG4.js → chunk-NWRILLTQ.js} +3 -3
- package/dist/{chunk-HQ3RFANL.js → chunk-OOIX6OGT.js} +2 -2
- package/dist/{chunk-5TMW2X5I.js → chunk-P474YA7K.js} +1 -1
- package/dist/{chunk-TQXKJX7X.js → chunk-PDALRESB.js} +8 -8
- package/dist/{chunk-53Y4QQNF.js → chunk-QXD25T2R.js} +5 -5
- package/dist/{chunk-ZSX4XN6C.js → chunk-RPGXFONU.js} +5 -5
- package/dist/{chunk-P6GCPJDQ.js → chunk-SI4WLQRD.js} +3 -3
- package/dist/{chunk-4UDGVO6A.js → chunk-SY75XL7K.js} +1 -1
- package/dist/{chunk-JJKPQSEE.js → chunk-UBOZHYDV.js} +2 -2
- package/dist/{chunk-ODYF7VZZ.js → chunk-USJEAJBM.js} +1 -1
- package/dist/{chunk-P3RRAH6J.js → chunk-UYWRWMVG.js} +3 -3
- package/dist/{chunk-BRXPFM3U.js → chunk-VAXPBUY7.js} +2 -2
- package/dist/{chunk-ILEO4YWM.js → chunk-VJCNWZWT.js} +1 -1
- package/dist/{chunk-DQKT5KK5.js → chunk-VMGVFV4F.js} +4 -4
- package/dist/{chunk-3TUSMGHE.js → chunk-W26FWH7E.js} +1 -1
- package/dist/{chunk-I6DLNMUM.js → chunk-WF4GAVIZ.js} +4 -4
- package/dist/{chunk-ZLHPTXWU.js → chunk-WUFOQ3BO.js} +5 -5
- package/dist/{chunk-LRK2F63A.js → chunk-X5ECZTDF.js} +8 -8
- package/dist/{chunk-S263JK6K.js → chunk-XNZT3Y3Y.js} +2 -2
- package/dist/{chunk-R2VVMSGM.js → chunk-XTIUW3CE.js} +5 -5
- package/dist/{chunk-YUYBMCKF.js → chunk-XVIPSHT3.js} +3 -3
- package/dist/{chunk-TR35RG7D.js → chunk-YELJYFSC.js} +18 -7
- package/dist/{chunk-IPRQFNPG.js → chunk-YGC22HOG.js} +1 -1
- package/dist/{chunk-HY4GEW3T.js → chunk-YKCACY4F.js} +2 -2
- package/dist/{chunk-XWMVKK54.js → chunk-ZUS334Z2.js} +1 -1
- package/dist/{chunk-BDF74W2U.js → chunk-ZYES37XJ.js} +4 -4
- package/dist/{codex-app-cards-switch-U77ZM22P.js → codex-app-cards-switch-ZC2QNMYV.js} +11 -11
- package/dist/{codex-card-routing-3L4XXUCK.js → codex-card-routing-7S6SQSCN.js} +2 -2
- package/dist/{codex-desktop-launch-KRLBST55.js → codex-desktop-launch-7A7YFJEW.js} +1 -1
- package/dist/{codex-session-launch-6LMMSNLA.js → codex-session-launch-6TN6U52H.js} +20 -20
- package/dist/{config-5YEZFF26.js → config-GC6NPWRS.js} +3 -3
- package/dist/{global-upgrade-EWBY6BD5.js → global-upgrade-2QO2GEFD.js} +9 -9
- package/dist/{identity-D3SYIS5Z.js → identity-7K2E5ZRO.js} +4 -4
- package/dist/{live-capabilities-QUNHPUFR.js → live-capabilities-6WMTLNQN.js} +4 -4
- package/dist/{paths-VI5KNBOY.js → paths-BJUKHDVE.js} +3 -3
- package/dist/{reapply-UKREFK55.js → reapply-ODUBZT4P.js} +30 -30
- package/dist/src/index.js +34 -34
- package/dist/{upgrade-lock-COPTGES4.js → upgrade-lock-N6FDN5Z7.js} +4 -4
- package/dist/{usage-4367CHW4.js → usage-4PYAM3IB.js} +3 -3
- package/package.json +1 -1
- package/data/cursor-plugin/scripts/pushary-gate.test.mjs +0 -150
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.9.152
|
|
4
|
+
|
|
5
|
+
- A tool counts as one of Pushary's own only when it comes from the server named exactly `pushary`, the claude.ai Pushary connector or the Pushary plugin, followed by one tool name. Before, any tool whose name started with `mcp__pushary__` counted. Claude Code writes every character a server name may not carry as `_`, so a different server named `pushary__fs` or `pushary.` lists its tools as `mcp__pushary__fs__write_file` or `mcp__pushary___run_shell`. In Claude Code, 1.9.150's `PermissionRequest` hook allowed every such tool without a prompt, and `PreToolUse` skipped the kill switch and standing denies for them. The Codex hooks skipped them the same way, and `pushary claude` allowed them while your phone drives the session. They are now judged like any other MCP tool. Pushary's own tools, the connector's and the plugin's are left alone as before.
|
|
6
|
+
|
|
7
|
+
## 1.9.151
|
|
8
|
+
|
|
9
|
+
- 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.
|
|
10
|
+
- 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.
|
|
11
|
+
- 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.
|
|
12
|
+
- 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.
|
|
13
|
+
- `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.
|
|
14
|
+
- The editor plugins this CLI carries no longer include their test files.
|
|
15
|
+
|
|
3
16
|
## 1.9.150
|
|
4
17
|
|
|
5
18
|
- 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.
|
|
@@ -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
|
-
-
|
|
45
|
-
- Every `
|
|
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 {
|
|
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
|
|
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,
|
|
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
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
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,
|
|
32
|
-
if (
|
|
33
|
-
return
|
|
34
|
-
if (
|
|
35
|
-
return
|
|
36
|
-
return
|
|
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
|
|
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 = (
|
|
47
|
-
if (
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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:
|
|
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
|
+
};
|
|
@@ -14,6 +14,8 @@ const FILE_REFERENCE_PREFIX = '@';
|
|
|
14
14
|
const HOME_PREFIX = '~';
|
|
15
15
|
const MISSING_PATH_CODES = new Set(['ENOENT', 'ENOTDIR']);
|
|
16
16
|
const WORKSPACE_HOOKS_DIRECTORY = 'hooks';
|
|
17
|
+
const WORKSPACE_OPENCLAW_DIRECTORY = '.openclaw';
|
|
18
|
+
const WORKSPACE_FOLDERS_OPENCLAW_LOADS = [WORKSPACE_HOOKS_DIRECTORY, WORKSPACE_OPENCLAW_DIRECTORY];
|
|
17
19
|
const RISKY_RELATIVE_STARTS = ['.pushary', '.config'];
|
|
18
20
|
const errorCodeOf = (error) => typeof error === 'object' && error !== null && 'code' in error && typeof error.code === 'string' ? error.code : null;
|
|
19
21
|
const canonicalPathOf = (path, system) => {
|
|
@@ -61,6 +63,7 @@ const comparablePathsFor = (locations, system, agentId) => {
|
|
|
61
63
|
protectedTrees: spellingsOfAll(locations.protectedTrees, system),
|
|
62
64
|
serviceFiles: locations.serviceFiles.flatMap(location => spellingsOfLocation(location.directory, system).map(directory => ({ directory, namePrefix: comparable(location.namePrefix, system) }))),
|
|
63
65
|
workspace: workspaceCanonical === null ? null : comparable(workspaceCanonical, system),
|
|
66
|
+
workspaceFoldersOpenClawLoads: WORKSPACE_FOLDERS_OPENCLAW_LOADS.map(folder => comparable(folder, system)),
|
|
64
67
|
riskyRelativeStarts: new Set([
|
|
65
68
|
...locations.stateDirectories.map(state => comparable(basename(state), system)),
|
|
66
69
|
...locations.configFiles.map(file => comparable(basename(file), system)),
|
|
@@ -69,7 +72,12 @@ const comparablePathsFor = (locations, system, agentId) => {
|
|
|
69
72
|
};
|
|
70
73
|
};
|
|
71
74
|
const isServiceFile = (path, services) => services.some(service => firstComponentUnder(path, service.directory)?.startsWith(service.namePrefix) === true);
|
|
72
|
-
const
|
|
75
|
+
const isInAWorkspaceFolderOpenClawLoads = (path, paths) => {
|
|
76
|
+
if (paths.workspace === null)
|
|
77
|
+
return false;
|
|
78
|
+
const component = firstComponentUnder(path, paths.workspace);
|
|
79
|
+
return component !== null && paths.workspaceFoldersOpenClawLoads.includes(component);
|
|
80
|
+
};
|
|
73
81
|
const isInWorkspaceUnderState = (path, paths) => {
|
|
74
82
|
const { workspace } = paths;
|
|
75
83
|
if (workspace === null || !isSameOrInside(path, workspace))
|
|
@@ -83,7 +91,7 @@ const isProtectedLocation = (path, paths) => {
|
|
|
83
91
|
return true;
|
|
84
92
|
if (isServiceFile(path, paths.serviceFiles))
|
|
85
93
|
return true;
|
|
86
|
-
if (
|
|
94
|
+
if (isInAWorkspaceFolderOpenClawLoads(path, paths))
|
|
87
95
|
return true;
|
|
88
96
|
if (!paths.stateDirectories.some(state => isSameOrInside(path, state)))
|
|
89
97
|
return false;
|
|
@@ -189,6 +197,12 @@ export const writesIntoOpenClaw = (locations, system, call) => {
|
|
|
189
197
|
export const SESSIONS_SPAWN_TOOL = 'sessions_spawn';
|
|
190
198
|
export const SPAWN_FOLDER_PARAMETER = 'cwd';
|
|
191
199
|
const SPAWN_SOURCES_IT_CANNOT_SEE = ['projectId', 'projectGitUrl', 'worktree'];
|
|
200
|
+
const SPAWN_RUNTIME_PARAMETER = 'runtime';
|
|
201
|
+
const ACP_RUNTIME = 'acp';
|
|
202
|
+
export const startsAnAcpSession = (params) => {
|
|
203
|
+
const runtime = params[SPAWN_RUNTIME_PARAMETER];
|
|
204
|
+
return typeof runtime === 'string' && runtime.trim().toLowerCase() === ACP_RUNTIME;
|
|
205
|
+
};
|
|
192
206
|
const namesAFolderItCannotSee = (params) => SPAWN_SOURCES_IT_CANNOT_SEE.some(name => params[name] !== undefined && params[name] !== false);
|
|
193
207
|
const spawnFolderVerdict = (raw, paths, system) => {
|
|
194
208
|
if (typeof raw !== 'string' || raw.trim().length === 0 || paths.workspace === null)
|
|
@@ -202,13 +216,13 @@ const spawnFolderVerdict = (raw, paths, system) => {
|
|
|
202
216
|
const folder = comparable(canonical, system);
|
|
203
217
|
if (!isSameOrInside(folder, paths.workspace))
|
|
204
218
|
return 'protected';
|
|
205
|
-
return
|
|
219
|
+
return isInAWorkspaceFolderOpenClawLoads(folder, paths) ? 'protected' : 'clear';
|
|
206
220
|
};
|
|
207
221
|
export const spawnsOutsideTheWorkspace = (locations, system, call) => {
|
|
208
222
|
if (call.toolId !== SESSIONS_SPAWN_TOOL)
|
|
209
223
|
return false;
|
|
210
224
|
const { params } = call.event;
|
|
211
|
-
if (namesAFolderItCannotSee(params))
|
|
225
|
+
if (startsAnAcpSession(params) || namesAFolderItCannotSee(params))
|
|
212
226
|
return true;
|
|
213
227
|
if (params[SPAWN_FOLDER_PARAMETER] === undefined)
|
|
214
228
|
return false;
|