aquaman-coder 0.14.1 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -14
- package/dist/adapters/claude-code/hook.d.ts +5 -0
- package/dist/adapters/claude-code/hook.d.ts.map +1 -1
- package/dist/adapters/claude-code/hook.js +4 -2
- package/dist/adapters/claude-code/hook.js.map +1 -1
- package/dist/adapters/claude-code/setup.d.ts +43 -0
- package/dist/adapters/claude-code/setup.d.ts.map +1 -1
- package/dist/adapters/claude-code/setup.js +126 -3
- package/dist/adapters/claude-code/setup.js.map +1 -1
- package/dist/adapters/codex/hook.d.ts +23 -0
- package/dist/adapters/codex/hook.d.ts.map +1 -0
- package/dist/adapters/codex/hook.js +64 -0
- package/dist/adapters/codex/hook.js.map +1 -0
- package/dist/adapters/codex/setup.d.ts +60 -0
- package/dist/adapters/codex/setup.d.ts.map +1 -0
- package/dist/adapters/codex/setup.js +116 -0
- package/dist/adapters/codex/setup.js.map +1 -0
- package/dist/broker-client.d.ts +29 -0
- package/dist/broker-client.d.ts.map +1 -1
- package/dist/broker-client.js +48 -4
- package/dist/broker-client.js.map +1 -1
- package/dist/cli/index.d.ts +2 -3
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +160 -49
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/projects.d.ts +4 -0
- package/dist/projects.d.ts.map +1 -1
- package/dist/projects.js +6 -1
- package/dist/projects.js.map +1 -1
- package/package.json +4 -6
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Pair with [`aquaman-proxy`](../proxy) (the vault + daemon + audit core). Togethe
|
|
|
10
10
|
2. **Redact secrets from tool output.** `aquaman-coder exec` pipes stdout/stderr through a pattern redactor before printing - secret-shaped strings (AWS, GitHub, Stripe, Slack, OpenAI, Anthropic, JWTs, PEM private keys) become `[REDACTED:kind]` before they enter the agent's transcript.
|
|
11
11
|
3. **Stay isolated from the proxy.** `aquaman-coder` only talks to `aquaman-proxy` over `~/.aquaman/proxy.sock` (UDS, `chmod 0o600`) via the broker endpoint `POST /broker/resolve`. No shared memory, no network exposure.
|
|
12
12
|
|
|
13
|
-
**Bring your own vault.** Aquaman has no house vault. It injects credentials from the secret store you already run: Keychain, 1Password, HashiCorp Vault, Bitwarden, KeePassXC, systemd-creds, or encrypted-file. No new store to adopt, no migration.
|
|
13
|
+
**Bring your own vault.** Aquaman has no house vault. It injects credentials from the secret store you already run: Keychain, 1Password, HashiCorp Vault, Bitwarden, Keeper, KeePassXC, systemd-creds, or encrypted-file. No new store to adopt, no migration.
|
|
14
14
|
|
|
15
15
|
## Install
|
|
16
16
|
|
|
@@ -20,7 +20,7 @@ npm install -g aquaman-proxy aquaman-coder
|
|
|
20
20
|
|
|
21
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).
|
|
22
22
|
|
|
23
|
-
## Quick Start (Claude Code)
|
|
23
|
+
## Quick Start (Claude Code, Codex)
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
26
|
aquaman setup # vault wizard (one-time)
|
|
@@ -30,10 +30,13 @@ aquaman coder project add my-app --path ~/code/my-app \
|
|
|
30
30
|
--env ANTHROPIC_API_KEY=aquaman://anthropic/api_key \
|
|
31
31
|
--env GITHUB_TOKEN=aquaman://github/token
|
|
32
32
|
aquaman coder setup claude-code # install hook in ~/.claude/settings.json
|
|
33
|
+
# or: aquaman coder setup codex # install hook in ~/.codex/hooks.json
|
|
33
34
|
aquaman coder doctor # verify
|
|
34
35
|
```
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
Running `project add` again on the same name adds to the project: new paths are appended and new `--env` bindings are merged in (an existing name takes the new ref). `--replace` overwrites the project instead, and `project remove my-app --env GITHUB_TOKEN` drops a single binding.
|
|
38
|
+
|
|
39
|
+
**See it for yourself (the 30-second aha):** restart Claude Code (or Codex), open a new session inside `~/code/my-app`, and ask the agent to run:
|
|
37
40
|
|
|
38
41
|
```
|
|
39
42
|
printenv | grep ANTHROPIC_API_KEY
|
|
@@ -58,33 +61,47 @@ aquaman-coder exec -- python app/scripts/import.py
|
|
|
58
61
|
|
|
59
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.
|
|
60
63
|
|
|
61
|
-
When Claude Code runs a
|
|
64
|
+
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:
|
|
62
65
|
|
|
63
66
|
- Resolves each `aquaman://service/key` reference via the broker (`POST /broker/resolve` over UDS). Credentials are materialized for one command, not for the agent's lifetime.
|
|
64
67
|
- Pipes stdout/stderr through a redactor that prepends a value-based pattern for each resolved value: **whatever string was injected gets redacted, regardless of shape** (Atlassian tokens, Notion secrets, internal-API keys - none of them need to match a known provider format). Generic shape-based patterns (sk-ant-, ghp_, sk_live_, AKIA…, JWTs, PEM blocks, ATATT3xF…) still run after as defense-in-depth for secrets the child surfaces that we did NOT inject.
|
|
65
68
|
- Cleans up when the command exits.
|
|
66
69
|
|
|
70
|
+
### Transport
|
|
71
|
+
|
|
72
|
+
`aquaman-coder` talks to the proxy over the Unix socket `~/.aquaman/proxy.sock` (`0600`) and nothing else: no port, no token, no network. Only processes running as you can reach it. Hermes and OpenClaw use a token-gated loopback listener instead, because neither can dial a socket; that listener is not part of the coder path. See the [root README](https://github.com/tech4242/aquaman#transports-and-access-control).
|
|
73
|
+
|
|
74
|
+
### What the broker hands out
|
|
75
|
+
|
|
76
|
+
The daemon's broker (`aquaman daemon`) materializes only refs you declared, meaning the `env` refs in `projects.yaml` plus anything added with `aquaman broker allow` (v0.15.0+). Everything else is refused before the vault is consulted, and so is every request to a proxy started by the OpenClaw plugin. `aquaman broker list` shows what's declared. Declaring a ref is an explicit opt-in: any process running as you can fetch it from the daemon, which is exactly what the `exec` wrapper does.
|
|
77
|
+
|
|
78
|
+
### Claude Code's sandbox
|
|
79
|
+
|
|
80
|
+
Claude Code's sandbox denies Unix-socket connects it hasn't allowlisted, so a sandboxed `aquaman-coder exec` can't reach the broker by default (you'd see a "blocked … most likely by Claude Code's sandbox" error). On **macOS**, `aquaman coder setup claude-code` adds exactly the proxy socket to `sandbox.network.allowUnixSockets` in `~/.claude/settings.json`. It never adds a directory or `allowAllUnixSockets`, and never turns the sandbox on or off. `aquaman coder doctor` checks the merged user, managed, and project settings.
|
|
81
|
+
|
|
82
|
+
**Linux/WSL2:** Claude Code ignores `allowUnixSockets` there (seccomp can't filter by path), so sandboxed commands can reach the broker only with `sandbox.network.allowAllUnixSockets: true`, which opens every Unix socket to them.
|
|
83
|
+
|
|
67
84
|
## CLI surface
|
|
68
85
|
|
|
69
86
|
The unified CLI lives in `aquaman-proxy` and delegates `coder` subcommands here:
|
|
70
87
|
|
|
71
88
|
```
|
|
72
89
|
aquaman coder
|
|
73
|
-
├── setup <agent> Install hooks for an agent (claude-code
|
|
90
|
+
├── setup <agent> Install hooks for an agent (claude-code, codex)
|
|
74
91
|
├── doctor Deep diagnostic - projects, broker, per-project vault checks
|
|
75
92
|
├── status Configured projects + hook wiring + broker connectivity
|
|
76
93
|
├── project list/add/remove ~/.aquaman/projects.yaml CRUD
|
|
77
|
-
├── get <ref> Resolve
|
|
94
|
+
├── get <ref> Resolve a declared aquaman://service/key reference once
|
|
78
95
|
├── exec <cmd> [args...] Run a command with project env injected + output redacted
|
|
79
|
-
└── hook Stdio hook handler (invoked by Claude Code; not user-facing)
|
|
96
|
+
└── hook Stdio hook handler (invoked by Claude Code or Codex; not user-facing)
|
|
80
97
|
```
|
|
81
98
|
|
|
82
|
-
The `aquaman-coder` binary works directly too. `aquaman coder X` ≡ `aquaman-coder X`. The unified form is the documented one; the standalone binary is what
|
|
99
|
+
The `aquaman-coder` binary works directly too. `aquaman coder X` ≡ `aquaman-coder X`. The unified form is the documented one; the standalone binary is what the agent's hook runs per tool call (faster, skips the shim).
|
|
83
100
|
|
|
84
101
|
## Architecture
|
|
85
102
|
|
|
86
103
|
```
|
|
87
|
-
Claude Code / Codex
|
|
104
|
+
Claude Code / Codex
|
|
88
105
|
│ hook stdin/stdout JSON
|
|
89
106
|
▼
|
|
90
107
|
aquaman-coder (this package)
|
|
@@ -94,13 +111,37 @@ Claude Code / Codex / OpenCode / Cursor
|
|
|
94
111
|
│
|
|
95
112
|
▼
|
|
96
113
|
Vault backends (Keychain, 1Password, HashiCorp Vault, KeePassXC,
|
|
97
|
-
encrypted-file, systemd-creds, Bitwarden)
|
|
114
|
+
encrypted-file, systemd-creds, Bitwarden, Keeper)
|
|
98
115
|
```
|
|
99
116
|
|
|
100
117
|
The hook uses Claude Code's real protocol (verified against the live docs):
|
|
101
118
|
|
|
102
119
|
- **PreToolUse** on Bash: emits `{ hookSpecificOutput: { permissionDecision: "allow", updatedInput: { command: "aquaman-coder exec -- sh -c '...'" } } }`. Claude Code runs the rewritten command in its child shell; the wrapper does the broker resolve.
|
|
103
|
-
- **PostToolUse**:
|
|
120
|
+
- **PostToolUse**: runs the redactor over every tool's output and rewrites it via `updatedToolOutput` (v0.14.0+) before it reaches the transcript. That covers Read/Grep surfacing on-disk secrets, MCP tools, and unwrapped Bash. `aquaman-coder exec` still owns value-based redaction of what it injected. Set `AQUAMAN_DISABLE_OUTPUT_REWRITE=1` on Claude Code < 2.1.170 to fall back to a warning via `additionalContext`. Caveat from Claude Code's docs: OpenTelemetry tool spans record the original output before hooks run, so this redaction doesn't reach OTel exports.
|
|
121
|
+
- Credentials are never passed through hook output. The hook contract has no env-injection field for PreToolUse, and we wouldn't use one: hook stdout transits Claude Code's process, which is what the broker + `exec` wrapper exists to avoid.
|
|
122
|
+
|
|
123
|
+
### Codex
|
|
124
|
+
|
|
125
|
+
`aquaman coder setup codex` writes `PreToolUse` and `PostToolUse` handlers for the shell tool (`matcher: "Bash"`) into `$CODEX_HOME/hooks.json` (default `~/.codex/hooks.json`). Codex's hook contract has the same shape as Claude Code's, with three differences that matter here:
|
|
126
|
+
|
|
127
|
+
- **Codex runs a new hook only after you approve it.** Start `codex` after setup and trust the aquaman hooks in the startup hook review. `aquaman coder doctor` reports hooks that are installed but not yet trusted.
|
|
128
|
+
- **Codex's sandbox blocks the proxy socket by default** (`EPERM`). The rewritten command runs inside it. Allow the socket with a permissions profile in `config.toml`; `unix_sockets` alone is not enough, the profile also needs `network.enabled = true`. Setup prints this snippet with your paths filled in and does not edit `config.toml` itself:
|
|
129
|
+
|
|
130
|
+
```toml
|
|
131
|
+
default_permissions = "aquaman"
|
|
132
|
+
|
|
133
|
+
[permissions.aquaman]
|
|
134
|
+
extends = ":workspace"
|
|
135
|
+
|
|
136
|
+
[permissions.aquaman.network]
|
|
137
|
+
enabled = true
|
|
138
|
+
unix_sockets = { "/Users/you/.aquaman/proxy.sock" = "allow" }
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`network.enabled = true` also affects other outbound traffic from sandboxed commands, so check it against your own network policy.
|
|
142
|
+
- **Output redaction happens inside the wrapper only.** Codex gives hooks no way to rewrite shell output, so `PostToolUse` only warns when it sees secret patterns. Commands run under `aquaman-coder exec` are still scrubbed before Codex sees them.
|
|
143
|
+
|
|
144
|
+
Codex fails open on invalid hook output (the original command runs), so the rewrite sends only `permissionDecision` and `updatedInput.command`.
|
|
104
145
|
|
|
105
146
|
See [`docs/PACKAGES.md`](../../docs/PACKAGES.md) for cross-package import rules.
|
|
106
147
|
|
|
@@ -128,9 +169,7 @@ The file is `chmod 0o600`. Both the service and key components are validated aga
|
|
|
128
169
|
| Adapter | Status | Release |
|
|
129
170
|
|---|---|---|
|
|
130
171
|
| Claude Code | shipped | v0.12.0 |
|
|
131
|
-
| Codex CLI |
|
|
132
|
-
| OpenCode (sst) | planned | v0.14.0 |
|
|
133
|
-
| Cursor | planned | v0.15.0 |
|
|
172
|
+
| Codex CLI | shipped | v0.16.0 |
|
|
134
173
|
|
|
135
174
|
## License
|
|
136
175
|
|
|
@@ -54,6 +54,11 @@ export interface HookContext {
|
|
|
54
54
|
* Defaults to the AQUAMAN_DISABLE_OUTPUT_REWRITE env var.
|
|
55
55
|
*/
|
|
56
56
|
disableOutputRewrite?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Which host invoked the hook. Codex (v0.16.0+) shares the event shape but
|
|
59
|
+
* not every output field, so its handlers live in adapters/codex/hook.ts.
|
|
60
|
+
*/
|
|
61
|
+
host?: 'claude-code' | 'codex';
|
|
57
62
|
}
|
|
58
63
|
/**
|
|
59
64
|
* If the project map has env bindings AND this is a Bash tool call AND
|
|
@@ -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;
|
|
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;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,SAAS,EAChB,GAAG,GAAE,WAAgB,GACpB,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAmD9B;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"}
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
import { redact, redactDeep } from 'aquaman-proxy';
|
|
32
32
|
import { findProjectForCwd, loadProjects } from '../../projects.js';
|
|
33
33
|
import { BrokerClient } from '../../broker-client.js';
|
|
34
|
+
import { handleCodexPreToolUse, handleCodexPostToolUse } from '../codex/hook.js';
|
|
34
35
|
// Default wrapper uses the direct binary form (`aquaman-coder exec`) rather
|
|
35
36
|
// than the unified-CLI form (`aquaman coder exec`) to skip the shim's
|
|
36
37
|
// process-spawn overhead on every Bash tool call. Both forms work; the
|
|
@@ -155,12 +156,13 @@ export async function runHookFromStdin(_argv, ctx = {}) {
|
|
|
155
156
|
}
|
|
156
157
|
let decision = null;
|
|
157
158
|
try {
|
|
159
|
+
const codex = ctx.host === 'codex';
|
|
158
160
|
switch (event.hook_event_name) {
|
|
159
161
|
case 'PreToolUse':
|
|
160
|
-
decision = await handlePreToolUse(event, ctx);
|
|
162
|
+
decision = codex ? await handleCodexPreToolUse(event, ctx) : await handlePreToolUse(event, ctx);
|
|
161
163
|
break;
|
|
162
164
|
case 'PostToolUse':
|
|
163
|
-
decision = handlePostToolUse(event, ctx);
|
|
165
|
+
decision = codex ? handleCodexPostToolUse(event) : handlePostToolUse(event, ctx);
|
|
164
166
|
break;
|
|
165
167
|
default:
|
|
166
168
|
return 0;
|
|
@@ -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;
|
|
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,4EAA4E;AAC5E,sEAAsE;AACtE,uEAAuE;AACvE,yEAAyE;AACzE,kBAAkB;AAClB,MAAM,eAAe,GAAG,uBAAuB,CAAC;AAChD,MAAM,qBAAqB,GAAG,CAAC,oBAAoB,EA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AAC,CAAC,MAAM,gBAAgB,CAAC,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"}
|
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
* `~/.claude/settings.json` so Claude Code invokes aquaman-coder on
|
|
4
4
|
* each tool call.
|
|
5
5
|
*
|
|
6
|
+
* On macOS it also allowlists the aquaman proxy socket for Claude Code's
|
|
7
|
+
* sandbox (v0.15.0+). The sandbox denies every Unix-socket connect by default,
|
|
8
|
+
* so a sandboxed `aquaman-coder exec` fails with EPERM before it can reach
|
|
9
|
+
* the broker. `sandbox.network.allowUnixSockets` takes exact socket paths
|
|
10
|
+
* (directories match as a prefix; globs don't work) and Claude Code merges
|
|
11
|
+
* list settings across scopes. We add exactly our socket: never the directory,
|
|
12
|
+
* never `allowAllUnixSockets`, never `sandbox.enabled`. On Linux/WSL2 the
|
|
13
|
+
* list is ignored (seccomp can't filter by path), so setup leaves the sandbox
|
|
14
|
+
* alone and doctor explains the tradeoff.
|
|
15
|
+
*
|
|
6
16
|
* Never overwrites unrelated keys. Atomic write via .tmp + rename.
|
|
7
17
|
*/
|
|
8
18
|
export interface ClaudeSettings {
|
|
@@ -20,13 +30,46 @@ export declare function defaultSettingsPath(): string;
|
|
|
20
30
|
export interface SetupOptions {
|
|
21
31
|
settingsPath?: string;
|
|
22
32
|
hookCommand?: string;
|
|
33
|
+
/** Proxy socket to allowlist for the sandbox. Default: defaultSocketPath(). */
|
|
34
|
+
socketPath?: string;
|
|
35
|
+
/** Override for tests. Default: process.platform. */
|
|
36
|
+
platform?: NodeJS.Platform;
|
|
23
37
|
}
|
|
24
38
|
export interface SetupResult {
|
|
25
39
|
path: string;
|
|
26
40
|
changed: boolean;
|
|
27
41
|
before: ClaudeSettings | null;
|
|
28
42
|
after: ClaudeSettings;
|
|
43
|
+
/**
|
|
44
|
+
* What happened to the sandbox socket allowance: `added` / `present` on
|
|
45
|
+
* macOS, `removed` / `absent` on uninstall, `unsupported-platform` on
|
|
46
|
+
* Linux/WSL2 (where allowUnixSockets is ignored).
|
|
47
|
+
*/
|
|
48
|
+
sandboxSocket: 'added' | 'present' | 'removed' | 'absent' | 'unsupported-platform';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Does one `allowUnixSockets` entry cover `socketPath`? Mirrors the sandbox's
|
|
52
|
+
* Seatbelt rule `(remote unix-socket (subpath <entry>))`: the entry matches
|
|
53
|
+
* the path itself or anything beneath it, after `~` expansion and symlink
|
|
54
|
+
* resolution (macOS /tmp -> /private/tmp). Globs are not patterns there, so
|
|
55
|
+
* they don't count here either.
|
|
56
|
+
*/
|
|
57
|
+
export declare function socketAllowedByEntry(entry: string, socketPath: string): boolean;
|
|
58
|
+
export interface SandboxSocketStatus {
|
|
59
|
+
/** Some settings file turns the sandbox on. */
|
|
60
|
+
sandboxEnabled: boolean;
|
|
61
|
+
/** Connects to the socket are permitted on this platform by the merged settings. */
|
|
62
|
+
socketAllowed: boolean;
|
|
63
|
+
/** Which files were read (existing ones only). */
|
|
64
|
+
sources: string[];
|
|
29
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Merge the sandbox bits of several Claude Code settings files the way Claude
|
|
68
|
+
* Code does for these keys (lists concatenate, booleans: any true wins for
|
|
69
|
+
* `enabled` / `allowAllUnixSockets`) and decide whether the proxy socket is
|
|
70
|
+
* reachable from sandboxed commands on `platform`.
|
|
71
|
+
*/
|
|
72
|
+
export declare function sandboxSocketStatus(settingsFiles: string[], socketPath?: string, platform?: NodeJS.Platform): SandboxSocketStatus;
|
|
30
73
|
/**
|
|
31
74
|
* Ensure ~/.claude/settings.json has PreToolUse + PostToolUse hooks
|
|
32
75
|
* pointing at `aquaman coder hook` (the canonical unified-CLI form;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../src/adapters/claude-code/setup.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../src/adapters/claude-code/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,SAAS,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAC,CAAC;IACxG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED,MAAM,WAAW,YAAY;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,KAAK,EAAE,cAAc,CAAC;IACtB;;;;OAIG;IACH,aAAa,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,sBAAsB,CAAC;CACpF;AAmBD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAS/E;AASD,MAAM,WAAW,mBAAmB;IAClC,+CAA+C;IAC/C,cAAc,EAAE,OAAO,CAAC;IACxB,oFAAoF;IACpF,aAAa,EAAE,OAAO,CAAC;IACvB,kDAAkD;IAClD,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,MAAM,EAAE,EACvB,UAAU,GAAE,MAA4B,EACxC,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,mBAAmB,CAsBrB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,GAAE,YAAiB,GAAG,WAAW,CAyE3E;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,GAAE,YAAiB,GAAG,WAAW,CA4D7E"}
|
|
@@ -3,14 +3,97 @@
|
|
|
3
3
|
* `~/.claude/settings.json` so Claude Code invokes aquaman-coder on
|
|
4
4
|
* each tool call.
|
|
5
5
|
*
|
|
6
|
+
* On macOS it also allowlists the aquaman proxy socket for Claude Code's
|
|
7
|
+
* sandbox (v0.15.0+). The sandbox denies every Unix-socket connect by default,
|
|
8
|
+
* so a sandboxed `aquaman-coder exec` fails with EPERM before it can reach
|
|
9
|
+
* the broker. `sandbox.network.allowUnixSockets` takes exact socket paths
|
|
10
|
+
* (directories match as a prefix; globs don't work) and Claude Code merges
|
|
11
|
+
* list settings across scopes. We add exactly our socket: never the directory,
|
|
12
|
+
* never `allowAllUnixSockets`, never `sandbox.enabled`. On Linux/WSL2 the
|
|
13
|
+
* list is ignored (seccomp can't filter by path), so setup leaves the sandbox
|
|
14
|
+
* alone and doctor explains the tradeoff.
|
|
15
|
+
*
|
|
6
16
|
* Never overwrites unrelated keys. Atomic write via .tmp + rename.
|
|
7
17
|
*/
|
|
8
18
|
import * as fs from 'node:fs';
|
|
9
19
|
import * as os from 'node:os';
|
|
10
20
|
import * as path from 'node:path';
|
|
21
|
+
import { defaultSocketPath } from '../../broker-client.js';
|
|
11
22
|
export function defaultSettingsPath() {
|
|
12
23
|
return path.join(os.homedir(), '.claude', 'settings.json');
|
|
13
24
|
}
|
|
25
|
+
function expandHome(p) {
|
|
26
|
+
return p === '~' || p.startsWith('~/') ? path.join(os.homedir(), p.slice(1)) : p;
|
|
27
|
+
}
|
|
28
|
+
/** realpath that tolerates a missing leaf (the socket only exists while the daemon runs). */
|
|
29
|
+
function realpathLoose(p) {
|
|
30
|
+
try {
|
|
31
|
+
return fs.realpathSync(p);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
try {
|
|
35
|
+
return path.join(fs.realpathSync(path.dirname(p)), path.basename(p));
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return path.resolve(p);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Does one `allowUnixSockets` entry cover `socketPath`? Mirrors the sandbox's
|
|
44
|
+
* Seatbelt rule `(remote unix-socket (subpath <entry>))`: the entry matches
|
|
45
|
+
* the path itself or anything beneath it, after `~` expansion and symlink
|
|
46
|
+
* resolution (macOS /tmp -> /private/tmp). Globs are not patterns there, so
|
|
47
|
+
* they don't count here either.
|
|
48
|
+
*/
|
|
49
|
+
export function socketAllowedByEntry(entry, socketPath) {
|
|
50
|
+
if (typeof entry !== 'string' || entry.length === 0 || /[*?[]/.test(entry))
|
|
51
|
+
return false;
|
|
52
|
+
const want = realpathLoose(socketPath);
|
|
53
|
+
// Trim trailing slashes without a regex: /\/+$/ backtracks polynomially on
|
|
54
|
+
// an entry ending in many slashes, and entries come from a settings file
|
|
55
|
+
// (CodeQL js/polynomial-redos).
|
|
56
|
+
let have = realpathLoose(expandHome(entry));
|
|
57
|
+
while (have.length > 1 && have.endsWith('/'))
|
|
58
|
+
have = have.slice(0, -1);
|
|
59
|
+
return want === have || want.startsWith(have + '/');
|
|
60
|
+
}
|
|
61
|
+
function sandboxNetwork(settings) {
|
|
62
|
+
const sandbox = settings.sandbox;
|
|
63
|
+
return sandbox && typeof sandbox === 'object' ? sandbox.network : undefined;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Merge the sandbox bits of several Claude Code settings files the way Claude
|
|
67
|
+
* Code does for these keys (lists concatenate, booleans: any true wins for
|
|
68
|
+
* `enabled` / `allowAllUnixSockets`) and decide whether the proxy socket is
|
|
69
|
+
* reachable from sandboxed commands on `platform`.
|
|
70
|
+
*/
|
|
71
|
+
export function sandboxSocketStatus(settingsFiles, socketPath = defaultSocketPath(), platform = process.platform) {
|
|
72
|
+
let sandboxEnabled = false;
|
|
73
|
+
let allowAll = false;
|
|
74
|
+
const entries = [];
|
|
75
|
+
const sources = [];
|
|
76
|
+
for (const file of settingsFiles) {
|
|
77
|
+
let parsed;
|
|
78
|
+
try {
|
|
79
|
+
parsed = JSON.parse(fs.readFileSync(file, 'utf-8'));
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
sources.push(file);
|
|
85
|
+
const sandbox = parsed.sandbox;
|
|
86
|
+
if (sandbox && typeof sandbox === 'object' && sandbox.enabled === true)
|
|
87
|
+
sandboxEnabled = true;
|
|
88
|
+
const net = sandboxNetwork(parsed);
|
|
89
|
+
if (net?.allowAllUnixSockets === true)
|
|
90
|
+
allowAll = true;
|
|
91
|
+
if (Array.isArray(net?.allowUnixSockets))
|
|
92
|
+
entries.push(...net.allowUnixSockets);
|
|
93
|
+
}
|
|
94
|
+
const socketAllowed = allowAll || (platform === 'darwin' && entries.some((e) => socketAllowedByEntry(e, socketPath)));
|
|
95
|
+
return { sandboxEnabled, socketAllowed, sources };
|
|
96
|
+
}
|
|
14
97
|
/**
|
|
15
98
|
* Ensure ~/.claude/settings.json has PreToolUse + PostToolUse hooks
|
|
16
99
|
* pointing at `aquaman coder hook` (the canonical unified-CLI form;
|
|
@@ -52,6 +135,25 @@ export function installClaudeCodeHooks(opts = {}) {
|
|
|
52
135
|
});
|
|
53
136
|
settings.hooks[event] = list;
|
|
54
137
|
}
|
|
138
|
+
// Sandbox socket allowance (macOS only; see the header comment).
|
|
139
|
+
const platform = opts.platform ?? process.platform;
|
|
140
|
+
const socketPath = opts.socketPath ?? defaultSocketPath();
|
|
141
|
+
let sandboxSocket = 'unsupported-platform';
|
|
142
|
+
if (platform === 'darwin') {
|
|
143
|
+
const existing = sandboxNetwork(settings);
|
|
144
|
+
const list = Array.isArray(existing?.allowUnixSockets) ? existing.allowUnixSockets : [];
|
|
145
|
+
if (existing?.allowAllUnixSockets === true || list.some((e) => socketAllowedByEntry(e, socketPath))) {
|
|
146
|
+
sandboxSocket = 'present';
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const sandbox = (settings.sandbox && typeof settings.sandbox === 'object' ? settings.sandbox : {});
|
|
150
|
+
const network = (sandbox.network && typeof sandbox.network === 'object' ? sandbox.network : {});
|
|
151
|
+
network.allowUnixSockets = [...list, socketPath];
|
|
152
|
+
sandbox.network = network;
|
|
153
|
+
settings.sandbox = sandbox;
|
|
154
|
+
sandboxSocket = 'added';
|
|
155
|
+
}
|
|
156
|
+
}
|
|
55
157
|
const after = settings;
|
|
56
158
|
const changed = JSON.stringify(before) !== JSON.stringify(after);
|
|
57
159
|
if (changed) {
|
|
@@ -59,7 +161,7 @@ export function installClaudeCodeHooks(opts = {}) {
|
|
|
59
161
|
fs.writeFileSync(tmp, JSON.stringify(after, null, 2), { mode: 0o600 });
|
|
60
162
|
fs.renameSync(tmp, settingsPath);
|
|
61
163
|
}
|
|
62
|
-
return { path: settingsPath, changed, before, after };
|
|
164
|
+
return { path: settingsPath, changed, before, after, sandboxSocket };
|
|
63
165
|
}
|
|
64
166
|
/**
|
|
65
167
|
* Remove aquaman coder hooks from settings.json (matches both legacy
|
|
@@ -69,7 +171,7 @@ export function uninstallClaudeCodeHooks(opts = {}) {
|
|
|
69
171
|
const settingsPath = opts.settingsPath ?? defaultSettingsPath();
|
|
70
172
|
const hookCommand = opts.hookCommand ?? 'aquaman coder hook';
|
|
71
173
|
if (!fs.existsSync(settingsPath)) {
|
|
72
|
-
return { path: settingsPath, changed: false, before: null, after: {} };
|
|
174
|
+
return { path: settingsPath, changed: false, before: null, after: {}, sandboxSocket: 'absent' };
|
|
73
175
|
}
|
|
74
176
|
const raw = fs.readFileSync(settingsPath, 'utf-8');
|
|
75
177
|
const before = JSON.parse(raw);
|
|
@@ -92,12 +194,33 @@ export function uninstallClaudeCodeHooks(opts = {}) {
|
|
|
92
194
|
delete settings.hooks;
|
|
93
195
|
}
|
|
94
196
|
}
|
|
197
|
+
// Remove only the exact socket entry setup adds; leave user-written entries
|
|
198
|
+
// (directories, other sockets, allowAllUnixSockets) alone. Prune containers
|
|
199
|
+
// only when this removal emptied them.
|
|
200
|
+
const socketPath = opts.socketPath ?? defaultSocketPath();
|
|
201
|
+
let sandboxSocket = 'absent';
|
|
202
|
+
const net = sandboxNetwork(settings);
|
|
203
|
+
if (Array.isArray(net?.allowUnixSockets) && net.allowUnixSockets.includes(socketPath)) {
|
|
204
|
+
const remaining = net.allowUnixSockets.filter((e) => e !== socketPath);
|
|
205
|
+
const sandbox = settings.sandbox;
|
|
206
|
+
if (remaining.length > 0) {
|
|
207
|
+
net.allowUnixSockets = remaining;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
delete net.allowUnixSockets;
|
|
211
|
+
if (Object.keys(net).length === 0)
|
|
212
|
+
delete sandbox.network;
|
|
213
|
+
if (Object.keys(sandbox).length === 0)
|
|
214
|
+
delete settings.sandbox;
|
|
215
|
+
}
|
|
216
|
+
sandboxSocket = 'removed';
|
|
217
|
+
}
|
|
95
218
|
const changed = JSON.stringify(before) !== JSON.stringify(settings);
|
|
96
219
|
if (changed) {
|
|
97
220
|
const tmp = settingsPath + '.tmp';
|
|
98
221
|
fs.writeFileSync(tmp, JSON.stringify(settings, null, 2), { mode: 0o600 });
|
|
99
222
|
fs.renameSync(tmp, settingsPath);
|
|
100
223
|
}
|
|
101
|
-
return { path: settingsPath, changed, before, after: settings };
|
|
224
|
+
return { path: settingsPath, changed, before, after: settings, sandboxSocket };
|
|
102
225
|
}
|
|
103
226
|
//# sourceMappingURL=setup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../src/adapters/claude-code/setup.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../src/adapters/claude-code/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAQ3D,MAAM,UAAU,mBAAmB;IACjC,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;AAC7D,CAAC;AAwBD,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,UAAU,CA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AC,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,OAAO,CAAC,OAAO,CAAC;YAC3D,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,QAAQ,CAAC,OAAO,CAAC;QACjE,CAAC;QACD,aAAa,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpE,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,GAAG,GAAG,YAAY,GAAG,MAAM,CAAC;QAClC,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1E,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex hook handler (v0.16.0).
|
|
3
|
+
*
|
|
4
|
+
* Codex's hook protocol follows Claude Code's shape (verified against
|
|
5
|
+
* openai/codex main, 2026-09-23; hooks are Stage::Stable, default on):
|
|
6
|
+
* - The shell tool (`exec_command`) reports `tool_name: "Bash"` and
|
|
7
|
+
* `tool_input: { command: "<string>" }`, so the Claude Code rewrite logic
|
|
8
|
+
* applies unchanged.
|
|
9
|
+
* - PreToolUse `updatedInput` requires `permissionDecision: "allow"`, and
|
|
10
|
+
* only `updatedInput.command` is read for shell calls. We send nothing
|
|
11
|
+
* else in the rewrite: invalid output makes Codex FAIL OPEN (the original
|
|
12
|
+
* command runs, unwrapped), so the payload stays minimal.
|
|
13
|
+
* - Deny: `permissionDecision: "deny"` plus a non-empty reason.
|
|
14
|
+
* - PostToolUse has no output-rewrite field for shell (`updatedMCPToolOutput`
|
|
15
|
+
* is rejected as unsupported). `continue: false` + `reason` does replace
|
|
16
|
+
* what the model sees, but also carries stop semantics we have not
|
|
17
|
+
* verified end to end, so PostToolUse here is warning-only. Wrapped
|
|
18
|
+
* commands are already scrubbed by `aquaman-coder exec`.
|
|
19
|
+
*/
|
|
20
|
+
import { type HookContext, type HookDecision, type HookEvent } from '../claude-code/hook.js';
|
|
21
|
+
export declare function handleCodexPreToolUse(event: HookEvent, ctx?: HookContext): Promise<HookDecision | null>;
|
|
22
|
+
export declare function handleCodexPostToolUse(event: HookEvent): HookDecision | null;
|
|
23
|
+
//# sourceMappingURL=hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../src/adapters/codex/hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAE/G,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,SAAS,EAChB,GAAG,GAAE,WAAgB,GACpB,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAwB9B;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,SAAS,GAAG,YAAY,GAAG,IAAI,CAiB5E"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex hook handler (v0.16.0).
|
|
3
|
+
*
|
|
4
|
+
* Codex's hook protocol follows Claude Code's shape (verified against
|
|
5
|
+
* openai/codex main, 2026-09-23; hooks are Stage::Stable, default on):
|
|
6
|
+
* - The shell tool (`exec_command`) reports `tool_name: "Bash"` and
|
|
7
|
+
* `tool_input: { command: "<string>" }`, so the Claude Code rewrite logic
|
|
8
|
+
* applies unchanged.
|
|
9
|
+
* - PreToolUse `updatedInput` requires `permissionDecision: "allow"`, and
|
|
10
|
+
* only `updatedInput.command` is read for shell calls. We send nothing
|
|
11
|
+
* else in the rewrite: invalid output makes Codex FAIL OPEN (the original
|
|
12
|
+
* command runs, unwrapped), so the payload stays minimal.
|
|
13
|
+
* - Deny: `permissionDecision: "deny"` plus a non-empty reason.
|
|
14
|
+
* - PostToolUse has no output-rewrite field for shell (`updatedMCPToolOutput`
|
|
15
|
+
* is rejected as unsupported). `continue: false` + `reason` does replace
|
|
16
|
+
* what the model sees, but also carries stop semantics we have not
|
|
17
|
+
* verified end to end, so PostToolUse here is warning-only. Wrapped
|
|
18
|
+
* commands are already scrubbed by `aquaman-coder exec`.
|
|
19
|
+
*/
|
|
20
|
+
import { redact, redactDeep } from 'aquaman-proxy';
|
|
21
|
+
import { handlePreToolUse } from '../claude-code/hook.js';
|
|
22
|
+
export async function handleCodexPreToolUse(event, ctx = {}) {
|
|
23
|
+
const decision = await handlePreToolUse(event, ctx);
|
|
24
|
+
const out = decision?.hookSpecificOutput;
|
|
25
|
+
if (!out)
|
|
26
|
+
return decision;
|
|
27
|
+
if (out.permissionDecision === 'deny') {
|
|
28
|
+
return {
|
|
29
|
+
hookSpecificOutput: {
|
|
30
|
+
hookEventName: 'PreToolUse',
|
|
31
|
+
permissionDecision: 'deny',
|
|
32
|
+
permissionDecisionReason: out.permissionDecisionReason,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const command = out.updatedInput?.command;
|
|
37
|
+
if (typeof command !== 'string')
|
|
38
|
+
return null;
|
|
39
|
+
return {
|
|
40
|
+
hookSpecificOutput: {
|
|
41
|
+
hookEventName: 'PreToolUse',
|
|
42
|
+
permissionDecision: 'allow',
|
|
43
|
+
updatedInput: { command },
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function handleCodexPostToolUse(event) {
|
|
48
|
+
const out = event.tool_response;
|
|
49
|
+
if (out === undefined || out === null)
|
|
50
|
+
return null;
|
|
51
|
+
const { findings } = typeof out === 'string' ? redact(out) : redactDeep(out);
|
|
52
|
+
if (findings.length === 0)
|
|
53
|
+
return null;
|
|
54
|
+
const summary = findings.map((f) => `${f.kind}×${f.count}`).join(', ');
|
|
55
|
+
return {
|
|
56
|
+
hookSpecificOutput: {
|
|
57
|
+
hookEventName: 'PostToolUse',
|
|
58
|
+
additionalContext: `aquaman: this command's output contained secret patterns (${summary}). ` +
|
|
59
|
+
`Codex offers no way for a hook to rewrite shell output, so they were not ` +
|
|
60
|
+
`removed. Treat the output as sensitive and do not repeat those values.`,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../../src/adapters/codex/hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAuD,MAAM,wBAAwB,CAAC;AAE/G,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,KAAgB,EAChB,MAAmB,EAAE;IAErB,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACpD,MAAM,GAAG,GAAG,QAAQ,EAAE,kBAAkB,CAAC;IACzC,IAAI,CAAC,GAAG;QAAE,OAAO,QAAQ,CAAC;IAE1B,IAAI,GAAG,CAAC,kBAAkB,KAAK,MAAM,EAAE,CAAC;QACtC,OAAO;YACL,kBAAkB,EAAE;gBAClB,aAAa,EAAE,YAAY;gBAC3B,kBAAkB,EAAE,MAAM;gBAC1B,wBAAwB,EAAE,GAAG,CAAC,wBAAwB;aACvD;SACF,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,G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