source dump of claude code
at main 43 lines 1.4 kB view raw
1import type { PermissionUpdate } from '../utils/permissions/PermissionUpdateSchema.js' 2 3type BridgePermissionResponse = { 4 behavior: 'allow' | 'deny' 5 updatedInput?: Record<string, unknown> 6 updatedPermissions?: PermissionUpdate[] 7 message?: string 8} 9 10type BridgePermissionCallbacks = { 11 sendRequest( 12 requestId: string, 13 toolName: string, 14 input: Record<string, unknown>, 15 toolUseId: string, 16 description: string, 17 permissionSuggestions?: PermissionUpdate[], 18 blockedPath?: string, 19 ): void 20 sendResponse(requestId: string, response: BridgePermissionResponse): void 21 /** Cancel a pending control_request so the web app can dismiss its prompt. */ 22 cancelRequest(requestId: string): void 23 onResponse( 24 requestId: string, 25 handler: (response: BridgePermissionResponse) => void, 26 ): () => void // returns unsubscribe 27} 28 29/** Type predicate for validating a parsed control_response payload 30 * as a BridgePermissionResponse. Checks the required `behavior` 31 * discriminant rather than using an unsafe `as` cast. */ 32function isBridgePermissionResponse( 33 value: unknown, 34): value is BridgePermissionResponse { 35 if (!value || typeof value !== 'object') return false 36 return ( 37 'behavior' in value && 38 (value.behavior === 'allow' || value.behavior === 'deny') 39 ) 40} 41 42export { isBridgePermissionResponse } 43export type { BridgePermissionCallbacks, BridgePermissionResponse }