refactor: unify hook notification system, remove duplicate broadcasts
- Replace forward-hook.ps1 with notify.ps1 (now accepts optional agent param) - Remove ejecutor settings.local.json (redundant status hooks, deriveStatus covers it) - Remove legacy claude-permission system (route, store methods, terminal broadcast) - Remove redundant deriveStatus + /claude-status POST from claude-hook.ts (broadcastClaudeHook → processHookEvent already handles status derivation) - Clean up HookNotifications.vue permission buttons (dead code)
This commit is contained in:
@@ -2,7 +2,7 @@ import { jsonResponse, errorResponse } from '../utils/cors'
|
||||
import { PORT_TERMINAL } from '../config'
|
||||
import { existsSync, readFileSync } from 'fs'
|
||||
import { setActiveSession, getIncrementalMessages } from '../services/transcript-engine'
|
||||
import { deriveStatus, sessionState, type HookPayload } from '../services/session-state'
|
||||
import { sessionState, type HookPayload } from '../services/session-state'
|
||||
|
||||
export async function handleClaudeHook(req: Request): Promise<Response | null> {
|
||||
if (req.method !== 'POST') return null
|
||||
@@ -68,34 +68,7 @@ export async function handleClaudeHook(req: Request): Promise<Response | null> {
|
||||
console.error('[claude-hook] Failed to forward hook to terminal server:', e)
|
||||
}
|
||||
|
||||
// 2. Forward PermissionRequest to /claude-permission for hooks approval system
|
||||
if (body.hook_event_name === 'PermissionRequest') {
|
||||
try {
|
||||
await fetch(`http://localhost:${PORT_TERMINAL}/claude-permission`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(hookData)
|
||||
})
|
||||
} catch (e) {
|
||||
console.error('[claude-hook] Failed to forward permission to terminal server:', e)
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Derive status and broadcast via WebSocket
|
||||
const derived = deriveStatus(body)
|
||||
if (derived) {
|
||||
try {
|
||||
await fetch(`http://localhost:${PORT_TERMINAL}/claude-status`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ status: derived.status, tool: derived.tool, agent })
|
||||
})
|
||||
} catch (e) {
|
||||
console.error('[claude-hook] Failed to forward status to terminal server:', e)
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Incremental transcript reading for real-time chat
|
||||
// 2. Incremental transcript reading for real-time chat
|
||||
if (body.session_id && body.transcript_path) {
|
||||
setActiveSession(agent, body.session_id, body.transcript_path as string)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user