Skip to content

Commit ca5455d

Browse files
fix(hooks): Update hook schema to use permissionDecision
- Replace 'decision: allow/block' with 'permissionDecision: allow/deny' - Use 'updatedInput' for PreToolUse input modification - Fix auto-background-hook and sms-response-handler schemas
1 parent cb578f3 commit ca5455d

2 files changed

Lines changed: 17 additions & 27 deletions

File tree

templates/claude-hooks/auto-background-hook.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,19 @@ process.stdin.on('end', () => {
110110
// Only process Bash tool
111111
if (tool_name !== 'Bash') {
112112
// Allow other tools through unchanged
113-
console.log(JSON.stringify({ decision: 'allow' }));
113+
console.log(JSON.stringify({ permissionDecision: 'allow' }));
114114
return;
115115
}
116116

117117
const command = tool_input?.command;
118118
if (!command) {
119-
console.log(JSON.stringify({ decision: 'allow' }));
119+
console.log(JSON.stringify({ permissionDecision: 'allow' }));
120120
return;
121121
}
122122

123123
// Already backgrounded
124124
if (tool_input.run_in_background === true) {
125-
console.log(JSON.stringify({ decision: 'allow' }));
125+
console.log(JSON.stringify({ permissionDecision: 'allow' }));
126126
return;
127127
}
128128

@@ -135,22 +135,23 @@ process.stdin.on('end', () => {
135135
);
136136
}
137137

138-
// Modify the tool input to add run_in_background
138+
// Modify the tool input to add run_in_background using correct schema
139139
console.log(
140140
JSON.stringify({
141-
decision: 'modify',
142-
tool_input: {
141+
hookEventName: 'PreToolUse',
142+
permissionDecision: 'allow',
143+
updatedInput: {
143144
...tool_input,
144145
run_in_background: true,
145146
},
146147
})
147148
);
148149
} else {
149-
console.log(JSON.stringify({ decision: 'allow' }));
150+
console.log(JSON.stringify({ permissionDecision: 'allow' }));
150151
}
151152
} catch (err) {
152153
// On error, allow the command through unchanged
153154
console.error('[auto-bg] Error:', err.message);
154-
console.log(JSON.stringify({ decision: 'allow' }));
155+
console.log(JSON.stringify({ permissionDecision: 'allow' }));
155156
}
156157
});

templates/claude-hooks/sms-response-handler.js

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,9 @@ process.stdin.on('end', () => {
139139

140140
clearLatestResponse();
141141

142-
console.log(
143-
JSON.stringify({
144-
decision: 'allow',
145-
context: context,
146-
user_message: `[SMS Response] User replied: "${latestResponse.response}"`,
147-
})
148-
);
142+
// Log context to stderr for visibility, allow the tool
143+
console.error(`[sms-hook] Context: ${JSON.stringify(context)}`);
144+
console.log(JSON.stringify({ permissionDecision: 'allow' }));
149145
return;
150146
}
151147

@@ -162,24 +158,17 @@ process.stdin.on('end', () => {
162158
)
163159
.join('\n');
164160

165-
console.log(
166-
JSON.stringify({
167-
decision: 'allow',
168-
context: {
169-
type: 'sms_actions_executed',
170-
results,
171-
},
172-
user_message: `[SMS Actions] Executed queued actions:\n${summary}`,
173-
})
174-
);
161+
// Log results to stderr for visibility, allow the tool
162+
console.error(`[sms-hook] Actions summary:\n${summary}`);
163+
console.log(JSON.stringify({ permissionDecision: 'allow' }));
175164
return;
176165
}
177166
}
178167

179168
// Default: allow everything
180-
console.log(JSON.stringify({ decision: 'allow' }));
169+
console.log(JSON.stringify({ permissionDecision: 'allow' }));
181170
} catch (err) {
182171
console.error('[sms-hook] Error:', err.message);
183-
console.log(JSON.stringify({ decision: 'allow' }));
172+
console.log(JSON.stringify({ permissionDecision: 'allow' }));
184173
}
185174
});

0 commit comments

Comments
 (0)