Release v5.1.3: Fix PostToolUse hook field name bug

Bug Fix:
- Changed tool_output to tool_response throughout PostToolUse hook chain
- PostToolUse events provide tool_response field, not tool_output
- Updated save-hook.ts to send tool_response
- Updated worker-service.ts endpoint to accept tool_response
- Updated worker-service-v2.ts for consistency
- Updated worker-types.ts interfaces (PendingMessage, ObservationData)
- Updated SessionManager.ts message queue
- Updated SDKAgent.ts observation prompt builder

Impact: Fixes observation capture for PostToolUse events. Previous version was sending undefined for tool responses, causing incomplete observations.

Files changed:
- src/hooks/save-hook.ts (interface + destructuring + fetch body)
- src/services/worker-service.ts (ObservationMessage interface + handler + SDK prompt)
- src/services/worker-service-v2.ts (handler)
- src/services/worker-types.ts (PendingMessage + ObservationData interfaces)
- src/services/worker/SessionManager.ts (queue push)
- src/services/worker/SDKAgent.ts (observation prompt)
- plugin/scripts/*.js (rebuilt)
- Version bumped to 5.1.3 (patch)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Alex Newman
2025-11-07 11:47:03 -05:00
parent 980151a50e
commit 13643a5b18
12 changed files with 21 additions and 21 deletions
+3 -3
View File
@@ -14,7 +14,7 @@ export interface PostToolUseInput {
cwd: string;
tool_name: string;
tool_input: any;
tool_output: any;
tool_response: any;
[key: string]: any;
}
@@ -31,7 +31,7 @@ async function saveHook(input?: PostToolUseInput): Promise<void> {
throw new Error('saveHook requires input');
}
const { session_id, tool_name, tool_input, tool_output } = input;
const { session_id, tool_name, tool_input, tool_response } = input;
if (SKIP_TOOLS.has(tool_name)) {
console.log(createHookResponse('PostToolUse', true));
@@ -64,7 +64,7 @@ async function saveHook(input?: PostToolUseInput): Promise<void> {
body: JSON.stringify({
tool_name,
tool_input: tool_input !== undefined ? JSON.stringify(tool_input) : '{}',
tool_output: tool_output !== undefined ? JSON.stringify(tool_output) : '{}',
tool_response: tool_response !== undefined ? JSON.stringify(tool_response) : '{}',
prompt_number: promptNumber
}),
signal: AbortSignal.timeout(2000)
+2 -2
View File
@@ -206,12 +206,12 @@ export class WorkerService {
private handleObservations(req: Request, res: Response): void {
try {
const sessionDbId = parseInt(req.params.sessionDbId, 10);
const { tool_name, tool_input, tool_output, prompt_number } = req.body;
const { tool_name, tool_input, tool_response, prompt_number } = req.body;
this.sessionManager.queueObservation(sessionDbId, {
tool_name,
tool_input,
tool_output,
tool_response,
prompt_number
});
+5 -5
View File
@@ -73,7 +73,7 @@ interface ObservationMessage {
type: 'observation';
tool_name: string;
tool_input: string;
tool_output: string;
tool_response: string;
prompt_number: number;
}
@@ -753,11 +753,11 @@ class WorkerService {
/**
* POST /sessions/:sessionDbId/observations
* Body: { tool_name, tool_input, tool_output, prompt_number }
* Body: { tool_name, tool_input, tool_response, prompt_number }
*/
private handleObservation(req: Request, res: Response): void {
const sessionDbId = parseInt(req.params.sessionDbId, 10);
const { tool_name, tool_input, tool_output, prompt_number } = req.body;
const { tool_name, tool_input, tool_response, prompt_number } = req.body;
const session = this.getOrCreateSession(sessionDbId);
const toolStr = logger.formatTool(tool_name, tool_input);
@@ -771,7 +771,7 @@ class WorkerService {
type: 'observation',
tool_name,
tool_input,
tool_output,
tool_response,
prompt_number
});
@@ -977,7 +977,7 @@ class WorkerService {
id: 0,
tool_name: message.tool_name,
tool_input: message.tool_input,
tool_output: message.tool_output,
tool_output: message.tool_response,
created_at_epoch: Date.now()
});
+2 -2
View File
@@ -25,14 +25,14 @@ export interface PendingMessage {
type: 'observation' | 'summarize';
tool_name?: string;
tool_input?: any;
tool_output?: any;
tool_response?: any;
prompt_number?: number;
}
export interface ObservationData {
tool_name: string;
tool_input: any;
tool_output: any;
tool_response: any;
prompt_number: number;
}
+1 -1
View File
@@ -137,7 +137,7 @@ export class SDKAgent {
id: 0, // Not used in prompt
tool_name: message.tool_name!,
tool_input: JSON.stringify(message.tool_input),
tool_output: JSON.stringify(message.tool_output),
tool_output: JSON.stringify(message.tool_response),
created_at_epoch: Date.now()
})
},
+1 -1
View File
@@ -80,7 +80,7 @@ export class SessionManager {
type: 'observation',
tool_name: data.tool_name,
tool_input: data.tool_input,
tool_output: data.tool_output,
tool_response: data.tool_response,
prompt_number: data.prompt_number
});