AIToolApprover

class AIToolApprover(val userId: String, val clientId: String, scope: CoroutineScope, val authorizer: AIToolAuthorizer? = null, decide: suspend (call: AIToolCallPart, allowed: Boolean) -> Unit)

The person answering tool calls' questions and sign-ins on this device, and how their answer reaches your backend, which holds each call until it gets one.

The approver keeps where each answer is, so create it where it outlives the screen, such as a ViewModel. It is confined to the main thread: pass a scope that runs on it, such as a viewModelScope.

Parameters

userId

The person signed in, matched against a call's target_user_id.

clientId

This install, matched against a client tool call's target_client_id. Use AIClientIdentity.installId.

scope

Where answers are sent.

authorizer

How this person signs in when a call waits for their account at a provider. Without one, no sign-in is offered here.

decide

Sends the answer. Your backend checks it is this person's (and this install's, for a client tool), then updates the call's step; until then the question stays, with its buttons disabled. A thrown exception lets the person answer again.

Constructors

Link copied to clipboard
constructor(userId: String, clientId: String, scope: CoroutineScope, authorizer: AIToolAuthorizer? = null, decide: suspend (call: AIToolCallPart, allowed: Boolean) -> Unit)
constructor(userId: String, clientId: String, scope: CoroutineScope, decide: suspend (call: AIToolCallPart, allowed: Boolean) -> Unit)

An approver that answers tool calls' questions here, without offering sign-ins.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard