MCPcopy Create free account
hub / github.com/anomalyco/opencode / copilotTotalNanoAiu

Function copilotTotalNanoAiu

packages/opencode/src/session/llm/ai-sdk.ts:32–42  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

30// Temporary AI SDK bridge: Copilot billing survives only in raw provider chunks here.
31// Move this extraction into @opencode-ai/llm when Copilot is handled by the native runtime.
32function copilotTotalNanoAiu(value: unknown) {
33 if (!value || typeof value !== "object") return
34 const raw = value as Record<string, unknown>
35 const response =
36 raw.response && typeof raw.response === "object" ? (raw.response as Record<string, unknown>) : undefined
37 const usage = raw.copilot_usage ?? response?.copilot_usage
38 if (!usage || typeof usage !== "object") return
39 const total = (usage as Record<string, unknown>).total_nano_aiu
40 if (typeof total !== "number" || !Number.isFinite(total) || total < 0) return
41 return total
42}
43
44function usage(value: unknown) {
45 if (!value || typeof value !== "object") return undefined

Callers 1

toLLMEventsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected