Interface: IUsageGuard
Defined in: internal/usage-guard/types.ts:40
The gateway holds no token logic; it asks, it reports.
Implemented by UsageGuard; the type of IAIGatewayDeps.usageGuard, so a host may pass its own in overrides.
Methods
addUsage()
addUsage(
args):Promise<void>
Defined in: internal/usage-guard/types.ts:71
addUsage -- tells the app what the call used
About
One report to the app, never fatal.
Passes the report to the adapter. When the adapter throws, the error is logged and nothing else happens: the call already ran and its answer belongs to the user.
Who needs it
The LLMClient, after every approved check — also when the provider call failed or was aborted.
Parameters
args
Returns
Promise<void>
check()
check(
args):Promise<IUsageCheckResult>
Defined in: internal/usage-guard/types.ts:55
check -- may this model call run?
About
One question to the app, fail closed.
Passes the call's factors and its rough size to the adapter and returns its answer. When the adapter throws, the call is
refused with USAGE_CHECK_FAILED_DENY_CODE and the error is logged: an app that cannot answer has not said yes.
Who needs it
The LLMClient, right before a provider call.
Parameters
args
Returns
Promise<IUsageCheckResult>