import { Entity } from "../../../common/abstracts/entity"; import { Company } from "../../company/entities/company"; /** * TokenUsage Entity Type * * An accounting record of a single LLM (large-language-model) call made by the * platform: how many tokens it consumed and what it cost. Written automatically * by the LLM call paths (see `TokenUsageService.recordTokenUsage`) — never * created or edited directly by end users. */ export type TokenUsage = Entity & { inputTokens: number; outputTokens: number; cachedInputTokens?: number; cost?: number; credits?: number; tokenUsageType: string; model?: string; provider?: string; company: Company; }; /** * TokenUsage Entity Descriptor * * Replaces the hand-written `TokenUsageModel` (`entities/tokenusage.model.ts`, * deleted), whose `serialiser` was `undefined` — the entity had no JSON:API * wire at all. This descriptor is therefore the FIRST tokenusage serialiser: * every attribute below is new on the wire for consuming apps, with no prior * consumer to constrain it. * * Relationship-parity note: the old model declared `childrenTokens: []` and * `singleChildrenTokens: [companyMeta.nodeName]`, so no relationships are * declared here either (`isCompanyScoped: true` reinstates the company token). * Real graph edges exist — BELONGS_TO (company), TRIGGERED_BY (user), USED_FOR * (the polymorphic target entity, see `TokenUsageRepository.create()`) — but * were never part of the JSON:API surface. USED_FOR in particular is * polymorphic (any entity label), which the descriptor's fixed-target * `relationships` shape cannot express as a single relationship. * * `tokenUsageType` stays `type: "string"`: the set of operations that record * usage is application-specific, so consuming apps narrow it with their own * enum rather than the package pinning one. * * No top-level `description`/`chat` block: the chatbot copy is * application-specific (it describes each app's own operation names and * billing model) and is supplied by the consuming app's extended descriptor. * Per-field `description`s live here so an extended descriptor can spread * `TokenUsageDescriptor.fields` and inherit them. */ export declare const TokenUsageDescriptor: import("../../..").EntityDescriptor; export type TokenUsageDescriptorType = typeof TokenUsageDescriptor; //# sourceMappingURL=tokenusage.d.ts.map