/* Free checks of a key: what a provider will say about a key without being
* sent a conversation (its key or balance endpoint, or its models list).
* The adapter of the provider's API says what to ask (provider_http.h,
* pic_provider_probe); this asks it of every wanted key at once, each with
* its own deadline, and records what comes back in picu_credential_health
* (cred.h): remaining credit, or valid, refused, out of credit, limited. A
* check sends the key only to the base URL the provider's requests use, and
* never text of a conversation; no answer or a status that says nothing
* about the key changes no state, only the time it was tried. It runs only
* when something asks: `pic auth status --check`, and the terminal interface
* in its own child process. Never in print, JSON or RPC mode. */
#ifndef PIC_KEYPROBE_H
#define PIC_KEYPROBE_H
/* A key checked within this long is not checked again unless forced. */
#define PIC_KEYPROBE_FRESH_MS 600000LL
/* Seconds each check may take, from the first byte sent to the last read. */
#define PIC_KEYPROBE_DEADLINE 8
typedef struct {
int force; /* check every key, fresh or not */
int active_only; /* only the key each provider's requests use */
int no_prompt; /* never ask for the passphrase: a locked store's keys are left alone */
const char *provider; /* only this provider's keys; NULL: all */
const char *label; /* only the key with this label ("default" for its own row); NULL: all */
int deadline; /* seconds; 0: PIC_KEYPROBE_DEADLINE */
} pic_keyprobe_opts;
/* Checks the wanted keys in parallel and records each answer as it arrives.
* How many were checked, or -1 when the credential store cannot be read. */
int pic_keyprobe(const pic_keyprobe_opts *o);
/* A key just saved, checked at once: asks its provider's free check of exactly that key, then reads
* what is recorded. 1 when the answer was a refusal (the words in `words`: 'anthropic refused the key
* "default" (HTTP 401: ...)'), 2 when it has no credit or is limited (words likewise), 0 when it is
* valid or the check said nothing (no answer, offline, PIC_NO_KEY_CHECKS set). */
int pic_keyprobe_saved(const char *provider, const char *label, char *words, size_t cap);
#endif