aquaman-coder 0.13.1 → 0.14.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.
|
@@ -13,11 +13,17 @@
|
|
|
13
13
|
* `updatedInput.command` to invoke it under `aquaman-coder exec`,
|
|
14
14
|
* which runs the broker resolve + redaction pipeline server-side.
|
|
15
15
|
*
|
|
16
|
-
* PostToolUse hookSpecificOutput
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* PostToolUse hookSpecificOutput supports `additionalContext` and — since
|
|
17
|
+
* Claude Code ~2.1.170 (verified stable through 2.1.215, 2026-07-19) —
|
|
18
|
+
* `updatedToolOutput`, which rewrites the tool output before it reaches
|
|
19
|
+
* the transcript. We run the redactor over every tool's output (Read /
|
|
20
|
+
* Grep / Glob surfacing on-disk secrets, unwrapped Bash, MCP tools) and
|
|
21
|
+
* rewrite in place. This is defense-in-depth on top of `aquaman-coder
|
|
22
|
+
* exec`'s stdout/stderr scrubbing: the exec wrapper knows the literal
|
|
23
|
+
* injected values (value-based redaction), the hook covers shape-based
|
|
24
|
+
* patterns for outputs that never passed through the wrapper. Set
|
|
25
|
+
* AQUAMAN_DISABLE_OUTPUT_REWRITE=1 to fall back to warning-only on
|
|
26
|
+
* pre-2.1.170 Claude Code versions that don't know the field.
|
|
21
27
|
*/
|
|
22
28
|
import { BrokerClient } from '../../broker-client.js';
|
|
23
29
|
export interface HookEvent {
|
|
@@ -42,6 +48,12 @@ export interface HookContext {
|
|
|
42
48
|
* `aquaman-coder exec --` — change in tests to assert the rewrite.
|
|
43
49
|
*/
|
|
44
50
|
wrapperPrefix?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Disable PostToolUse `updatedToolOutput` rewriting (fall back to the
|
|
53
|
+
* warning-only additionalContext behavior for Claude Code < 2.1.170).
|
|
54
|
+
* Defaults to the AQUAMAN_DISABLE_OUTPUT_REWRITE env var.
|
|
55
|
+
*/
|
|
56
|
+
disableOutputRewrite?: boolean;
|
|
45
57
|
}
|
|
46
58
|
/**
|
|
47
59
|
* If the project map has env bindings AND this is a Bash tool call AND
|
|
@@ -51,12 +63,18 @@ export interface HookContext {
|
|
|
51
63
|
*/
|
|
52
64
|
export declare function handlePreToolUse(event: HookEvent, ctx?: HookContext): Promise<HookDecision | null>;
|
|
53
65
|
/**
|
|
54
|
-
* Inspect tool output for leaked secrets
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
66
|
+
* Inspect tool output for leaked secrets and rewrite it via
|
|
67
|
+
* `updatedToolOutput` (Claude Code ≥2.1.170) so redacted markers — not
|
|
68
|
+
* the secrets — reach the transcript. Applies to every tool: Read/Grep
|
|
69
|
+
* surfacing on-disk secrets, MCP tools, and Bash commands that didn't
|
|
70
|
+
* route through the exec wrapper. String outputs stay strings; structured
|
|
71
|
+
* outputs are deep-redacted with their shape preserved.
|
|
72
|
+
*
|
|
73
|
+
* With rewriting disabled (AQUAMAN_DISABLE_OUTPUT_REWRITE=1, for
|
|
74
|
+
* pre-2.1.170 hosts) this degrades to the historical warning-only
|
|
75
|
+
* additionalContext behavior.
|
|
58
76
|
*/
|
|
59
|
-
export declare function handlePostToolUse(event: HookEvent): HookDecision | null;
|
|
77
|
+
export declare function handlePostToolUse(event: HookEvent, ctx?: HookContext): HookDecision | null;
|
|
60
78
|
/**
|
|
61
79
|
* Stdio entry point: read JSON from stdin, dispatch by hook_event_name,
|
|
62
80
|
* write decision to stdout (exit 0) or error to stderr (exit 2).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../src/adapters/claude-code/hook.ts"],"names":[],"mappings":"AAAA
|
|
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;AAEtD,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;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,CAkCjB"}
|
|
@@ -13,16 +13,22 @@
|
|
|
13
13
|
* `updatedInput.command` to invoke it under `aquaman-coder exec`,
|
|
14
14
|
* which runs the broker resolve + redaction pipeline server-side.
|
|
15
15
|
*
|
|
16
|
-
* PostToolUse hookSpecificOutput
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* PostToolUse hookSpecificOutput supports `additionalContext` and — since
|
|
17
|
+
* Claude Code ~2.1.170 (verified stable through 2.1.215, 2026-07-19) —
|
|
18
|
+
* `updatedToolOutput`, which rewrites the tool output before it reaches
|
|
19
|
+
* the transcript. We run the redactor over every tool's output (Read /
|
|
20
|
+
* Grep / Glob surfacing on-disk secrets, unwrapped Bash, MCP tools) and
|
|
21
|
+
* rewrite in place. This is defense-in-depth on top of `aquaman-coder
|
|
22
|
+
* exec`'s stdout/stderr scrubbing: the exec wrapper knows the literal
|
|
23
|
+
* injected values (value-based redaction), the hook covers shape-based
|
|
24
|
+
* patterns for outputs that never passed through the wrapper. Set
|
|
25
|
+
* AQUAMAN_DISABLE_OUTPUT_REWRITE=1 to fall back to warning-only on
|
|
26
|
+
* pre-2.1.170 Claude Code versions that don't know the field.
|
|
21
27
|
*/
|
|
22
28
|
// Note: imported from `aquaman-proxy` (which re-exports from its
|
|
23
29
|
// merged core/). There is no separate `aquaman-core` npm package since
|
|
24
30
|
// v0.7.0; the vitest alias resolves the same path for tests.
|
|
25
|
-
import { redact } from 'aquaman-proxy';
|
|
31
|
+
import { redact, redactDeep } from 'aquaman-proxy';
|
|
26
32
|
import { findProjectForCwd, loadProjects } from '../../projects.js';
|
|
27
33
|
import { BrokerClient } from '../../broker-client.js';
|
|
28
34
|
// Default wrapper uses the direct binary form (`aquaman-coder exec`) rather
|
|
@@ -88,27 +94,45 @@ export async function handlePreToolUse(event, ctx = {}) {
|
|
|
88
94
|
};
|
|
89
95
|
}
|
|
90
96
|
/**
|
|
91
|
-
* Inspect tool output for leaked secrets
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
97
|
+
* Inspect tool output for leaked secrets and rewrite it via
|
|
98
|
+
* `updatedToolOutput` (Claude Code ≥2.1.170) so redacted markers — not
|
|
99
|
+
* the secrets — reach the transcript. Applies to every tool: Read/Grep
|
|
100
|
+
* surfacing on-disk secrets, MCP tools, and Bash commands that didn't
|
|
101
|
+
* route through the exec wrapper. String outputs stay strings; structured
|
|
102
|
+
* outputs are deep-redacted with their shape preserved.
|
|
103
|
+
*
|
|
104
|
+
* With rewriting disabled (AQUAMAN_DISABLE_OUTPUT_REWRITE=1, for
|
|
105
|
+
* pre-2.1.170 hosts) this degrades to the historical warning-only
|
|
106
|
+
* additionalContext behavior.
|
|
95
107
|
*/
|
|
96
|
-
export function handlePostToolUse(event) {
|
|
108
|
+
export function handlePostToolUse(event, ctx = {}) {
|
|
97
109
|
const out = event.tool_response ?? event.tool_output;
|
|
98
110
|
if (out === undefined || out === null)
|
|
99
111
|
return null;
|
|
100
|
-
const
|
|
101
|
-
|
|
112
|
+
const rewriteEnabled = !(ctx.disableOutputRewrite ??
|
|
113
|
+
process.env.AQUAMAN_DISABLE_OUTPUT_REWRITE === '1');
|
|
114
|
+
const { output, findings } = typeof out === 'string' ? redact(out) : redactDeep(out);
|
|
102
115
|
if (findings.length === 0)
|
|
103
116
|
return null;
|
|
104
117
|
const summary = findings.map((f) => `${f.kind}×${f.count}`).join(', ');
|
|
118
|
+
if (!rewriteEnabled) {
|
|
119
|
+
return {
|
|
120
|
+
hookSpecificOutput: {
|
|
121
|
+
hookEventName: 'PostToolUse',
|
|
122
|
+
additionalContext: `aquaman: tool output contained secret patterns (${summary}). ` +
|
|
123
|
+
`These were detected after the fact — to scrub before output ` +
|
|
124
|
+
`reaches the model, ensure agent-invoked commands route through ` +
|
|
125
|
+
`\`aquaman-coder exec\`.`,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
105
129
|
return {
|
|
106
130
|
hookSpecificOutput: {
|
|
107
131
|
hookEventName: 'PostToolUse',
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
`
|
|
111
|
-
|
|
132
|
+
updatedToolOutput: output,
|
|
133
|
+
additionalContext: `aquaman: redacted secret patterns from this tool's output ` +
|
|
134
|
+
`(${summary}) before it reached the transcript. The underlying ` +
|
|
135
|
+
`data still exists at its source — treat it as sensitive.`,
|
|
112
136
|
},
|
|
113
137
|
};
|
|
114
138
|
}
|
|
@@ -136,7 +160,7 @@ export async function runHookFromStdin(_argv, ctx = {}) {
|
|
|
136
160
|
decision = await handlePreToolUse(event, ctx);
|
|
137
161
|
break;
|
|
138
162
|
case 'PostToolUse':
|
|
139
|
-
decision = handlePostToolUse(event);
|
|
163
|
+
decision = handlePostToolUse(event, ctx);
|
|
140
164
|
break;
|
|
141
165
|
default:
|
|
142
166
|
return 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../../src/adapters/claude-code/hook.ts"],"names":[],"mappings":"AAAA
|
|
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;AAkCtD,4EAA4E;AAC5E,sEAAsE;AACtE,uEAAuE;AACvE,yEAAyE;AACzE,kBAAkB;AAClB,MAAM,eAAe,GAAG,uBAAuB,CAAC;AAChD,MAAM,qBAAqB,GAAG,CAAC,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAgB,EAChB,MAAmB,EAAE;IAErB,IAAI,KAAK,CAAC,SAAS,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAC5C,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE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AAE,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aquaman-coder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Vault adapter for AI coding agents. Keep API keys, secrets, and .env contents out of your coding agent's memory and transcripts. Supports Claude Code (Codex, OpenCode, Cursor coming soon).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"author": "tech4242",
|
|
40
40
|
"license": "MIT",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"aquaman-proxy": "0.
|
|
42
|
+
"aquaman-proxy": "0.14.0",
|
|
43
43
|
"commander": "^11.0.0",
|
|
44
44
|
"yaml": "^2.3.4"
|
|
45
45
|
},
|