import { type PropsWithChildren, type ReactNode } from 'react'; import type { AIToolCallPart } from '../MessageParts'; /** * How the person signs in on this device when a tool call waits for their account at a * provider, and how their "not now" reaches your backend, which holds the call until one or * the other. `createPopupAuthorizer` makes one that opens the sign-in in a popup. */ export type AIToolAuthorizer = { /** * Opens the call's sign-in. It is called in the click handler, so a popup it opens before * anything is awaited is not blocked. * * Resolves `true` once the account is connected: your backend then updates the call's step, * and until it does the sign-in reads as connecting. Resolves `false` when the person closed * the sign-in or it ended without connecting, so they can try again. Rejects when the sign-in * could not be opened. */ connect: (call: AIToolCallPart) => Promise; /** * Tells your backend the person won't sign in now. Your backend ends the call, which never * runs. A rejection lets the person answer again. */ decline: (call: AIToolCallPart) => Promise; }; /** * The person answering tool calls' questions on this device, and how their answer reaches * your backend, which holds each call until it gets one. */ export type AIToolApprover = { /** This install, matched against a client tool call's `target_client_id`. Use `AIClientIdentity.installId()`. */ clientId: string; /** * 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 rejection lets the person answer again. */ decide: (call: AIToolCallPart, allowed: boolean) => Promise; /** The person signed in, matched against a call's `target_user_id`. */ userId: string; /** * What an approval card shows of what the call will send, under its question. Return the * view of `call.arguments` the app wants, such as a sentence or a table, `null` to show * nothing, or `undefined` for the default: the arguments as JSON, collapsed when long. */ argumentsPreview?: (call: AIToolCallPart) => ReactNode | null | undefined; /** How this person signs in when a call waits for their account. Without one, no sign-in is offered here. */ authorizer?: AIToolAuthorizer; }; /** * Provides the approver to the AI components below it, for those not given one as a prop. */ export declare const AIToolApproverProvider: ({ approver, children, }: PropsWithChildren<{ approver?: AIToolApprover; }>) => import("react/jsx-runtime").JSX.Element; /** The approver given as a prop, else the one of the nearest `AIToolApproverProvider`. */ export declare const useAIToolApprover: (approver?: AIToolApprover) => AIToolApprover | undefined; //# sourceMappingURL=AIToolApprover.d.ts.map