Files
HealthLog/src/lib/ai/provider-egress.ts
T
Marc-André Bombeck 5fd858e0af refactor(ai): define the operator-held providers once
The list of provider tags that send data out through a credential the
operator holds (admin-openai, admin-codex) existed four times: in the
consent gate, in the capability resolver, in the shared-provider health
read and in the admin provider-health ordering. A tag added to one and not
the others would be consented for in one place and not the other. The list
and the local-provider test now live in src/lib/ai/provider-egress.ts and
every reader imports them.

The guard meant to keep one copy matched a variable name, so the copy in
the resolver, under another name, never tripped it. It now matches the
list itself in either order and names the one file allowed to hold it.
2026-09-26 20:27:53 +02:00

37 lines
1.4 KiB
TypeScript

/**
* Which AI provider tags send a record off the machine, and through whose
* credential. One definition, read by the consent gate
* (`src/lib/ai/consent-guard.ts`) and the capability resolver
* (`src/lib/ai/capabilities/resolve.ts`). They each kept their own copy
* before, and a provider added to one list but not the other would have been
* consented for in one place and not the other.
*/
/**
* Provider tags that egress through a credential the operator holds, which
* the user did not personally contract: the operator's global OpenAI key
* (`admin-openai`) and the operator's shared Codex / ChatGPT-subscription
* account (`admin-codex`). Both need an active consent receipt before any
* health data leaves for them.
*/
export const OPERATOR_HELD_PROVIDER_TYPES: ReadonlySet<string> = new Set([
"admin-openai",
"admin-codex",
]);
/** The one provider tag that keeps its input on the operator's machine. */
export const LOCAL_PROVIDER_TYPE = "local";
export function isOperatorHeldProvider(providerType: string): boolean {
return OPERATOR_HELD_PROVIDER_TYPES.has(providerType);
}
/**
* True when this provider sends its input OFF the machine to a third-party AI
* service. Only the self-hosted `local` provider keeps it on the operator's
* own infrastructure.
*/
export function isExternalProvider(providerType: string): boolean {
return providerType !== LOCAL_PROVIDER_TYPE;
}