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

Function usage

packages/core/src/session/projector.ts:36–42  ·  view source on GitHub ↗
(part: (typeof SessionV1.Event.PartUpdated.Type)["data"]["part"] | unknown)

Source from the content-addressed store, hash-verified

34}
35
36function usage(part: (typeof SessionV1.Event.PartUpdated.Type)["data"]["part"] | unknown): Usage | undefined {
37 if (typeof part !== "object" || part === null) return undefined
38 const value = part as Record<string, unknown>
39 if (value.type !== "step-finish") return undefined
40 if (!("cost" in value) || !("tokens" in value)) return undefined
41 return { cost: value.cost as Usage["cost"], tokens: value.tokens as Usage["tokens"] }
42}
43
44function sessionRow(info: SessionV1.SessionInfo): typeof SessionTable.$inferInsert {
45 return {

Callers 3

projector.tsFile · 0.70
NewUserSectionFunction · 0.50
UsageSectionFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected