const ALLOW_OPTION = {
    optionId: 'allow',
    name: 'Allow',
    kind: 'allow_once',
};
const DENY_OPTION = {
    optionId: 'deny',
    name: 'Deny',
    kind: 'reject_once',
};
export async function requestToolPermission(session, toolCall, conn, meta) {
    const toolCallUpdate = {
        toolCallId: toolCall.id,
        title: meta?.title ?? toolCall.function.name,
        kind: meta?.kind,
        rawInput: toolCall.function.arguments,
        status: 'pending',
        content: meta && meta.content.length > 0 ? meta.content : undefined,
        locations: meta && meta.locations.length > 0 ? meta.locations : undefined,
    };
    const response = await conn.requestPermission({
        sessionId: session.sessionId,
        options: [ALLOW_OPTION, DENY_OPTION],
        toolCall: toolCallUpdate,
    });
    if (response.outcome.outcome === 'cancelled') {
        return 'cancelled';
    }
    if (response.outcome.outcome === 'selected' &&
        response.outcome.optionId === 'allow') {
        return 'approved';
    }
    return 'denied';
}
//# sourceMappingURL=acp-permission.js.map