Function: createToolApprovalHandler()
Makaio Framework / ai-adapters-core / createToolApprovalHandler
Function: createToolApprovalHandler()
Section titled “Function: createToolApprovalHandler()”createToolApprovalHandler<
TPayload,TContext,TResponse>(subject,toGlobal,fromGlobal): (connector,context) => () =>void
Defined in: ../../../adapters/core/src/utils/tool-approval.ts:305
Factory: Create tool approval handler for adapter connector.
Wires adapter-scoped tool approval subject → AgentSubjects.toolApprove. Handles lazy context resolution to avoid race conditions with adapterSessionId.
Used by both test harnesses (createTestConfig) and production (agent.ts).
Type Parameters
Section titled “Type Parameters”TPayload
Section titled “TPayload”TPayload
TContext
Section titled “TContext”TContext = ToolApprovalContext
TResponse
Section titled “TResponse”TResponse = { action: "allow"; updatedInput?: Record<string, unknown>; updatedPermissions?: unknown[]; } | { action: "deny"; message: string; shouldAbort?: boolean; }
Parameters
Section titled “Parameters”subject
Section titled “subject”ScopedSubjectDefinition<string>
Adapter-scoped subject for tool approval requests
toGlobal
Section titled “toGlobal”ToGlobalToolApprovalFn<TPayload, TContext>
Transform SDK payload to global request
fromGlobal
Section titled “fromGlobal”FromGlobalToolApprovalFn<TResponse>
Transform global response to SDK format
Returns
Section titled “Returns”Handler registration function
(connector, context) => () => void
Example
Section titled “Example”// In gemini-sdk/src/tool-handling.tsexport const registerToolApprovalHandler = createToolApprovalHandler( GeminiConnectorSubjects.acp.tool_approval, toGlobalToolApproval, fromGlobalToolApproval,);