MCPcopy Create free account
hub / github.com/apache/maka / decodeLlmUsageQuery

Function decodeLlmUsageQuery

packages/runtime-host/src/protocol/usage-pricing.ts:643–654  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

641}
642
643function decodeLlmUsageQuery(value: unknown): LlmUsageQuery {
644 const query = requireRecord(value, 'usage query');
645 assertAllowedKeys(query, LLM_USAGE_QUERY_FIELDS, 'LLM usage query');
646 if (!Object.hasOwn(query, 'range')) throw invalidProtocolFrame('Invalid usage query fields');
647 return {
648 range: decodeUsageRange(query.range),
649 ...optionalQueryText(query, 'connectionSlug'),
650 ...optionalQueryText(query, 'providerId'),
651 ...optionalQueryText(query, 'modelId'),
652 ...(query.status === undefined ? {} : { status: decodeUsageStatus(query.status) }),
653 };
654}
655
656function decodeToolUsageQuery(value: unknown): ToolUsageQuery {
657 const query = requireRecord(value, 'tool usage query');

Callers 1

decodeUsageQueryInputFunction · 0.85

Calls 6

invalidProtocolFrameFunction · 0.85
decodeUsageRangeFunction · 0.85
optionalQueryTextFunction · 0.85
decodeUsageStatusFunction · 0.85
requireRecordFunction · 0.70
assertAllowedKeysFunction · 0.70

Tested by

no test coverage detected