68
* (via `PendingRequestRegistry.registerAndFire`).
69
*/
71
>
deps: IClaudeCanUseToolDeps,
72
>
sessionId: string,
73
>
toolName: string,
74
>
input: Record<string, unknown>,
75
>
options: IClaudeCanUseToolOptions,
76
>
): Promise<PermissionResult> {
77
>
const session = deps.getSession(sessionId);
78
>
if (!session) {
79
return { behavior: 'deny', message: 'Session is no longer active' };
80
}
82
>
// Observe the SDK's per-request abort signal so a host parked on
83
>
// `requestPermission` / `requestUserInput` unwinds promptly when
84
>
// the SDK cancels the canUseTool call (subprocess teardown,
85
>
// upstream abort). Both `respondTo*` methods are no-ops if the
86
>
// id is not pending, so it is safe to fire both regardless of
87
>
// which channel this tool happens to use.
88
>
if (options.signal.aborted) {
89
return { behavior: 'deny', message: 'SDK aborted the tool request' };
90
}