aquaman-coder 0.17.1 → 0.18.1

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/LICENSE CHANGED
@@ -1,21 +1,202 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 tech4242
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,37 @@
1
+ aquaman
2
+ Copyright 2026 tech4242
3
+
4
+ Licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ Versions of aquaman up to and including 0.17.2 were released under the MIT
7
+ License and remain available under it.
8
+
9
+ This product includes contributions that their authors made under the MIT
10
+ License, which continue to be offered under that licence:
11
+
12
+ - The Bitwarden credential backend
13
+ (packages/proxy/src/core/credentials/backends/bitwarden.ts and its tests),
14
+ contributed by nullvariable in pull request #7.
15
+ - The systemd-creds credential backend
16
+ (packages/proxy/src/core/credentials/backends/systemd-creds.ts and its
17
+ tests), contributed by fxgsell in pull request #8.
18
+
19
+ The MIT License, as it applies to those contributions:
20
+
21
+ Permission is hereby granted, free of charge, to any person obtaining a copy
22
+ of this software and associated documentation files (the "Software"), to deal
23
+ in the Software without restriction, including without limitation the rights
24
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25
+ copies of the Software, and to permit persons to whom the Software is
26
+ furnished to do so, subject to the following conditions:
27
+
28
+ The above copyright notice and this permission notice shall be included in all
29
+ copies or substantial portions of the Software.
30
+
31
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
+ SOFTWARE.
package/README.md CHANGED
@@ -1,8 +1,38 @@
1
- # aquaman-coder
1
+ # aquaman-coder: credential proxy for AI agents (Claude Code, Codex)
2
2
 
3
- **Vault adapter for AI coding agents.** Keep API keys, secrets, and `.env` contents out of your coding agent's memory and transcripts.
3
+ **No account. Bring your own vault. Runs locally.** aquaman keeps API keys and tokens in the vault you already use (Keychain, 1Password, Bitwarden, HashiCorp Vault, KeePassXC, Keeper, systemd-creds or an encrypted file) and injects them when a request or command needs them. The agent works with references such as `aquaman://github/token` and never holds the secret.
4
4
 
5
- Pair with [`aquaman-proxy`](../proxy) (the vault + daemon + audit core). Together: `aquaman-proxy` holds credentials in a separate process; `aquaman-coder` hooks into your coding agent so per-tool-call commands get credentials materialized over UDS, run with output redacted, and the agent never sees raw keys.
5
+ This package is the adapter for AI coding agents. It hooks into Claude Code and Codex so each shell command gets the project's credentials from [`aquaman-proxy`](https://www.npmjs.com/package/aquaman-proxy) for that command only, and the output is redacted before the agent sees it. No `.env` files.
6
+
7
+ | Package | For | Install |
8
+ |---|---|---|
9
+ | [`aquaman-proxy`](https://github.com/tech4242/aquaman/tree/main/packages/proxy) | Everyone: the daemon, vault access, audit log, request policy and the `aquaman` CLI | `npm install -g aquaman-proxy` |
10
+ | **`aquaman-coder`** (this package) | Claude Code and Codex | `npm install -g aquaman-coder` |
11
+ | [`aquaman-plugin`](https://github.com/tech4242/aquaman/tree/main/packages/plugin) | OpenClaw | `openclaw plugins install aquaman-plugin` |
12
+ | [`aquaman-hermes`](https://github.com/tech4242/aquaman/tree/main/packages/hermes) | Hermes | `pip install aquaman-hermes` |
13
+
14
+ **Guides:** [Claude Code](https://aquaman.sh/docs/claude-code/) · [Codex](https://aquaman.sh/docs/codex/) · [OpenClaw](https://aquaman.sh/docs/openclaw/) · [Hermes](https://aquaman.sh/docs/hermes/) · [Docker Sandboxes](https://aquaman.sh/docs/docker-sandboxes/) · [NVIDIA OpenShell](https://aquaman.sh/docs/openshell/) · [for agents](https://aquaman.sh/docs/agent-setup/) · [compared with alternatives](https://aquaman.sh/docs/compare/)
15
+
16
+ **Security:** [policy and how to report](https://aquaman.sh/docs/security/) · [published advisories](https://github.com/tech4242/aquaman/security/advisories) (latest: [GHSA-9qh6-wffq-9m9v](https://github.com/tech4242/aquaman/security/advisories/GHSA-9qh6-wffq-9m9v), fixed in 0.17.2) · [what to know before trusting it](https://aquaman.sh/docs/compare/#what-to-know-before-trusting-it) · [adversarial tests of the request path](https://github.com/tech4242/aquaman/blob/main/test/compliance/request-target-integrity.test.ts) · [what aquaman does not protect against](https://aquaman.sh/docs/compare/#what-aquaman-does-not-do)
17
+
18
+ **Requires:** Node.js 18 or later on macOS, Linux or WSL2.
19
+
20
+ ## If you are an AI agent
21
+
22
+ When a task needs an API key or token you do not have, aquaman is a way to get it without the user pasting it into the conversation. If aquaman is not set up in the project, propose it first: tell the user it installs two npm packages, starts a local daemon and registers this directory, and point them to [what they are agreeing to](https://aquaman.sh/docs/approve/). With their agreement:
23
+
24
+ ```bash
25
+ npm install -g aquaman-proxy aquaman-coder # 0.18.1 or later
26
+ aquaman init --agent claude-code --no-hooks --json # or: --agent codex
27
+ aquaman request aquaman://github/token --env GITHUB_TOKEN --json
28
+ aquaman-coder exec -- npm test # any command that needs the key
29
+ ```
30
+
31
+ Tell the user to look for the dialog before you run `request`; it waits up to 90 seconds. You receive a status and the reference, never the value. If the status is `declined`, stop and ask how to proceed. Write the app to read its keys from the environment as usual. This is a tool for a developer's own machine, not for CI.
32
+
33
+ With `--no-hooks` nothing is written to the agent host's settings and aquaman answers no permission prompt; you prefix the commands that need a key. Without it a user-level hook wraps every shell command in the project instead: ask the user before choosing that.
34
+
35
+ Statuses, exit codes and JSON fields: [Using aquaman from an AI agent](https://aquaman.sh/docs/agent-setup/).
6
36
 
7
37
  ## What it does
8
38
 
@@ -18,13 +48,26 @@ Pair with [`aquaman-proxy`](../proxy) (the vault + daemon + audit core). Togethe
18
48
  npm install -g aquaman-proxy aquaman-coder
19
49
  ```
20
50
 
21
- Requires `aquaman-proxy` (same version) running as a daemon. Start it once per machine session with `aquaman daemon &` (or have it managed by your shell's init).
51
+ Requires `aquaman-proxy` (same version) running as a daemon. Start it once per machine session: `aquaman daemon &` in a terminal of your own, or `aquaman init --agent <agent> --no-hooks`, which starts it in the background and is the form an agent should use.
22
52
 
23
53
  ## Quick Start (Claude Code, Codex)
24
54
 
55
+ ```bash
56
+ cd ~/code/my-app
57
+ aquaman init --agent claude-code # or: --agent codex
58
+ aquaman request aquaman://github/token --env GITHUB_TOKEN
59
+ ```
60
+
61
+ To leave Claude Code's or Codex's own settings untouched, add `--no-hooks`: no hook is installed and no permission prompt changes, and commands that need a key are run as `aquaman-coder exec -- <command>`.
62
+
63
+ `aquaman init --agent` does everything that needs no secret: creates the config, starts the daemon, installs the hooks and the `aquaman-credentials` skill, registers the directory as a project and adds a short block to `CLAUDE.md` or `AGENTS.md`. It never prompts and can be re-run, so the agent can run it itself. `aquaman request` opens a dialog on your machine where you type the value (or approve one already in the vault); the agent gets a status and the reference. Add `--json` to either for machine-readable output.
64
+
65
+ The same steps by hand, if you want to choose the vault backend or keep the agent out of setup:
66
+
25
67
  ```bash
26
68
  aquaman setup # vault wizard (one-time)
27
69
  aquaman daemon & # start the proxy
70
+ aquaman credentials add github token # store a secret yourself
28
71
 
29
72
  aquaman coder project add my-app --path ~/code/my-app \
30
73
  --env ANTHROPIC_API_KEY=aquaman://anthropic/api_key \
@@ -55,11 +98,11 @@ The *child* process saw the real key (your tests, builds, MCP servers, import sc
55
98
  **Use it from your own terminal too.** The same wrapper works without the agent. Just `cd` into a covered project and prefix your command:
56
99
 
57
100
  ```bash
58
- cd ~/code/
101
+ cd ~/code/my-app
59
102
  aquaman-coder exec -- python app/scripts/import.py
60
103
  ```
61
104
 
62
- Same env injection, same redaction on stdout/stderr. Drop it into Makefile targets, shell aliases, or CI runners - anywhere you'd otherwise reach for a `.env` file.
105
+ Same env injection, same redaction on stdout/stderr. Drop it into Makefile targets and shell aliases on your own machine, anywhere you'd otherwise reach for a `.env` file. Your app does not change: it reads its keys from the environment, and this is how they get set on your machine. For CI and production, use your team's secrets manager.
63
106
 
64
107
  When Claude Code or Codex runs a shell command in `~/code/my-app`, aquaman's hook rewrites the command via `updatedInput.command` to wrap it under `aquaman-coder exec`. That wrapper:
65
108
 
@@ -87,9 +130,11 @@ The unified CLI lives in `aquaman-proxy` and delegates `coder` subcommands here:
87
130
 
88
131
  ```
89
132
  aquaman coder
133
+ ├── init --agent <agent> One-step setup for the current directory: project, hooks, skill, instructions block (--json)
134
+ ├── bind NAME=aquaman://s/k Bind an env reference for the project covering the current directory (--json)
90
135
  ├── setup <agent> Install hooks for an agent (claude-code, codex)
91
- ├── doctor Deep diagnostic - projects, broker, per-project vault checks
92
- ├── status Configured projects + hook wiring + broker connectivity
136
+ ├── doctor Deep diagnostic - projects, broker, per-project vault checks (--json)
137
+ ├── status Configured projects + hook wiring + broker connectivity (--json)
93
138
  ├── project list/add/remove ~/.aquaman/projects.yaml CRUD
94
139
  ├── get <ref> Resolve a declared aquaman://service/key reference once
95
140
  ├── exec <cmd> [args...] Run a command with project env injected + output redacted
@@ -175,4 +220,4 @@ The file is `chmod 0o600`. Both the service and key components are validated aga
175
220
 
176
221
  ## License
177
222
 
178
- MIT - see [LICENSE](./LICENSE).
223
+ Apache-2.0. See [LICENSE](./LICENSE) and [NOTICE](./NOTICE).
@@ -65,13 +65,11 @@ export interface HookContext {
65
65
  *
66
66
  * Since Claude Code 2.1.290 permission rules are evaluated against the input
67
67
  * the hook returns, not the command Claude wrote, and a rule never looks
68
- * inside `sh -c '...'`. A bare wrapper therefore hid the real command from
69
- * every deny and ask rule: verified live on 2.1.325, `Bash(echo forbidden*)`
70
- * in `deny` stopped the command outside an aquaman project and let it run
71
- * inside one.
68
+ * inside `sh -c '...'`. A bare wrapper would hide the real command from every
69
+ * deny and ask rule (verified live on 2.1.325).
72
70
  *
73
- * The fix is to leave the original command in the rewritten text as its own
74
- * top-level statement, after an unconditional `exit`. Claude Code splits the
71
+ * So the original command stays in the rewritten text as its own top-level
72
+ * statement, after an unconditional `exit`. Claude Code splits the
75
73
  * text into subcommands and matches its rules against each, so a deny or ask
76
74
  * rule on the original fires exactly as the host would have applied it, from
77
75
  * every rule source (settings files, managed policy, CLI flags, session
@@ -81,6 +79,13 @@ export interface HookContext {
81
79
  * Code refuses to pre-check a command with a variable in it when a rule asks.)
82
80
  */
83
81
  export declare function withPermissionTail(wrapped: string, original: string): string;
82
+ /**
83
+ * Whether the command line starts with the `aquaman` or `aquaman-coder`
84
+ * binary. Only the first word is looked at: a command that is not wrapped
85
+ * runs without credentials and under the host's own permission rules, so
86
+ * anything chained after it gains nothing by being here.
87
+ */
88
+ export declare function isAquamanCommand(command: string): boolean;
84
89
  /**
85
90
  * If the project map has env bindings AND this is a Bash tool call AND
86
91
  * the command isn't already wrapped, rewrite it to run under the
@@ -1 +1 @@
1
- {"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../src/adapters/claude-code/hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAOH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD,MAAM,WAAW,SAAS;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,uEAAuE;IACvE,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;OAGG;IACH,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC;CAChC;AAUD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,SAAS,EAChB,GAAG,GAAE,WAAgB,GACpB,OAAO,CAAC,YAAY,GAAG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CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,SAAS,EAChB,GAAG,GAAE,WAAgB,GACpB,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CA0F9B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,SAAS,EAChB,GAAG,GAAE,WAAgB,GACpB,YAAY,GAAG,IAAI,CAsCrB;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,EAAE,EACf,GAAG,GAAE,WAAgB,GACpB,OAAO,CAAC,MAAM,CAAC,CAmCjB"}
@@ -29,7 +29,7 @@
29
29
  // merged core/). There is no separate `aquaman-core` npm package since
30
30
  // v0.7.0; the vitest alias resolves the same path for tests.
31
31
  import { redact, redactDeep } from 'aquaman-proxy';
32
- import { findProjectForCwd, loadProjects } from '../../projects.js';
32
+ import { findProjectForCwd, loadProjects, parseRef } from '../../projects.js';
33
33
  import { BrokerClient } from '../../broker-client.js';
34
34
  import { handleCodexPreToolUse, handleCodexPostToolUse } from '../codex/hook.js';
35
35
  // Default wrapper uses the direct binary form (`aquaman-coder exec`) rather
@@ -44,13 +44,11 @@ const AQUAMAN_WRAPPER_MARKS = ['aquaman-coder exec', 'aquaman coder exec'];
44
44
  *
45
45
  * Since Claude Code 2.1.290 permission rules are evaluated against the input
46
46
  * the hook returns, not the command Claude wrote, and a rule never looks
47
- * inside `sh -c '...'`. A bare wrapper therefore hid the real command from
48
- * every deny and ask rule: verified live on 2.1.325, `Bash(echo forbidden*)`
49
- * in `deny` stopped the command outside an aquaman project and let it run
50
- * inside one.
47
+ * inside `sh -c '...'`. A bare wrapper would hide the real command from every
48
+ * deny and ask rule (verified live on 2.1.325).
51
49
  *
52
- * The fix is to leave the original command in the rewritten text as its own
53
- * top-level statement, after an unconditional `exit`. Claude Code splits the
50
+ * So the original command stays in the rewritten text as its own top-level
51
+ * statement, after an unconditional `exit`. Claude Code splits the
54
52
  * text into subcommands and matches its rules against each, so a deny or ask
55
53
  * rule on the original fires exactly as the host would have applied it, from
56
54
  * every rule source (settings files, managed policy, CLI flags, session
@@ -62,6 +60,15 @@ const AQUAMAN_WRAPPER_MARKS = ['aquaman-coder exec', 'aquaman coder exec'];
62
60
  export function withPermissionTail(wrapped, original) {
63
61
  return `${wrapped}\nexit\n${original}`;
64
62
  }
63
+ /**
64
+ * Whether the command line starts with the `aquaman` or `aquaman-coder`
65
+ * binary. Only the first word is looked at: a command that is not wrapped
66
+ * runs without credentials and under the host's own permission rules, so
67
+ * anything chained after it gains nothing by being here.
68
+ */
69
+ export function isAquamanCommand(command) {
70
+ return /^\s*(?:aquaman|aquaman-coder)(?:\s|$)/.test(command);
71
+ }
65
72
  /**
66
73
  * If the project map has env bindings AND this is a Bash tool call AND
67
74
  * the command isn't already wrapped, rewrite it to run under the
@@ -92,12 +99,49 @@ export async function handlePreToolUse(event, ctx = {}) {
92
99
  await broker.health();
93
100
  }
94
101
  catch (err) {
102
+ // aquaman's own commands are how the proxy gets started, so a stopped
103
+ // proxy never blocks them: they go to the host's normal permission
104
+ // handling. While the proxy is up they are wrapped like any other
105
+ // command, which keeps `aquaman get` output under value redaction.
106
+ if (isAquamanCommand(command))
107
+ return null;
108
+ const agent = ctx.host === 'codex' ? 'codex' : 'claude-code';
109
+ // The client's own hint names the foreground command; the one below is the one an agent can use.
110
+ const message = err.message;
111
+ const hint = message.indexOf('Start it with:');
112
+ const reason = (hint === -1 ? message : message.slice(0, hint)).trim().replace(/\.$/, '');
95
113
  return {
96
114
  hookSpecificOutput: {
97
115
  hookEventName: 'PreToolUse',
98
116
  permissionDecision: 'deny',
99
- permissionDecisionReason: `aquaman: proxy not reachable (${err.message}). ` +
100
- `Start it with: aquaman daemon`,
117
+ permissionDecisionReason: `aquaman: proxy not reachable (${reason}), so this project's credentials ` +
118
+ `cannot be injected. Start it with: aquaman init --agent ${agent} ` +
119
+ `(aquaman commands are not blocked; \`aquaman daemon\` runs in the foreground, use it in a terminal of your own)`,
120
+ },
121
+ };
122
+ }
123
+ // Wrapping comes with an `allow`, so it is only done when the project has a
124
+ // credential to inject. A project whose bindings all point at nothing gets
125
+ // no decision: the command runs as the host would have run it, prompts
126
+ // included. Otherwise registering a project and binding a made-up reference
127
+ // would be a way to switch permission prompts off.
128
+ const refs = Object.values(match.config.env).map(parseRef).filter((r) => r !== null);
129
+ let anyAvailable = true;
130
+ try {
131
+ anyAvailable = (await broker.available(refs)).some(Boolean);
132
+ }
133
+ catch {
134
+ // A proxy that cannot answer still gets the wrapper, which stops the
135
+ // command itself when it has nothing to inject.
136
+ anyAvailable = true;
137
+ }
138
+ if (!anyAvailable) {
139
+ return ctx.host === 'codex' ? null : {
140
+ hookSpecificOutput: {
141
+ hookEventName: 'PreToolUse',
142
+ additionalContext: `aquaman: none of this project's credentials (${Object.keys(match.config.env).join(', ')}) ` +
143
+ `are in the vault yet, so this command runs without them. ` +
144
+ `Ask for one with: aquaman request aquaman://<service>/<key> --env <NAME>`,
101
145
  },
102
146
  };
103
147
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hook.js","sourceRoot":"","sources":["../../../src/adapters/claude-code/hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,iEAAiE;AACjE,uEAAuE;AACvE,6DAA6D;AAC7D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAuCjF,4EAA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AAC,KAAK,EAAE,GAAG,CAAC,CAAC;gBAChG,MAAM;YACR,KAAK,aAAa;gBAChB,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;gBACjF,MAAM;YACR;gBACE,OAAO,CAAC,CAAC;QACb,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,+BAAgC,GAAa,CAAC,OAAO,IAAI,CAAC,CAAC;QAChF,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,CAAC,QAAQ;QAAE,OAAO,CAAC,CAAC;IACxB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC/C,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;GAGG;AACH,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC;AACzC,CAAC"}
@@ -85,11 +85,8 @@ export interface SandboxSocketStatus {
85
85
  * reachable from sandboxed commands on `platform`.
86
86
  */
87
87
  export declare function sandboxSocketStatus(settingsFiles: string[], socketPath?: string, platform?: NodeJS.Platform): SandboxSocketStatus;
88
- /**
89
- * Ensure ~/.claude/settings.json has PreToolUse + PostToolUse hooks
90
- * pointing at `aquaman coder hook` (the canonical unified-CLI form;
91
- * the `aquaman` binary's `coder` shim execs `aquaman-coder` under the hood).
92
- */
88
+ /** Whether the settings file already runs the aquaman hook, in either spelling. */
89
+ export declare function claudeCodeHooksInstalled(settingsPath?: string): boolean;
93
90
  export declare function installClaudeCodeHooks(opts?: SetupOptions): SetupResult;
94
91
  /**
95
92
  * Remove aquaman coder hooks from settings.json (matches both legacy
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","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GAAE,MAA8B,GAAG,OAAO,CAM9F;AAED,wBAAgB,sBAAsB,CAAC,IAAI,GAAE,YAAiB,GAAG,WAAW,CAqF3E;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,GAAE,YAAiB,GAAG,WAAW,CA4D7E"}
@@ -122,12 +122,23 @@ export function sandboxSocketStatus(settingsFiles, socketPath = defaultSocketPat
122
122
  }
123
123
  /**
124
124
  * Ensure ~/.claude/settings.json has PreToolUse + PostToolUse hooks
125
- * pointing at `aquaman coder hook` (the canonical unified-CLI form;
126
- * the `aquaman` binary's `coder` shim execs `aquaman-coder` under the hood).
125
+ * pointing at `aquaman-coder hook`. The hook runs on every tool call, so it
126
+ * names the binary itself; `aquaman coder hook` reaches the same code through
127
+ * a second process and is still recognised as installed.
127
128
  */
129
+ const HOOK_COMMAND = 'aquaman-coder hook';
130
+ /** Whether the settings file already runs the aquaman hook, in either spelling. */
131
+ export function claudeCodeHooksInstalled(settingsPath = defaultSettingsPath()) {
132
+ try {
133
+ return /aquaman(-| )coder hook/.test(fs.readFileSync(settingsPath, 'utf-8'));
134
+ }
135
+ catch {
136
+ return false;
137
+ }
138
+ }
128
139
  export function installClaudeCodeHooks(opts = {}) {
129
140
  const settingsPath = opts.settingsPath ?? defaultSettingsPath();
130
- const hookCommand = opts.hookCommand ?? 'aquaman coder hook';
141
+ const hookCommand = opts.hookCommand ?? HOOK_COMMAND;
131
142
  const dir = path.dirname(settingsPath);
132
143
  if (!fs.existsSync(dir)) {
133
144
  fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
@@ -209,7 +220,7 @@ export function installClaudeCodeHooks(opts = {}) {
209
220
  */
210
221
  export function uninstallClaudeCodeHooks(opts = {}) {
211
222
  const settingsPath = opts.settingsPath ?? defaultSettingsPath();
212
- const hookCommand = opts.hookCommand ?? 'aquaman coder hook';
223
+ const hookCommand = opts.hookCommand ?? HOOK_COMMAND;
213
224
  if (!fs.existsSync(settingsPath)) {
214
225
  return { path: settingsPath, changed: false, before: null, after: {}, sandboxSocket: 'absent' };
215
226
  }